diff --git a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj index edd776ae4569..87b252ddbbd3 100644 --- a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj +++ b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj @@ -5,7 +5,7 @@ Microsoft.Maui.Controls.Compatibility.ControlGallery 4 0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429;0618;0612 - $(WarningsNotAsErrors);XC10101;XC10102 + $(WarningsNotAsErrors);XC0022;XC0023 True diff --git a/src/Controls/samples/Directory.Build.props b/src/Controls/samples/Directory.Build.props index 241a359433ad..5fadd0e2e51e 100644 --- a/src/Controls/samples/Directory.Build.props +++ b/src/Controls/samples/Directory.Build.props @@ -2,7 +2,7 @@ true true - $(WarningsNotAsErrors);XC10101;XC10102 + $(WarningsNotAsErrors);XC0022;XC0023 diff --git a/src/Controls/src/Build.Tasks/BuildException.cs b/src/Controls/src/Build.Tasks/BuildException.cs index 2f29afab4697..912b9917d308 100644 --- a/src/Controls/src/Build.Tasks/BuildException.cs +++ b/src/Controls/src/Build.Tasks/BuildException.cs @@ -55,6 +55,8 @@ class BuildExceptionCode //BP,BO public static BuildExceptionCode BPName = new BuildExceptionCode("XFC", 0020, nameof(BPName), ""); public static BuildExceptionCode BPMissingGetter = new BuildExceptionCode("XFC", 0021, nameof(BPMissingGetter), ""); + public static BuildExceptionCode BindingWithoutDataType = new BuildExceptionCode("XC", 0022, nameof(BindingWithoutDataType), ""); //warning + public static BuildExceptionCode BindingWithNullDataType = new BuildExceptionCode("XC", 0023, nameof(BindingWithNullDataType), ""); //warning //Bindings, conversions public static BuildExceptionCode Conversion = new BuildExceptionCode("XFC", 0040, nameof(Conversion), ""); @@ -90,7 +92,7 @@ class BuildExceptionCode public static BuildExceptionCode XKeyNotLiteral = new BuildExceptionCode("XFC", 0127, nameof(XKeyNotLiteral), ""); //CSC equivalents - public static BuildExceptionCode ObsoleteProperty = new BuildExceptionCode("XC", 0618, nameof(ObsoleteProperty), ""); + public static BuildExceptionCode ObsoleteProperty = new BuildExceptionCode("XC", 0618, nameof(ObsoleteProperty), ""); //warning public string Code { get; } public string CodePrefix { get; } diff --git a/src/Controls/src/Build.Tasks/ErrorMessages.Designer.cs b/src/Controls/src/Build.Tasks/ErrorMessages.Designer.cs index 4e1c2883b0e0..e3316e659b3f 100644 --- a/src/Controls/src/Build.Tasks/ErrorMessages.Designer.cs +++ b/src/Controls/src/Build.Tasks/ErrorMessages.Designer.cs @@ -385,12 +385,31 @@ internal class ErrorMessages { } /// - /// Gets the error message for the obsolete property. + /// Looks up a localized message for the obsolete property. /// internal static string ObsoleteProperty { get { return ResourceManager.GetString("ObsoleteProperty", resourceCulture); } } + + /// + /// Looks up a localized message for when a binding is used without specifying a data type. + /// + internal static string BindingWithoutDataType { + get { + return ResourceManager.GetString("BindingWithoutDataType", resourceCulture); + } + } + + /// + /// Looks up a localized message for binding with null data type. + /// + /// The error message. + internal static string BindingWithNullDataType { + get { + return ResourceManager.GetString("BindingWithNullDataType", resourceCulture); + } + } } } diff --git a/src/Controls/src/Build.Tasks/ErrorMessages.resx b/src/Controls/src/Build.Tasks/ErrorMessages.resx index 45f55ba6c971..92b100af60eb 100644 --- a/src/Controls/src/Build.Tasks/ErrorMessages.resx +++ b/src/Controls/src/Build.Tasks/ErrorMessages.resx @@ -135,6 +135,12 @@ Binding: Unsupported indexer index type: "{0}". 0 is indexer type name + + Binding could be compiled if x:DataType is specified. + + + Binding could be compiled if x:DataType is not explicitly null. + Binding: Property "{0}" not found on "{1}". 0 is property name, 1 is type name diff --git a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs index c9da20239abf..28e69c311ab1 100644 --- a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs +++ b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs @@ -390,7 +390,8 @@ static IEnumerable CompileBindingPath(ElementNode node, ILContext c } if (dataTypeNode is null) { - context.LoggingHelper.LogWarningOrError(10101, context.XamlFilePath, node.LineNumber, node.LinePosition, 0, 0, $"Binding could be compiled if x:DataType is specified", null); + context.LoggingHelper.LogWarningOrError(BuildExceptionCode.BindingWithoutDataType, context.XamlFilePath, node.LineNumber, node.LinePosition, 0, 0, null); + yield break; } @@ -398,7 +399,7 @@ static IEnumerable CompileBindingPath(ElementNode node, ILContext c && 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); + context.LoggingHelper.LogWarningOrError(BuildExceptionCode.BindingWithNullDataType, context.XamlFilePath, node.LineNumber, node.LinePosition, 0, 0, null); yield break; } diff --git a/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj b/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj index d958099c7f7c..e988431827da 100644 --- a/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj +++ b/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj @@ -6,7 +6,7 @@ Microsoft.Maui.Controls.Xaml.UnitTests 4 $(NoWarn);0672;0219;0414;CS0436;CS0618 - $(WarningsNotAsErrors);XC0618;XC10101;XC10102 + $(WarningsNotAsErrors);XC0618;XC0022;XC0023 false true diff --git a/src/Essentials/samples/Directory.Build.props b/src/Essentials/samples/Directory.Build.props index 241a359433ad..5fadd0e2e51e 100644 --- a/src/Essentials/samples/Directory.Build.props +++ b/src/Essentials/samples/Directory.Build.props @@ -2,7 +2,7 @@ true true - $(WarningsNotAsErrors);XC10101;XC10102 + $(WarningsNotAsErrors);XC0022;XC0023 diff --git a/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj b/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj index ffdcea8bc68c..cdc562972f47 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 - $(WarningsNotAsErrors);XC10101;XC10102 + $(WarningsNotAsErrors);XC0022;XC0023