Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…not found due to type forwarding
  • Loading branch information
siegfriedpammer committed Aug 21, 2011
1 parent ac683e2 commit c0fe6d0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ILSpy.BamlDecompiler/CecilTypeResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,38 @@ public IType GetTypeByAssemblyQualifiedName(string name)
string assemblyName = name.Substring(comma + 1).Trim();

var type = thisAssembly.MainModule.GetType(fullName);

if (type == null) {
type = TryFindInExportedTypes(fullName, thisAssembly);
}

if (type == null) {
var otherAssembly = resolver.Resolve(assemblyName);
if (otherAssembly == null)
throw new Exception("could not resolve '" + assemblyName + "'!");
type = otherAssembly.MainModule.GetType(fullName.Replace('+', '/'));

if (type == null) {
type = TryFindInExportedTypes(fullName, otherAssembly);
}
}

if (type == null)
throw new Exception("could not resolve '" + name + "'!");

return new CecilType(type);
}

TypeDefinition TryFindInExportedTypes(string fullName, AssemblyDefinition asm)
{
foreach (var exportedType in asm.MainModule.ExportedTypes) {
if (exportedType.IsForwarder && exportedType.FullName == fullName) {
return exportedType.Resolve();
}
}

return null;
}

public IDependencyPropertyDescriptor GetDependencyPropertyDescriptor(string name, IType ownerType, IType targetType)
{
Expand Down

0 comments on commit c0fe6d0

Please sign in to comment.