Browse Source

add more unit tests; use current type instead of declaring type for PropertyElements

pull/252/head
Siegfried Pammer 14 years ago
parent
commit
5ef8af1346
  1. 5
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlElement.cs
  2. 3
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlPropertyElement.cs
  3. 9
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs
  4. 77
      ILSpy.BamlDecompiler/Tests/Cases/AvalonDockBrushes.xaml
  5. 8
      ILSpy.BamlDecompiler/Tests/Cases/Resources.xaml
  6. 3
      ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj
  7. 46
      ILSpy.BamlDecompiler/Tests/Mocks/AvalonDock.cs
  8. 8
      ILSpy.BamlDecompiler/Tests/TestRunner.cs

5
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlElement.cs

@ -19,6 +19,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -19,6 +19,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
public XmlBamlElement(XmlBamlElement parent)
{
this.Parent = parent;
this.Namespaces.AddRange(parent.Namespaces);
}
@ -26,7 +27,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -26,7 +27,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
{
get { return _namespaces; }
}
public XmlBamlElement Parent { get; private set; }
public TypeDeclaration TypeDeclaration { get; set; }
public override XmlNodeType NodeType {

3
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlPropertyElement.cs

@ -11,8 +11,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -11,8 +11,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
{
private readonly PropertyType _propertyType;
private PropertyDeclaration propertyDeclaration;
public XmlBamlPropertyElement(PropertyType propertyType, PropertyDeclaration propertyDeclaration)
{
_propertyType = propertyType;

9
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

@ -604,7 +604,12 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -604,7 +604,12 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
else if (node is XmlBamlPropertyElement)
{
XmlBamlPropertyElement property = (XmlBamlPropertyElement)node;
localName = String.Format("{0}.{1}", property.TypeDeclaration.Name, property.PropertyDeclaration.Name);
string typeName = property.TypeDeclaration.Name;
if (property.Parent.TypeDeclaration.Type.IsSubclassOf(property.PropertyDeclaration.DeclaringType.Type))
typeName = property.Parent.TypeDeclaration.Name;
localName = String.Format("{0}.{1}", typeName, property.PropertyDeclaration.Name);
}
else if (node is XmlBamlElement)
localName = ((XmlBamlElement)node).TypeDeclaration.Name;
@ -1117,7 +1122,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -1117,7 +1122,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
sb.Append(sep);
sb.Append(((XmlBamlText)node).Text);
}
sep = ",";
sep = ", ";
}
}

77
ILSpy.BamlDecompiler/Tests/Cases/AvalonDockBrushes.xaml

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ad="clr-namespace:AvalonDock">
<SolidColorBrush x:Key="ManagedContentTabControlNormalBorderBrush" Color="#919B9C" />
<SolidColorBrush x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DefaultBackgroundBrush}}" Color="#FFF4F2E8" />
<LinearGradientBrush x:Key="ManagedContentTabItemNormalBackground" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FFECEBE6" Offset="0"/>
<GradientStop Color="#FFFFFFFF" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ManagedContentTabItemInvNormalBackground" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#FFECEBE6" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<LinearGradientBrush x:Key="ManagedContentTabItemHotBackground" StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#FFECEBE6" Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush x:Key="ManagedContentTabItemSelectedBackground"
Color="#FFFCFCFE"/>
<SolidColorBrush x:Key="ManagedContentTabItemDisabledBackground"
Color="#FFF5F4EA"/>
<LinearGradientBrush x:Key="ManagedContentTabItemSelectedBorderBackround" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FFFFC73C" Offset="0"/>
<GradientStop Color="#FFE68B2C" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ManagedContentTabItemSelectedBorderBrush"
Color="#FFE68B2C"/>
<SolidColorBrush x:Key="ManagedContentTabItemHotBorderBackround"
Color="#FFFFC73C"/>
<SolidColorBrush x:Key="ManagedContentTabItemHotBorderBrush"
Color="#FFE68B2C"/>
<SolidColorBrush x:Key="ManagedContentTabItemDisabledBorderBrush"
Color="#FFC9C7BA"/>
<LinearGradientBrush x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DockablePaneTitleBackgroundSelected}}"
StartPoint="0,0"
EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStop Color="#FF3B80ED"
Offset="0"/>
<GradientStop Color="#FF316AC5"
Offset="1"/>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
<SolidColorBrush
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DockablePaneTitleBackground}}"
Color="#FFCCC5BA"/>
<SolidColorBrush
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DockablePaneTitleForeground}}"
Color="Black"/>
<SolidColorBrush
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DockablePaneTitleForegroundSelected}}"
Color="White"/>
<SolidColorBrush
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.PaneHeaderCommandBackground}}"
Color="{x:Static SystemColors.ControlLightLightColor}" Opacity="0.5" />
<SolidColorBrush
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.PaneHeaderCommandBorderBrush}}"
Color="{x:Static SystemColors.ControlDarkColor}"/>
<LinearGradientBrush x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DocumentHeaderBackground}}" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FFFFFFFF" Offset="0" />
<GradientStop Color="#FFE0E0E0" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DocumentHeaderForeground}}"
Color="{x:Static SystemColors.WindowTextColor}"/>
<LinearGradientBrush x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DocumentHeaderBackgroundSelected}}" StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FFFFFFFF" Offset="0" />
<GradientStop Color="#FFC1D2EE" Offset="1" />
</LinearGradientBrush>
<SolidColorBrush
x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type ad:DockingManager}, ResourceId={x:Static ad:AvalonDockBrushes.DocumentHeaderBackgroundMouseOver}}"
Color="White"/>
</ResourceDictionary>

8
ILSpy.BamlDecompiler/Tests/Cases/Resources.xaml

@ -1,16 +1,16 @@ @@ -1,16 +1,16 @@
<Window x:Class="ILSpy.BamlDecompiler.Tests.Cases.Resources" Title="ILSpy.BamlDecompiler.Tests.Cases" Height="300" Width="300" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Canvas>
<FrameworkElement.Resources>
<Canvas.Resources>
<ResourceDictionary>
<BooleanToVisibilityConverter x:Key="b" />
</ResourceDictionary>
</FrameworkElement.Resources>
</Canvas.Resources>
</Canvas>
<Canvas>
<FrameworkElement.Resources>
<Canvas.Resources>
<BooleanToVisibilityConverter x:Key="b" />
</FrameworkElement.Resources>
</Canvas.Resources>
</Canvas>
</Grid>
</Window>

3
ILSpy.BamlDecompiler/Tests/ILSpy.BamlDecompiler.Tests.csproj

@ -74,6 +74,7 @@ @@ -74,6 +74,7 @@
<DependentUpon>Simple.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Mocks\AvalonDock.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TestRunner.cs" />
</ItemGroup>
@ -101,9 +102,11 @@ @@ -101,9 +102,11 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Cases" />
<Folder Include="Mocks" />
<Folder Include="Properties" />
</ItemGroup>
<ItemGroup>
<Page Include="Cases\AvalonDockBrushes.xaml" />
<Page Include="Cases\Resources.xaml" />
<Page Include="Cases\Simple.xaml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

46
ILSpy.BamlDecompiler/Tests/Mocks/AvalonDock.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
// 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.Windows.Media;
namespace AvalonDock
{
public class DockingManager
{
public DockingManager()
{
}
}
public enum AvalonDockBrushes
{
DefaultBackgroundBrush,
DockablePaneTitleBackground,
DockablePaneTitleBackgroundSelected,
DockablePaneTitleForeground,
DockablePaneTitleForegroundSelected,
PaneHeaderCommandBackground,
PaneHeaderCommandBorderBrush,
DocumentHeaderBackground,
DocumentHeaderForeground,
DocumentHeaderForegroundSelected,
DocumentHeaderForegroundSelectedActivated,
DocumentHeaderBackgroundSelected,
DocumentHeaderBackgroundSelectedActivated,
DocumentHeaderBackgroundMouseOver,
DocumentHeaderBorderBrushMouseOver,
DocumentHeaderBorder,
DocumentHeaderBorderSelected,
DocumentHeaderBorderSelectedActivated,
NavigatorWindowTopBackground,
NavigatorWindowTitleForeground,
NavigatorWindowDocumentTypeForeground,
NavigatorWindowInfoTipForeground,
NavigatorWindowForeground,
NavigatorWindowBackground,
NavigatorWindowSelectionBackground,
NavigatorWindowSelectionBorderbrush,
NavigatorWindowBottomBackground
}
}

8
ILSpy.BamlDecompiler/Tests/TestRunner.cs

@ -37,6 +37,12 @@ namespace ILSpy.BamlDecompiler.Tests @@ -37,6 +37,12 @@ namespace ILSpy.BamlDecompiler.Tests
RunTest("cases/resources");
}
[Test]
public void AvalonDockBrushes()
{
RunTest("cases/avalondockbrushes");
}
#region RunTest
void RunTest(string name)
{
@ -48,7 +54,7 @@ namespace ILSpy.BamlDecompiler.Tests @@ -48,7 +54,7 @@ namespace ILSpy.BamlDecompiler.Tests
XDocument document = BamlResourceEntryNode.LoadIntoDocument(new DefaultAssemblyResolver(), assembly, bamlStream);
string path = Path.Combine("..\\..\\Tests", name + ".xaml");
CodeAssert.AreEqual(document.ToString(), File.ReadAllText(path));
CodeAssert.AreEqual(File.ReadAllText(path), document.ToString());
}
Stream LoadBaml(Resource res, string name)

Loading…
Cancel
Save