From 5c3394e21fcad7c18d1307fb7d4053e61315cf5d Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 13 Dec 2023 13:48:16 +0100 Subject: [PATCH] warn on datatype explicitly null --- .../src/Core/Compatibility.ControlGallery.Core.csproj | 7 +++---- src/Controls/samples/Directory.Build.props | 3 ++- src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs | 3 +++ .../tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj | 4 ++-- src/Essentials/samples/Directory.Build.props | 3 ++- .../TestUtils.DeviceTests.Runners.csproj | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj index 4fe496c4db99..edd776ae4569 100644 --- a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj +++ b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj @@ -3,6 +3,9 @@ netstandard2.0 Microsoft.Maui.Controls.Compatibility.ControlGallery Microsoft.Maui.Controls.Compatibility.ControlGallery + 4 + 0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429;0618;0612 + $(WarningsNotAsErrors);XC10101;XC10102 True @@ -10,14 +13,10 @@ TRACE;DEBUG;PERF;APP prompt - 4 - 0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429;0618;0612 TRACE;APP prompt - 4 - 0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429;0618;0612 $(DefineConstants);WINDOWS diff --git a/src/Controls/samples/Directory.Build.props b/src/Controls/samples/Directory.Build.props index 70564c58672c..241a359433ad 100644 --- a/src/Controls/samples/Directory.Build.props +++ b/src/Controls/samples/Directory.Build.props @@ -2,6 +2,7 @@ true true + $(WarningsNotAsErrors);XC10101;XC10102 - \ No newline at end of file + diff --git a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs index 0db5f2c6a11a..f70f7e42f694 100644 --- a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs +++ b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs @@ -397,7 +397,10 @@ static IEnumerable CompileBindingPath(ElementNode node, ILContext c if (dataTypeNode is ElementNode enode && enode.XmlType.NamespaceUri == XamlParser.X2009Uri && enode.XmlType.Name == nameof(Microsoft.Maui.Controls.Xaml.NullExtension)) + { + context.LoggingHelper.LogWarningOrError(10102, context.XamlFilePath, node.LineNumber, node.LinePosition, 0, 0, $"Binding could be compiled if x:DataType is not explicitly null", null); yield break; + } string dataType = null; diff --git a/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj b/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj index c28d6b2ff0ff..d958099c7f7c 100644 --- a/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj +++ b/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj @@ -5,8 +5,8 @@ Microsoft.Maui.Controls.Xaml.UnitTests Microsoft.Maui.Controls.Xaml.UnitTests 4 - 0672;0219;0414;CS0436;CS0618 - XC0618;XC10101 + $(NoWarn);0672;0219;0414;CS0436;CS0618 + $(WarningsNotAsErrors);XC0618;XC10101;XC10102 false true diff --git a/src/Essentials/samples/Directory.Build.props b/src/Essentials/samples/Directory.Build.props index 70564c58672c..241a359433ad 100644 --- a/src/Essentials/samples/Directory.Build.props +++ b/src/Essentials/samples/Directory.Build.props @@ -2,6 +2,7 @@ true true + $(WarningsNotAsErrors);XC10101;XC10102 - \ No newline at end of file + diff --git a/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj b/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj index 546b378eff74..ffdcea8bc68c 100644 --- a/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj +++ b/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj @@ -7,7 +7,7 @@ Microsoft.Maui.TestUtils.DeviceTests.Runners $(NoWarn);CA1416 - XC10101 + $(WarningsNotAsErrors);XC10101;XC10102