Skip to content

Commit

Permalink
Fix namespace prefixes of property elements.
Browse files Browse the repository at this point in the history
  • Loading branch information
vwoodzell committed May 15, 2013
1 parent 6ba013d commit b54be39
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,13 @@ public override string NamespaceURI {
|| (elementDeclaration.Type != null && declaration.Type != null && elementDeclaration.Type.IsSubclassOf(declaration.Type)))
return String.Empty;
}
else if (node is XmlBamlPropertyElement)
{
XmlBamlPropertyElement property = (XmlBamlPropertyElement)node;
declaration = property.TypeDeclaration;
if (property.Parent.TypeDeclaration.Type.IsSubclassOf(property.PropertyDeclaration.DeclaringType.Type))
declaration = property.Parent.TypeDeclaration;
}
else if (node is XmlBamlElement)
declaration = ((XmlBamlElement)node).TypeDeclaration;
else
Expand Down
13 changes: 13 additions & 0 deletions ILSpy.BamlDecompiler/Tests/Cases/CustomControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;

namespace ILSpy.BamlDecompiler.Tests.Cases
{
public class CustomControl : Control
{
}
}
12 changes: 12 additions & 0 deletions ILSpy.BamlDecompiler/Tests/Cases/NamespacePrefix.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:cc="clr-namespace:ILSpy.BamlDecompiler.Tests.Cases">
<Label>
<Label.Style>
<Style />
</Label.Style>
</Label>
<cc:CustomControl>
<cc:CustomControl.Style>
<Style />
</cc:CustomControl.Style>
</cc:CustomControl>
</Grid>
2 changes: 2 additions & 0 deletions ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<DependentUpon>AttachedEvent.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Cases\CustomControl.cs" />
<Compile Include="Cases\MyControl.xaml.cs">
<DependentUpon>MyControl.xaml</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -127,6 +128,7 @@
<Page Include="Cases\AvalonDockCommon.xaml" />
<Page Include="Cases\MarkupExtension.xaml" />
<Page Include="Cases\MyControl.xaml" />
<Page Include="Cases\NamespacePrefix.xaml" />
<Page Include="Cases\Resources.xaml" />
<Page Include="Cases\Simple.xaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
6 changes: 6 additions & 0 deletions ILSpy.BamlDecompiler/Tests/TestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public void SimplePropertyElement()
RunTest("cases/simplepropertyelement");
}

[Test]
public void NamespacePrefix()
{
RunTest("cases/namespaceprefix");
}

#region RunTest
void RunTest(string name)
{
Expand Down

0 comments on commit b54be39

Please sign in to comment.