diff --git a/ILSpy.BamlDecompiler/CecilTypeResolver.cs b/ILSpy.BamlDecompiler/CecilTypeResolver.cs
index 702c37c38..bc42696ea 100644
--- a/ILSpy.BamlDecompiler/CecilTypeResolver.cs
+++ b/ILSpy.BamlDecompiler/CecilTypeResolver.cs
@@ -25,7 +25,16 @@ namespace ILSpy.BamlDecompiler
public bool IsLocalAssembly(string name)
{
- return name == this.thisAssembly.Name.Name;
+ return MakeShort(name) == this.thisAssembly.Name.Name;
+ }
+
+ string MakeShort(string name)
+ {
+ int endOffset = name.IndexOf(',');
+ if (endOffset == -1)
+ return name;
+
+ return name.Substring(0, endOffset);
}
public IType GetTypeByAssemblyQualifiedName(string name)
diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlProperty.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlProperty.cs
index 2da34dd90..9207f936f 100644
--- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlProperty.cs
+++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlProperty.cs
@@ -10,18 +10,18 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
{
internal class XmlBamlProperty : XmlBamlNode
{
- private PropertyDeclaration propertyDeclaration;
- private PropertyType propertyType;
- private object value;
+ PropertyType propertyType;
- public XmlBamlProperty(PropertyType propertyType)
+ public XmlBamlProperty(XmlBamlElement parent, PropertyType propertyType)
{
+ this.Parent = parent;
this.propertyType = propertyType;
}
- public XmlBamlProperty(PropertyType propertyType, PropertyDeclaration propertyDeclaration)
+ public XmlBamlProperty(XmlBamlElement parent, PropertyType propertyType, PropertyDeclaration propertyDeclaration)
{
- this.propertyDeclaration = propertyDeclaration;
+ this.Parent = parent;
+ this.PropertyDeclaration = propertyDeclaration;
this.propertyType = propertyType;
}
@@ -29,45 +29,19 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
{
return this.PropertyDeclaration.Name;
}
+
+ public XmlBamlElement Parent { get; set; }
+
+ public PropertyDeclaration PropertyDeclaration { get; set; }
- public PropertyDeclaration PropertyDeclaration
- {
- get
- {
- return this.propertyDeclaration;
- }
- set
- {
- this.propertyDeclaration = value;
- }
+ public PropertyType PropertyType {
+ get { return this.propertyType; }
}
- public PropertyType PropertyType
- {
- get
- {
- return this.propertyType;
- }
- }
+ public object Value { get; set; }
- public object Value
- {
- get
- {
- return this.value;
- }
- set
- {
- this.value = value;
- }
- }
-
- public override XmlNodeType NodeType
- {
- get
- {
- return XmlNodeType.Attribute;
- }
+ public override XmlNodeType NodeType {
+ get { return XmlNodeType.Attribute; }
}
}
diff --git a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs
index 94ede5552..00c51225e 100644
--- a/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs
+++ b/ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs
@@ -777,7 +777,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
return;
}
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Value, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Value, pd);
property.Value = value;
nodes.Enqueue(property);
@@ -907,7 +907,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
throw new NotSupportedException("Unknown property with extension");
}
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Value, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Value, pd);
property.Value = value;
nodes.Enqueue(property);
@@ -919,7 +919,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
string text = reader.ReadString();
PropertyDeclaration pd = this.GetPropertyDeclaration(identifier);
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Value, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Value, pd);
property.Value = text;
nodes.Enqueue(property);
@@ -932,7 +932,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
reader.ReadInt16();
PropertyDeclaration pd = this.GetPropertyDeclaration(identifier);
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Value, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Value, pd);
property.Value = text;
nodes.Enqueue(property);
@@ -945,8 +945,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
reader.ReadByte();
string name = reader.ReadString();
TypeDeclaration declaringType = this.GetTypeDeclaration(identifier);
- PropertyDeclaration declaration2 = new PropertyDeclaration(name, declaringType);
- this.propertyTable.Add(key, declaration2);
+ PropertyDeclaration property = new PropertyDeclaration(name, declaringType);
+ this.propertyTable.Add(key, property);
}
void ReadDefAttributeKeyType()
@@ -985,7 +985,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
break;
}
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Key, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Key, pd);
property.Value = text;
nodes.Enqueue(property);
@@ -1250,7 +1250,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
void AddKeyToElement(string key)
{
PropertyDeclaration pd = new PropertyDeclaration("Key", XamlTypeDeclaration);
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Key, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Key, pd);
property.Value = key;
@@ -1393,7 +1393,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
PropertyDeclaration pd = new PropertyDeclaration(this.stringTable[valueIdentifier].ToString());
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Value, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Value, pd);
property.Value = text;
}
@@ -1405,7 +1405,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
PropertyDeclaration pd = this.GetPropertyDeclaration(identifier);
string value = this.GetTypeExtension(typeIdentifier);
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Value, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Value, pd);
property.Value = value;
nodes.Enqueue(property);
@@ -1524,7 +1524,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
string prefix = this.LookupPrefix(XmlPIMapping.PresentationNamespace, false);
string value = String.Format("{{{0}{1}StaticResource {2}}}", prefix, (String.IsNullOrEmpty(prefix)) ? String.Empty : ":", staticResource);
- XmlBamlProperty property = new XmlBamlProperty(PropertyType.Value, pd);
+ XmlBamlProperty property = new XmlBamlProperty(elements.Peek(), PropertyType.Value, pd);
property.Value = value;
nodes.Enqueue(property);
@@ -1637,13 +1637,17 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
XmlBamlNode node = this.CurrentNode;
if (node is XmlBamlSimpleProperty)
return ((XmlBamlSimpleProperty)node).NamespaceName;
- else if (node is XmlBamlProperty)
- {
+ else if (node is XmlBamlProperty) {
declaration = ((XmlBamlProperty)node).PropertyDeclaration.DeclaringType;
TypeDeclaration elementDeclaration = this.readingElements.Peek().TypeDeclaration;
XmlPIMapping propertyMapping = FindByClrNamespaceAndAssemblyId(declaration) ?? XmlPIMapping.Presentation;
XmlPIMapping elementMapping = FindByClrNamespaceAndAssemblyId(elementDeclaration) ?? XmlPIMapping.Presentation;
+
+ if (((XmlBamlProperty)node).PropertyDeclaration.Name == "Name" &&
+ _resolver.IsLocalAssembly(((XmlBamlProperty)node).Parent.TypeDeclaration.Assembly))
+ return XWPFNamespace;
+
if (String.CompareOrdinal(propertyMapping.XmlNamespace, elementMapping.XmlNamespace) == 0
|| (elementDeclaration.Type != null && declaration.Type != null && elementDeclaration.Type.IsSubclassOf(declaration.Type)))
return String.Empty;
diff --git a/ILSpy.BamlDecompiler/Tests/Cases/MyControl.xaml b/ILSpy.BamlDecompiler/Tests/Cases/MyControl.xaml
new file mode 100644
index 000000000..4e8c218e0
--- /dev/null
+++ b/ILSpy.BamlDecompiler/Tests/Cases/MyControl.xaml
@@ -0,0 +1,7 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/ILSpy.BamlDecompiler/Tests/Cases/MyControl.xaml.cs b/ILSpy.BamlDecompiler/Tests/Cases/MyControl.xaml.cs
new file mode 100644
index 000000000..6a0932d4e
--- /dev/null
+++ b/ILSpy.BamlDecompiler/Tests/Cases/MyControl.xaml.cs
@@ -0,0 +1,26 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace ILSpy.BamlDecompiler.Tests.Cases
+{
+ ///
+ /// Interaction logic for MyControl.xaml
+ ///
+ public partial class MyControl : UserControl
+ {
+ public MyControl()
+ {
+ InitializeComponent();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ILSpy.BamlDecompiler/Tests/Cases/SimpleNames.xaml b/ILSpy.BamlDecompiler/Tests/Cases/SimpleNames.xaml
index 91a908fdf..3d94c5052 100644
--- a/ILSpy.BamlDecompiler/Tests/Cases/SimpleNames.xaml
+++ b/ILSpy.BamlDecompiler/Tests/Cases/SimpleNames.xaml
@@ -1,6 +1,6 @@
-
+
-
-
+
+
\ No newline at end of file
diff --git a/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj b/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj
index 95c91a8d6..b7174e31a 100644
--- a/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj
+++ b/ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj
@@ -70,6 +70,10 @@
AttachedEvent.xaml
Code
+
+ MyControl.xaml
+ Code
+
Resources.xaml
Code
@@ -117,6 +121,7 @@
+
Always