Skip to content

Commit

Permalink
allow localization
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneDelcroix committed Dec 19, 2023
1 parent 5bdeb23 commit e702845
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<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>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0022;XC0023</WarningsNotAsErrors>
</PropertyGroup>
<PropertyGroup>
<XFDisableTargetsValidation>True</XFDisableTargetsValidation>
Expand Down
2 changes: 1 addition & 1 deletion src/Controls/samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<SampleProject>true</SampleProject>
<UseMaui Condition=" '$(UseWorkload)' == 'true' ">true</UseMaui>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC10101;XC10102</WarningsNotAsErrors>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0022;XC0023</WarningsNotAsErrors>
</PropertyGroup>
<Import Project="../../../Directory.Build.props" />
</Project>
4 changes: 3 additions & 1 deletion src/Controls/src/Build.Tasks/BuildException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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), "");
Expand Down Expand Up @@ -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; }
Expand Down
21 changes: 20 additions & 1 deletion src/Controls/src/Build.Tasks/ErrorMessages.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Controls/src/Build.Tasks/ErrorMessages.resx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
<value>Binding: Unsupported indexer index type: "{0}".</value>
<comment>0 is indexer type name</comment>
</data>
<data name="BindingWithoutDataType" xml:space="preserve">
<value>Binding could be compiled if x:DataType is specified.</value>
</data>
<data name="BindingWithNullDataType" xml:space="preserve">
<value>Binding could be compiled if x:DataType is not explicitly null.</value>
</data>
<data name="BindingPropertyNotFound" xml:space="preserve">
<value>Binding: Property "{0}" not found on "{1}".</value>
<comment>0 is property name, 1 is type name</comment>
Expand Down
5 changes: 3 additions & 2 deletions src/Controls/src/Build.Tasks/SetPropertiesVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,16 @@ static IEnumerable<Instruction> 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;
}

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);
context.LoggingHelper.LogWarningOrError(BuildExceptionCode.BindingWithNullDataType, context.XamlFilePath, node.LineNumber, node.LinePosition, 0, 0, null);
yield break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<AssemblyName>Microsoft.Maui.Controls.Xaml.UnitTests</AssemblyName>
<WarningLevel>4</WarningLevel>
<NoWarn>$(NoWarn);0672;0219;0414;CS0436;CS0618</NoWarn>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0618;XC10101;XC10102</WarningsNotAsErrors>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0618;XC0022;XC0023</WarningsNotAsErrors>
<IsPackable>false</IsPackable>
<DisableMSBuildAssemblyCopyCheck>true</DisableMSBuildAssemblyCopyCheck>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/Essentials/samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<SampleProject>true</SampleProject>
<UseMaui Condition=" '$(UseWorkload)' == 'true' ">true</UseMaui>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC10101;XC10102</WarningsNotAsErrors>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0022;XC0023</WarningsNotAsErrors>
</PropertyGroup>
<Import Project="../../../Directory.Build.props" />
</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>$(WarningsNotAsErrors);XC10101;XC10102</WarningsNotAsErrors>
<WarningsNotAsErrors>$(WarningsNotAsErrors);XC0022;XC0023</WarningsNotAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit e702845

Please sign in to comment.