Browse Source

add support for nested classes in type system - fix missing Win32Native.Color

pull/252/head
Siegfried Pammer 14 years ago
parent
commit
19a8087be0
  1. 3
      ILSpy.BamlDecompiler/CecilDependencyPropertyDescriptor.cs
  2. 2
      ILSpy.BamlDecompiler/CecilType.cs
  3. 2
      ILSpy.BamlDecompiler/CecilTypeResolver.cs
  4. 2
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs
  5. 80
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/TypeDeclaration.cs
  6. 19
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlElement.cs
  7. 2
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlPropertyElement.cs
  8. 8
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

3
ILSpy.BamlDecompiler/CecilDependencyPropertyDescriptor.cs

@ -2,6 +2,7 @@ @@ -2,6 +2,7 @@
// This code is distributed under the MS-PL (for details please see \doc\MS-PL.txt)
using System;
using System.Diagnostics;
using System.Linq;
using ICSharpCode.ILSpy;
using Mono.Cecil;
@ -16,6 +17,8 @@ namespace ILSpy.BamlDecompiler @@ -16,6 +17,8 @@ namespace ILSpy.BamlDecompiler
public CecilDependencyPropertyDescriptor(string member, TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException("type");
this.member = member;
this.type = type;
}

2
ILSpy.BamlDecompiler/CecilType.cs

@ -15,6 +15,8 @@ namespace ILSpy.BamlDecompiler @@ -15,6 +15,8 @@ namespace ILSpy.BamlDecompiler
public CecilType(TypeDefinition type)
{
if (type == null)
throw new ArgumentNullException("type");
this.type = type;
}

2
ILSpy.BamlDecompiler/CecilTypeResolver.cs

@ -52,7 +52,7 @@ namespace ILSpy.BamlDecompiler @@ -52,7 +52,7 @@ namespace ILSpy.BamlDecompiler
var otherAssembly = resolver.Resolve(assemblyName);
if (otherAssembly == null)
throw new Exception("could not resolve '" + assemblyName + "'!");
type = otherAssembly.MainModule.GetType(fullName);
type = otherAssembly.MainModule.GetType(fullName.Replace('+', '/'));
}
return new CecilType(type);

2
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/KnownInfo.cs

@ -127,7 +127,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -127,7 +127,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
KnownTypeTable[0x4e] = new TypeDeclaration(resolver, "CollectionContainer", "System.Windows.Data", 0);
KnownTypeTable[0x4f] = new TypeDeclaration(resolver, "CollectionView", "System.Windows.Data", 0);
KnownTypeTable[80] = new TypeDeclaration(resolver, "CollectionViewSource", "System.Windows.Data", 0);
KnownTypeTable[0x51] = new TypeDeclaration(resolver, "Color", "Microsoft.Win32", 2);
KnownTypeTable[0x51] = new TypeDeclaration(resolver, "Color", "Win32Native", "Microsoft.Win32", 2);
KnownTypeTable[0x52] = new TypeDeclaration(resolver, "ColorAnimation", "System.Windows.Media.Animation", 1);
KnownTypeTable[0x53] = new TypeDeclaration(resolver, "ColorAnimationBase", "System.Windows.Media.Animation", 1);
KnownTypeTable[0x54] = new TypeDeclaration(resolver, "ColorAnimationUsingKeyFrames", "System.Windows.Media.Animation", 1);

80
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/TypeDeclaration.cs

@ -8,11 +8,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -8,11 +8,6 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
internal class TypeDeclaration
{
private readonly XmlBamlReader reader;
private readonly short _assemblyId;
private readonly bool _isKnown;
private readonly string _name;
private readonly string _namespaceName;
private readonly bool _isExtension;
private IType _type;
private bool _typeLoaded;
@ -21,7 +16,12 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -21,7 +16,12 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
public TypeDeclaration(ITypeResolver resolver, string name, string namespaceName, short assemblyId)
: this(null, resolver, name, namespaceName, assemblyId, true)
{
}
public TypeDeclaration(ITypeResolver resolver, string name, string enclosingTypeName, string namespaceName, short assemblyId)
: this(null, resolver, name, namespaceName, assemblyId, true)
{
this.EnclosingTypeName = enclosingTypeName;
}
public TypeDeclaration(ITypeResolver resolver, string name, string namespaceName, short assemblyId, bool isExtension)
@ -39,10 +39,10 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -39,10 +39,10 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
{
this.reader = reader;
this.resolver = resolver;
this._name = name;
this._namespaceName = namespaceName;
this._assemblyId = assemblyId;
this._isKnown = isKnown;
this.Name = name;
this.Namespace = namespaceName;
this.AssemblyId = assemblyId;
this.IsKnown = isKnown;
if (!_isExtension)
_isExtension = name.EndsWith("Extension");
@ -50,8 +50,10 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -50,8 +50,10 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
public override string ToString()
{
return this._name;
return this.Name;
}
public string EnclosingTypeName { get; private set; }
public bool IsExtension
{
@ -60,8 +62,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -60,8 +62,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
public string Assembly
{
get
{
get {
if (reader != null)
return this.reader.GetAssembly(this.AssemblyId);
else
@ -69,46 +70,19 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -69,46 +70,19 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
}
}
public short AssemblyId
{
get { return _assemblyId; }
}
public short AssemblyId { get; private set; }
public string Name
{
get
{
return this._name;
}
}
public string Name { get; private set; }
public bool IsKnown
{
get { return _isKnown; }
}
public bool IsKnown { get; private set; }
//public Type DotNetType
//{
// get
// {
// if (!_typeLoaded)
// {
// _type = Type.GetType(String.Format("{0}.{1}, {2}", this.Namespace, this.Name, this.Assembly), false, true);
// _typeLoaded = true;
// }
// return _type;
// }
//}
public IType Type
{
public IType Type {
get
{
if (!_typeLoaded)
{
if (this.Name.Length > 0)
_type = resolver.GetTypeByAssemblyQualifiedName(String.Format("{0}.{1}, {2}", this.Namespace, this.Name, this.Assembly));
_type = resolver.GetTypeByAssemblyQualifiedName(AssemblyQualifiedName);
_typeLoaded = true;
}
@ -116,26 +90,28 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -116,26 +90,28 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
}
}
public string Namespace
{
get
{
return this._namespaceName;
}
public string Namespace { get; private set; }
public string FullyQualifiedName {
get { return EnclosingTypeName == null ? string.Format("{0}.{1}", Namespace, Name) : string.Format("{0}.{1}+{2}", Namespace, EnclosingTypeName, Name); }
}
public string AssemblyQualifiedName {
get { return string.Format("{0}, {1}", FullyQualifiedName, Assembly); }
}
public override bool Equals(object obj)
{
TypeDeclaration td = obj as TypeDeclaration;
if (td != null)
return (this.Name == td.Name && this.Namespace == td.Namespace && this.AssemblyId == td.AssemblyId);
return (this.Name == td.Name && this.EnclosingTypeName == td.EnclosingTypeName && this.Namespace == td.Namespace && this.AssemblyId == td.AssemblyId);
else
return false;
}
public override int GetHashCode()
{
return this.AssemblyId ^ this.Name.GetHashCode() ^ this.Namespace.GetHashCode();
return this.AssemblyId ^ this.Name.GetHashCode() ^ this.EnclosingTypeName.GetHashCode() ^ this.Namespace.GetHashCode();
}
}

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

@ -23,8 +23,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -23,8 +23,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
this.Namespaces.AddRange(parent.Namespaces);
}
public XmlNamespaceCollection Namespaces
{
public XmlNamespaceCollection Namespaces {
get { return _namespaces; }
}
@ -42,11 +41,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -42,11 +41,11 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
public override string ToString()
{
return String.Format("Element: {0}", TypeDeclaration.Name);
return string.Format("Element: {0}", TypeDeclaration.Name);
}
}
internal class XmlBamlEndElement : XmlBamlElement
class XmlBamlEndElement : XmlBamlElement
{
public XmlBamlEndElement(XmlBamlElement start)
{
@ -54,19 +53,13 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -54,19 +53,13 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
this.Namespaces.AddRange(start.Namespaces);
}
public override XmlNodeType NodeType
{
get
{
return XmlNodeType.EndElement;
}
public override XmlNodeType NodeType {
get { return XmlNodeType.EndElement; }
}
public override string ToString()
{
return String.Format("EndElement: {0}", TypeDeclaration.Name);
return string.Format("EndElement: {0}", TypeDeclaration.Name);
}
}
}

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

@ -41,7 +41,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -41,7 +41,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
public override string ToString()
{
return String.Format("PropertyElement: {0}.{1}", TypeDeclaration.Name, PropertyDeclaration.Name);
return String.Format("PropertyElement: {0}.{1}", TypeDeclaration.Name.Replace('+', '.'), PropertyDeclaration.Name);
}
}
}

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

@ -632,9 +632,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -632,9 +632,9 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
{
get
{
if (intoAttribute) return String.Empty;
if (intoAttribute) return string.Empty;
String localName = String.Empty;
String localName = string.Empty;
XmlBamlNode node = this.CurrentNode;
if (node is XmlBamlSimpleProperty) {
@ -1226,7 +1226,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -1226,7 +1226,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
nodes.Enqueue(element);
if (oldDeclaration != null) {
nodes.Enqueue(new XmlBamlSimpleProperty(XWPFNamespace, "Class", string.Format("{0}.{1}", oldDeclaration.Namespace, oldDeclaration.Name)));
nodes.Enqueue(new XmlBamlSimpleProperty(XWPFNamespace, "Class", oldDeclaration.FullyQualifiedName.Replace('+', '.')));
}
if (parentElement != null && complexPropertyOpened == 0 && !Current.IsInStaticResource && Current.Previous.IsDeferred) {
@ -1590,7 +1590,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -1590,7 +1590,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
TypeDeclaration GetKnownTypeDeclarationByName(string name)
{
foreach (var type in KnownInfo.KnownTypeTable) {
if (name == string.Format("{0}.{1}, {2}", type.Namespace, type.Name, type.Assembly))
if (name == type.AssemblyQualifiedName)
return type;
}

Loading…
Cancel
Save