[Xaml] expose XmlnsPrefixAttribute (#4562)
authorStephane Delcroix <stephane@delcroix.org>
Tue, 4 Dec 2018 18:36:29 +0000 (19:36 +0100)
committerE.Z. Hart <hartez@users.noreply.github.com>
Tue, 4 Dec 2018 18:36:29 +0000 (11:36 -0700)
Expose the XmlnsPrefixAttribute, that can be used by external tools to
support object tree serialixation to Xaml.

- fixes #3191

Xamarin.Forms.Core/Properties/AssemblyInfo.cs
Xamarin.Forms.Core/XmlnsDefinitionAttribute.cs
Xamarin.Forms.Core/XmlnsPrefixAttribute.cs [new file with mode: 0644]

index 1e9972e..85605f5 100644 (file)
@@ -38,6 +38,7 @@ using Xamarin.Forms.StyleSheets;
 [assembly: Preserve]
 
 [assembly: XmlnsDefinition("http://xamarin.com/schemas/2014/forms", "Xamarin.Forms")]
+[assembly: XmlnsPrefix("http://xamarin.com/schemas/2014/forms", "xf")]
 
 [assembly: StyleProperty("background-color", typeof(VisualElement), nameof(VisualElement.BackgroundColorProperty))]
 [assembly: StyleProperty("background-image", typeof(Page), nameof(Page.BackgroundImageProperty))]
index a524b19..295e906 100644 (file)
@@ -1,7 +1,6 @@
 using System;
 using System.Diagnostics;
 
-
 namespace Xamarin.Forms
 {
        [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
@@ -30,4 +29,4 @@ namespace Xamarin.Forms
                        XmlNamespace = xmlNamespace;
                }
        }
-}
\ No newline at end of file
+}
diff --git a/Xamarin.Forms.Core/XmlnsPrefixAttribute.cs b/Xamarin.Forms.Core/XmlnsPrefixAttribute.cs
new file mode 100644 (file)
index 0000000..b0d973e
--- /dev/null
@@ -0,0 +1,17 @@
+using System;
+
+namespace Xamarin.Forms
+{
+       [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
+       public sealed class XmlnsPrefixAttribute : Attribute
+       {
+               public XmlnsPrefixAttribute(string xmlNamespace, string prefix)
+               {
+                       XmlNamespace = xmlNamespace ?? throw new ArgumentNullException(nameof(xmlNamespace));
+                       Prefix = prefix ?? throw new ArgumentNullException(nameof(prefix));
+               }
+
+               public string XmlNamespace { get; }
+               public string Prefix { get; }
+       }
+}
\ No newline at end of file