diff options
author | Stephane Delcroix <stephane@delcroix.org> | 2017-04-20 21:06:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-20 21:06:00 +0200 |
commit | 8e567b9ad1669265d994c84acd5c49d43829a3da (patch) | |
tree | 05d761b74c86b85feed8ebfe649626b55c04341a | |
parent | abdad979ce9de6f4d5f43774886f61f5e9e9e95f (diff) | |
download | xamarin-forms-8e567b9ad1669265d994c84acd5c49d43829a3da.tar.gz xamarin-forms-8e567b9ad1669265d994c84acd5c49d43829a3da.tar.bz2 xamarin-forms-8e567b9ad1669265d994c84acd5c49d43829a3da.zip |
[XamlC] support nested types type declarations (#872)
-rw-r--r-- | Xamarin.Forms.Build.Tasks/XmlTypeExtensions.cs | 4 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/XStatic.xaml | 2 | ||||
-rw-r--r-- | Xamarin.Forms.Xaml.UnitTests/XStatic.xaml.cs | 13 |
3 files changed, 17 insertions, 2 deletions
diff --git a/Xamarin.Forms.Build.Tasks/XmlTypeExtensions.cs b/Xamarin.Forms.Build.Tasks/XmlTypeExtensions.cs index 893108e1..9ff32eb7 100644 --- a/Xamarin.Forms.Build.Tasks/XmlTypeExtensions.cs +++ b/Xamarin.Forms.Build.Tasks/XmlTypeExtensions.cs @@ -108,7 +108,7 @@ namespace Xamarin.Forms.Build.Tasks break; var clrNamespace = asm.ClrNamespace; - var typeName = name; + var typeName = name.Replace('+', '/'); //Nested types var idx = typeName.LastIndexOf('.'); if (idx >= 0) { clrNamespace += '.' + typeName.Substring(0, typeName.LastIndexOf('.')); @@ -118,7 +118,7 @@ namespace Xamarin.Forms.Build.Tasks module.Assembly : module.AssemblyResolver.Resolve(AssemblyNameReference.Parse(asm.AssemblyName)); - type = assemblydefinition.MainModule.GetType(clrNamespace, typeName); + type = assemblydefinition.MainModule.GetType(clrNamespace + "." + typeName); if (type == null) { var exportedtype = diff --git a/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml b/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml index 2627ae39..35f0f04d 100644 --- a/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml +++ b/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml @@ -24,5 +24,7 @@ Orientation="{x:Static ScrollOrientation.Both}"/> <Label x:Name="field2" Text="{x:Static local:MockxStatic.MockFieldRef}" /> + <Label x:Name="nestedField" + Text="{x:Static local:MockxStatic+Nested.Foo}" /> </StackLayout> </ContentPage>
\ No newline at end of file diff --git a/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml.cs index 63854e1c..a545b4a5 100644 --- a/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml.cs +++ b/Xamarin.Forms.Xaml.UnitTests/XStatic.xaml.cs @@ -17,6 +17,10 @@ namespace Xamarin.Forms.Xaml.UnitTests public static string MockFieldRef = Icons.CLOSE; public string InstanceProperty { get { return "InstanceProperty"; } } public static readonly Color BackgroundColor = Color.Fuchsia; + + public class Nested { + public static string Foo = "FOO"; + } } public enum MockEnum : long @@ -135,6 +139,15 @@ namespace Xamarin.Forms.Xaml.UnitTests var layout = new XStatic(useCompiledXaml); Assert.AreEqual("ic_close.png", layout.ToolbarItems[0].Icon.File); } + + [TestCase(false)] + [TestCase(true)] + // https://bugzilla.xamarin.com/show_bug.cgi?id=55096 + public void xStaticAndNestedClasses(bool useCompiledXaml) + { + var layout = new XStatic(useCompiledXaml); + Assert.AreEqual(MockxStatic.Nested.Foo, layout.nestedField.Text); + } } } }
\ No newline at end of file |