From 90396b0ffdecf65b8e2eea8eb4f148bdea1071c4 Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Mon, 15 Aug 2016 22:07:35 +0200 Subject: [PATCH] Refix mc ignorable (#302) * Revert "Fix mc ignorable (#298)" This reverts commit 31c2be29d5982338ae178d1b0f107e23e7749782. * [Xaml] fix mc:Ignorable --- .../CreateObjectVisitor.cs | 17 ---- Xamarin.Forms.Build.Tasks/ILRootNode.cs | 3 +- .../SetNamescopesAndRegisterNamesVisitor.cs | 3 - .../SetPropertiesVisitor.cs | 9 -- .../SetResourcesVisitor.cs | 6 -- Xamarin.Forms.Build.Tasks/XamlCTask.cs | 3 +- Xamarin.Forms.Xaml.UnitTests/McIgnorable.xaml | 1 + Xamarin.Forms.Xaml/ApplyPropertiesVisitor.cs | 13 +-- Xamarin.Forms.Xaml/CreateValuesVisitor.cs | 17 ---- .../FillResourceDictionariesVisitor.cs | 8 +- .../PruneIgnoredNodesVisitor.cs | 85 +++++++++++++++++++ Xamarin.Forms.Xaml/Xamarin.Forms.Xaml.csproj | 1 + Xamarin.Forms.Xaml/XamlLoader.cs | 1 + 13 files changed, 95 insertions(+), 72 deletions(-) create mode 100644 Xamarin.Forms.Xaml/PruneIgnoredNodesVisitor.cs diff --git a/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs b/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs index e6453575e..449b887fd 100644 --- a/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs +++ b/Xamarin.Forms.Build.Tasks/CreateObjectVisitor.cs @@ -39,17 +39,6 @@ namespace Xamarin.Forms.Build.Tasks public void Visit(ValueNode node, INode parentNode) { Context.Values[node] = node.Value; - - XmlName propertyName; - if (SetPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName)) - { - if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" && - propertyName.LocalName == "Ignorable") - { - (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List())).AddRange( - (node.Value as string).Split(',')); - } - } } public void Visit(MarkupNode node, INode parentNode) @@ -59,12 +48,6 @@ namespace Xamarin.Forms.Build.Tasks public void Visit(ElementNode node, INode parentNode) { - if (node.SkipPrefix((node.NamespaceResolver ?? parentNode.NamespaceResolver).LookupPrefix(node.NamespaceURI))) { - node.Properties.Clear(); - node.CollectionItems.Clear(); - return; - } - var typeref = node.XmlType.GetTypeReference(Module, node); TypeDefinition typedef = typeref.Resolve(); diff --git a/Xamarin.Forms.Build.Tasks/ILRootNode.cs b/Xamarin.Forms.Build.Tasks/ILRootNode.cs index 1c59cd3cd..77e1e8ca8 100644 --- a/Xamarin.Forms.Build.Tasks/ILRootNode.cs +++ b/Xamarin.Forms.Build.Tasks/ILRootNode.cs @@ -1,3 +1,4 @@ +using System.Xml; using Mono.Cecil; using Xamarin.Forms.Xaml; @@ -5,7 +6,7 @@ namespace Xamarin.Forms.Build.Tasks { class ILRootNode : RootNode { - public ILRootNode(XmlType xmlType, TypeReference typeReference) : base(xmlType, null) + public ILRootNode(XmlType xmlType, TypeReference typeReference, IXmlNamespaceResolver nsResolver) : base(xmlType, nsResolver) { TypeReference = typeReference; } diff --git a/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs index 477328e2a..8e03b925e 100644 --- a/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs +++ b/Xamarin.Forms.Build.Tasks/SetNamescopesAndRegisterNamesVisitor.cs @@ -43,9 +43,6 @@ namespace Xamarin.Forms.Build.Tasks public void Visit(ElementNode node, INode parentNode) { - if (node.SkipPrefix((node.NamespaceResolver ?? parentNode.NamespaceResolver).LookupPrefix(node.NamespaceURI))) - return; - VariableDefinition ns; if (parentNode == null || IsDataTemplate(node, parentNode) || IsStyle(node, parentNode)) ns = CreateNamescope(); diff --git a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs index a1c0711a2..b6bdf40b7 100644 --- a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs +++ b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs @@ -67,15 +67,9 @@ namespace Xamarin.Forms.Build.Tasks if (skips.Contains(propertyName)) return; - if (node.SkipPrefix((node.NamespaceResolver ?? parentNode.NamespaceResolver)?.LookupPrefix(propertyName.NamespaceURI))) - return; if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" && propertyName.LocalName == "Ignorable") - { - (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List())).AddRange( - (node.Value as string).Split(',')); return; - } SetPropertyValue(Context.Variables[(IElementNode)parentNode], propertyName, node, Context, node); } @@ -85,9 +79,6 @@ namespace Xamarin.Forms.Build.Tasks public void Visit(ElementNode node, INode parentNode) { - if (node.SkipPrefix((node.NamespaceResolver ?? parentNode.NamespaceResolver)?.LookupPrefix(node.NamespaceURI))) - return; - //if this node is an IMarkupExtension, invoke ProvideValue() and replace the variable var vardef = Context.Variables[node]; var vardefref = new VariableDefinitionReference(vardef); diff --git a/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs index 2bf19c268..25efa439b 100644 --- a/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs +++ b/Xamarin.Forms.Build.Tasks/SetResourcesVisitor.cs @@ -52,15 +52,9 @@ namespace Xamarin.Forms.Build.Tasks return; } - if (node.SkipPrefix((node.NamespaceResolver ?? parentNode.NamespaceResolver)?.LookupPrefix(propertyName.NamespaceURI))) - return; if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" && propertyName.LocalName == "Ignorable") - { - (parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List())).AddRange( - (node.Value as string).Split(',')); return; - } if (propertyName.LocalName != "MergedWith") return; SetPropertiesVisitor.SetPropertyValue(Context.Variables[(IElementNode)parentNode], propertyName, node, Context, node); diff --git a/Xamarin.Forms.Build.Tasks/XamlCTask.cs b/Xamarin.Forms.Build.Tasks/XamlCTask.cs index ae2a66d07..b119b4e99 100644 --- a/Xamarin.Forms.Build.Tasks/XamlCTask.cs +++ b/Xamarin.Forms.Build.Tasks/XamlCTask.cs @@ -300,6 +300,7 @@ namespace Xamarin.Forms.Build.Tasks rootnode.Accept(new XamlNodeVisitor((node, parent) => node.Parent = parent), null); rootnode.Accept(new ExpandMarkupsVisitor(visitorContext), null); + rootnode.Accept(new PruneIgnoredNodesVisitor(), null); rootnode.Accept(new CreateObjectVisitor(visitorContext), null); rootnode.Accept(new SetNamescopesAndRegisterNamesVisitor(visitorContext), null); rootnode.Accept(new SetFieldVisitor(visitorContext), null); @@ -427,7 +428,7 @@ namespace Xamarin.Forms.Build.Tasks } XamlParser.ParseXaml( - rootnode = new ILRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), typeReference), reader); + rootnode = new ILRootNode(new XmlType(reader.NamespaceURI, reader.Name, null), typeReference, reader as IXmlNamespaceResolver), reader); break; } } diff --git a/Xamarin.Forms.Xaml.UnitTests/McIgnorable.xaml b/Xamarin.Forms.Xaml.UnitTests/McIgnorable.xaml index 1a196d7c5..2dfe1aa1b 100644 --- a/Xamarin.Forms.Xaml.UnitTests/McIgnorable.xaml +++ b/Xamarin.Forms.Xaml.UnitTests/McIgnorable.xaml @@ -12,6 +12,7 @@ +