Browse Source

fix #264: add UnresolvableDependencyPropertyDescriptor and UnresolvableType to represent types from assemblies that cannot be loaded

pull/205/merge
Siegfried Pammer 14 years ago
parent
commit
2872d2ea1d
  1. 6
      ILSpy.BamlDecompiler/CecilType.cs
  2. 15
      ILSpy.BamlDecompiler/CecilTypeResolver.cs
  3. 9
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/IDependencyPropertyDescriptor.cs
  4. 32
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/IType.cs

6
ILSpy.BamlDecompiler/CecilType.cs

@ -32,11 +32,11 @@ namespace ILSpy.BamlDecompiler @@ -32,11 +32,11 @@ namespace ILSpy.BamlDecompiler
if (type == null)
throw new ArgumentNullException("type");
if (!(type is CecilType))
throw new ArgumentException("type has to be a CecilType");
return false;
CecilType ct = (CecilType)type;
var t = ct.type;
var t = this.type;
while (t != null) {
if (t == ct.type)
@ -60,7 +60,7 @@ namespace ILSpy.BamlDecompiler @@ -60,7 +60,7 @@ namespace ILSpy.BamlDecompiler
if (type == null)
throw new ArgumentNullException("type");
if (!(type is CecilType))
throw new ArgumentException("type has to be a CecilType");
return false;
return this.type == ((CecilType)type).type;
}

15
ILSpy.BamlDecompiler/CecilTypeResolver.cs

@ -56,7 +56,7 @@ namespace ILSpy.BamlDecompiler @@ -56,7 +56,7 @@ namespace ILSpy.BamlDecompiler
if (type == null) {
var otherAssembly = resolver.Resolve(assemblyName);
if (otherAssembly == null)
throw new Exception("could not resolve '" + assemblyName + "'!");
return new UnresolvableType(name);
type = otherAssembly.MainModule.GetType(fullName.Replace('+', '/'));
if (type == null) {
@ -65,7 +65,7 @@ namespace ILSpy.BamlDecompiler @@ -65,7 +65,7 @@ namespace ILSpy.BamlDecompiler
}
if (type == null)
throw new Exception("could not resolve '" + name + "'!");
return new UnresolvableType(name);
return new CecilType(type);
}
@ -83,10 +83,15 @@ namespace ILSpy.BamlDecompiler @@ -83,10 +83,15 @@ namespace ILSpy.BamlDecompiler
public IDependencyPropertyDescriptor GetDependencyPropertyDescriptor(string name, IType ownerType, IType targetType)
{
if (!(ownerType is CecilType))
throw new ArgumentException();
if (ownerType == null)
throw new ArgumentNullException("ownerType");
return new CecilDependencyPropertyDescriptor(name, ((CecilType)ownerType).type);
if (ownerType is CecilType)
return new CecilDependencyPropertyDescriptor(name, ((CecilType)ownerType).type);
if (ownerType is UnresolvableType)
return new UnresolvableDependencyPropertyDescriptor();
throw new ArgumentException("Invalid IType: " + ownerType.GetType());
}
public string RuntimeVersion {

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

@ -11,4 +11,13 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -11,4 +11,13 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
{
bool IsAttached { get; }
}
public class UnresolvableDependencyPropertyDescriptor : IDependencyPropertyDescriptor
{
public bool IsAttached {
get {
return false;
}
}
}
}

32
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/IType.cs

@ -17,4 +17,36 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -17,4 +17,36 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
bool IsSubclassOf(IType type);
bool Equals(IType type);
}
public class UnresolvableType : IType
{
string assemblyQualifiedName;
public UnresolvableType(string assemblyQualifiedName)
{
this.assemblyQualifiedName = assemblyQualifiedName;
}
public IType BaseType {
get {
return null;
}
}
public string AssemblyQualifiedName {
get {
return assemblyQualifiedName;
}
}
public bool IsSubclassOf(IType type)
{
return Equals(type);
}
public bool Equals(IType type)
{
return type is UnresolvableType && type.AssemblyQualifiedName == AssemblyQualifiedName;
}
}
}

Loading…
Cancel
Save