зеркало из https://github.com/DeGsoft/maui-linux.git
Refix mc ignorable (#302)
* Revert "Fix mc ignorable (#298)"
This reverts commit 31c2be29d5
.
* [Xaml] fix mc:Ignorable
This commit is contained in:
Родитель
775df09a3e
Коммит
90396b0ffd
|
@ -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<string>())).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();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<string>())).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);
|
||||
|
|
|
@ -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<string>())).AddRange(
|
||||
(node.Value as string).Split(','));
|
||||
return;
|
||||
}
|
||||
if (propertyName.LocalName != "MergedWith")
|
||||
return;
|
||||
SetPropertiesVisitor.SetPropertyValue(Context.Variables[(IElementNode)parentNode], propertyName, node, Context, node);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
</ContentPage.BindingContext>
|
||||
<StackLayout x:Name="stack">
|
||||
<d:FakeControlWithContent>
|
||||
<d:Invalid />
|
||||
<Button />
|
||||
</d:FakeControlWithContent>
|
||||
</StackLayout>
|
||||
|
|
|
@ -9,7 +9,7 @@ using Xamarin.Forms.Xaml.Internals;
|
|||
|
||||
namespace Xamarin.Forms.Xaml
|
||||
{
|
||||
class ApplyPropertiesVisitor : IXamlNodeVisitor
|
||||
internal class ApplyPropertiesVisitor : IXamlNodeVisitor
|
||||
{
|
||||
public static readonly IList<XmlName> Skips = new List<XmlName>
|
||||
{
|
||||
|
@ -58,15 +58,9 @@ namespace Xamarin.Forms.Xaml
|
|||
return;
|
||||
if (parentElement.SkipProperties.Contains(propertyName))
|
||||
return;
|
||||
if (parentElement.SkipPrefix(node.NamespaceResolver.LookupPrefix(propertyName.NamespaceURI)))
|
||||
return;
|
||||
if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" &&
|
||||
propertyName.LocalName == "Ignorable")
|
||||
{
|
||||
(parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(
|
||||
(value as string).Split(','));
|
||||
propertyName.LocalName == "Ignorable")
|
||||
return;
|
||||
}
|
||||
SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
|
||||
}
|
||||
else if (IsCollectionItem(node, parentNode) && parentNode is IElementNode)
|
||||
|
@ -91,9 +85,6 @@ namespace Xamarin.Forms.Xaml
|
|||
|
||||
public void Visit(ElementNode node, INode parentNode)
|
||||
{
|
||||
if (node.SkipPrefix(node.NamespaceResolver.LookupPrefix(node.NamespaceURI)))
|
||||
return;
|
||||
|
||||
var value = Values[node];
|
||||
var parentElement = parentNode as IElementNode;
|
||||
var markupExtension = value as IMarkupExtension;
|
||||
|
|
|
@ -41,17 +41,6 @@ namespace Xamarin.Forms.Xaml
|
|||
public void Visit(ValueNode node, INode parentNode)
|
||||
{
|
||||
Values[node] = node.Value;
|
||||
|
||||
XmlName propertyName;
|
||||
if (ApplyPropertiesVisitor.TryGetPropertyName(node, parentNode, out propertyName))
|
||||
{
|
||||
if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" &&
|
||||
propertyName.LocalName == "Ignorable")
|
||||
{
|
||||
(parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(
|
||||
(node.Value as string).Split(','));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Visit(MarkupNode node, INode parentNode)
|
||||
|
@ -62,12 +51,6 @@ namespace Xamarin.Forms.Xaml
|
|||
{
|
||||
object value = null;
|
||||
|
||||
if (node.SkipPrefix(node.NamespaceResolver.LookupPrefix(node.NamespaceURI))) {
|
||||
node.Properties.Clear();
|
||||
node.CollectionItems.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
XamlParseException xpe;
|
||||
var type = XamlParser.GetElementType(node.XmlType, node, Context.RootElement?.GetType().GetTypeInfo().Assembly,
|
||||
out xpe);
|
||||
|
|
|
@ -48,11 +48,8 @@ namespace Xamarin.Forms.Xaml
|
|||
if (parentElement.SkipPrefix(node.NamespaceResolver.LookupPrefix(propertyName.NamespaceURI)))
|
||||
return;
|
||||
if (propertyName.NamespaceURI == "http://schemas.openxmlformats.org/markup-compatibility/2006" &&
|
||||
propertyName.LocalName == "Ignorable") {
|
||||
(parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string> ())).AddRange (
|
||||
(value as string).Split (','));
|
||||
propertyName.LocalName == "Ignorable")
|
||||
return;
|
||||
}
|
||||
if (propertyName.LocalName != "MergedWith")
|
||||
return;
|
||||
ApplyPropertiesVisitor.SetPropertyValue(source, propertyName, value, Context.RootElement, node, Context, node);
|
||||
|
@ -66,9 +63,6 @@ namespace Xamarin.Forms.Xaml
|
|||
|
||||
public void Visit(ElementNode node, INode parentNode)
|
||||
{
|
||||
if (node.SkipPrefix(node.NamespaceResolver.LookupPrefix(node.NamespaceURI)))
|
||||
return;
|
||||
|
||||
var value = Values[node];
|
||||
var parentElement = parentNode as IElementNode;
|
||||
var markupExtension = value as IMarkupExtension;
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Xamarin.Forms.Xaml
|
||||
{
|
||||
class PruneIgnoredNodesVisitor : IXamlNodeVisitor
|
||||
{
|
||||
public bool StopOnDataTemplate {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool StopOnResourceDictionary {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public bool VisitChildrenFirst {
|
||||
get { return false; }
|
||||
}
|
||||
|
||||
public void Visit(ElementNode node, INode parentNode)
|
||||
{
|
||||
foreach (var propertyKvp in node.Properties)
|
||||
{
|
||||
var propertyName = propertyKvp.Key;
|
||||
var propertyValue = (propertyKvp.Value as ValueNode)?.Value as string;
|
||||
if (propertyValue == null)
|
||||
continue;
|
||||
if (propertyName.NamespaceURI != "http://schemas.openxmlformats.org/markup-compatibility/2006" ||
|
||||
propertyName.LocalName != "Ignorable")
|
||||
continue;
|
||||
(parentNode.IgnorablePrefixes ?? (parentNode.IgnorablePrefixes = new List<string>())).AddRange(propertyValue.Split(','));
|
||||
}
|
||||
|
||||
foreach (var propertyKvp in node.Properties.ToList())
|
||||
{
|
||||
// skip d:foo="bar"
|
||||
var prefix = node.NamespaceResolver.LookupPrefix(propertyKvp.Key.NamespaceURI);
|
||||
if (node.SkipPrefix(prefix))
|
||||
node.Properties.Remove(propertyKvp.Key);
|
||||
var propNs = (propertyKvp.Value as IElementNode)?.NamespaceURI ?? "";
|
||||
var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
|
||||
if (node.SkipPrefix(propPrefix))
|
||||
node.Properties.Remove(propertyKvp.Key);
|
||||
}
|
||||
|
||||
foreach (var prop in node.CollectionItems.ToList())
|
||||
{
|
||||
var propNs = (prop as IElementNode)?.NamespaceURI ?? "";
|
||||
var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
|
||||
if (node.SkipPrefix(propPrefix))
|
||||
node.CollectionItems.Remove(prop);
|
||||
}
|
||||
|
||||
if (node.SkipPrefix(node.NamespaceResolver.LookupPrefix(node.NamespaceURI)))
|
||||
{
|
||||
node.Properties.Clear();
|
||||
node.CollectionItems.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void Visit(RootNode node, INode parentNode)
|
||||
{
|
||||
Visit((ElementNode)node, node);
|
||||
}
|
||||
|
||||
public void Visit(MarkupNode node, INode parentNode)
|
||||
{
|
||||
}
|
||||
|
||||
public void Visit(ListNode node, INode parentNode)
|
||||
{
|
||||
foreach (var prop in node.CollectionItems.ToList())
|
||||
{
|
||||
var propNs = (prop as IElementNode)?.NamespaceURI ?? "";
|
||||
var propPrefix = node.NamespaceResolver.LookupPrefix(propNs);
|
||||
if (node.SkipPrefix(propPrefix))
|
||||
node.CollectionItems.Remove(prop);
|
||||
}
|
||||
}
|
||||
|
||||
public void Visit(ValueNode node, INode parentNode)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -81,6 +81,7 @@
|
|||
<Compile Include="ExpandMarkupsVisitor.cs" />
|
||||
<Compile Include="XamlCompilationAttribute.cs" />
|
||||
<Compile Include="TypeArgumentsParser.cs" />
|
||||
<Compile Include="PruneIgnoredNodesVisitor.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
|
|
@ -117,6 +117,7 @@ namespace Xamarin.Forms.Xaml
|
|||
{
|
||||
rootnode.Accept (new XamlNodeVisitor ((node, parent) => node.Parent = parent), null); //set parents for {StaticResource}
|
||||
rootnode.Accept (new ExpandMarkupsVisitor (visitorContext), null);
|
||||
rootnode.Accept (new PruneIgnoredNodesVisitor(), null);
|
||||
rootnode.Accept (new NamescopingVisitor (visitorContext), null); //set namescopes for {x:Reference}
|
||||
rootnode.Accept (new CreateValuesVisitor (visitorContext), null);
|
||||
rootnode.Accept (new RegisterXNamesVisitor (visitorContext), null);
|
||||
|
|
Загрузка…
Ссылка в новой задаче