Skip to content

Commit

Permalink
warn on datatype explicitly null
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneDelcroix committed Dec 15, 2023
1 parent 27180c4 commit 5c3394e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,20 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Microsoft.Maui.Controls.Compatibility.ControlGallery</AssemblyName>
<RootNamespace>Microsoft.Maui.Controls.Compatibility.ControlGallery</RootNamespace>
<WarningLevel>4</WarningLevel>
<NoWarn>0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429;0618;0612</NoWarn>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC10101;XC10102</WarningsNotAsErrors>
</PropertyGroup>
<PropertyGroup>
<XFDisableTargetsValidation>True</XFDisableTargetsValidation>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DefineConstants>TRACE;DEBUG;PERF;APP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429;0618;0612</NoWarn>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DefineConstants>TRACE;APP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<NoWarn>0114;0108;0109;4014;0649;0169;0472;0414;0168;0219;0429;0618;0612</NoWarn>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith('uap10.0'))">
<DefineConstants>$(DefineConstants);WINDOWS</DefineConstants>
Expand Down
3 changes: 2 additions & 1 deletion src/Controls/samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<SampleProject>true</SampleProject>
<UseMaui Condition=" '$(UseWorkload)' == 'true' ">true</UseMaui>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC10101;XC10102</WarningsNotAsErrors>
</PropertyGroup>
<Import Project="../../../Directory.Build.props" />
</Project>
</Project>
3 changes: 3 additions & 0 deletions src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,10 @@ static IEnumerable<Instruction> 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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<RootNamespace>Microsoft.Maui.Controls.Xaml.UnitTests</RootNamespace>
<AssemblyName>Microsoft.Maui.Controls.Xaml.UnitTests</AssemblyName>
<WarningLevel>4</WarningLevel>
<NoWarn>0672;0219;0414;CS0436;CS0618</NoWarn>
<WarningsNotAsErrors>XC0618;XC10101</WarningsNotAsErrors>
<NoWarn>$(NoWarn);0672;0219;0414;CS0436;CS0618</NoWarn>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0618;XC10101;XC10102</WarningsNotAsErrors>
<IsPackable>false</IsPackable>
<DisableMSBuildAssemblyCopyCheck>true</DisableMSBuildAssemblyCopyCheck>
</PropertyGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Essentials/samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<PropertyGroup>
<SampleProject>true</SampleProject>
<UseMaui Condition=" '$(UseWorkload)' == 'true' ">true</UseMaui>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC10101;XC10102</WarningsNotAsErrors>
</PropertyGroup>
<Import Project="../../../Directory.Build.props" />
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyName>Microsoft.Maui.TestUtils.DeviceTests.Runners</AssemblyName>
<!--<Nullable>enable</Nullable>-->
<NoWarn>$(NoWarn);CA1416</NoWarn>
<WarningsNotAsErrors>XC10101</WarningsNotAsErrors>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC10101;XC10102</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 5c3394e

Please sign in to comment.