提交 8a208e86 编写于 作者: Y Youssef Victor

fix: Properly generate code for items in custom dictionary

上级 d40c59f4
......@@ -4,6 +4,7 @@
xmlns:xamarin="http://nventive.com/xamarin"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:ios="http://nventive.com/ios"
xmlns:local="using:SamplesApp"
xmlns:toolkit="using:Uno.UI.Toolkit"
mc:Ignorable="ios"
RequestedTheme="Light">
......@@ -33,6 +34,12 @@
<MapResources xmlns="using:Uno.UI.Maps"/>
</ResourceDictionary.MergedDictionaries>
<local:StringToStyleDictionary x:Key="MyResource">
<Style x:Key="MyStyle" TargetType="Button">
</Style>
</local:StringToStyleDictionary>
<SolidColorBrush x:Key="GlobalStaticResource_Test01"
Color="Purple" />
......
......@@ -27,6 +27,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Samples\UnitTests\UnitTestsPage.xaml.cs">
<DependentUpon>UnitTestsPage.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)StringToStyleDictionary.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="$(MSBuildThisFileDirectory)MainPage.xaml">
......@@ -81,4 +82,4 @@
<ItemGroup>
<Folder Include="$(MSBuildThisFileDirectory)Embedded\SubFolder1\SubFolder2\" />
</ItemGroup>
</Project>
\ No newline at end of file
</Project>
using System.Collections.Generic;
using Windows.UI.Xaml;
namespace SamplesApp;
class StringToStyleDictionary : Dictionary<string, Style>
{
}
......@@ -3313,6 +3313,11 @@ namespace Uno.UI.SourceGenerators.XamlGenerator
writer.AppendLineIndented($"{closureName}.Add(");
using (writer.Indent())
{
if (objectDefinitionType?.AllInterfaces.Any(i => i.OriginalDefinition.Equals(Generation.IDictionaryOfTKeySymbol.Value, SymbolEqualityComparer.Default)) == true &&
GetDictionaryResourceKey(item) is string dictionaryKey)
{
writer.AppendLineIndented($"\"{dictionaryKey}\",");
}
BuildChild(writer, member, item);
}
writer.AppendLineIndented(");");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册