diff --git a/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj b/src/Compatibility/ControlGallery/src/Core/Compatibility.ControlGallery.Core.csproj
index 4fe496c4db99..87b252ddbbd3 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);XC0022;XC0023
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..5fadd0e2e51e 100644
--- a/src/Controls/samples/Directory.Build.props
+++ b/src/Controls/samples/Directory.Build.props
@@ -2,6 +2,7 @@
true
true
+ $(WarningsNotAsErrors);XC0022;XC0023
-
\ No newline at end of file
+
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 static string XStaticSyntax {
}
///
- /// 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 6c6dd066258a..28e69c311ab1 100644
--- a/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs
+++ b/src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs
@@ -389,13 +389,19 @@ static IEnumerable CompileBindingPath(ElementNode node, ILContext c
n = n.Parent as IElementNode;
}
- if (dataTypeNode is null)
+ if (dataTypeNode is null) {
+ context.LoggingHelper.LogWarningOrError(BuildExceptionCode.BindingWithoutDataType, context.XamlFilePath, node.LineNumber, node.LinePosition, 0, 0, null);
+
yield break;
+ }
if (dataTypeNode is ElementNode enode
&& enode.XmlType.NamespaceUri == XamlParser.X2009Uri
&& enode.XmlType.Name == nameof(Microsoft.Maui.Controls.Xaml.NullExtension))
+ {
+ context.LoggingHelper.LogWarningOrError(BuildExceptionCode.BindingWithNullDataType, context.XamlFilePath, node.LineNumber, node.LinePosition, 0, 0, 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 cc244dbf002b..e988431827da 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
+ $(NoWarn);0672;0219;0414;CS0436;CS0618
+ $(WarningsNotAsErrors);XC0618;XC0022;XC0023
false
true
diff --git a/src/Essentials/samples/Directory.Build.props b/src/Essentials/samples/Directory.Build.props
index 70564c58672c..5fadd0e2e51e 100644
--- a/src/Essentials/samples/Directory.Build.props
+++ b/src/Essentials/samples/Directory.Build.props
@@ -2,6 +2,7 @@
true
true
+ $(WarningsNotAsErrors);XC0022;XC0023
-
\ 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 e20ff19881d1..cdc562972f47 100644
--- a/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj
+++ b/src/TestUtils/src/DeviceTests.Runners/TestUtils.DeviceTests.Runners.csproj
@@ -6,7 +6,8 @@
Microsoft.Maui.TestUtils.DeviceTests.Runners
Microsoft.Maui.TestUtils.DeviceTests.Runners
- $(NoWarn),CA1416
+ $(NoWarn);CA1416
+ $(WarningsNotAsErrors);XC0022;XC0023