Skip to content
Permalink
Browse files

#1625: Improve error message, if known assembly cannot be resolved.

  • Loading branch information...
siegfriedpammer committed Aug 9, 2019
1 parent 87353aa commit 71644bcae90e6e240f6b92554b58e771acb1b8b6
Showing with 17 additions and 6 deletions.
  1. +17 −6 ILSpy.BamlDecompiler/Baml/KnownThings.cs
@@ -45,19 +45,30 @@ internal partial class KnownThings {
strings = new Dictionary<int, string>();
resources = new Dictionary<int, (string, string, string)>();

InitAssemblies();
InitTypes();
InitMembers();
InitStrings();
InitResources();
try {
InitAssemblies();
InitTypes();
InitMembers();
InitStrings();
InitResources();
} catch (Exception ex) {
throw new ICSharpCode.Decompiler.DecompilerException(typeSystem.MainModule.PEFile, ex.Message, ex);
}
}

public Func<KnownTypes, ITypeDefinition> Types => id => types[id];
public Func<KnownMembers, KnownMember> Members => id => members[id];
public Func<short, string> Strings => id => strings[id];
public Func<short, (string, string, string)> Resources => id => resources[id];
public IModule FrameworkAssembly => assemblies[0];
IModule ResolveAssembly(string name) => typeSystem.Modules.First(m => m.FullAssemblyName == name);
IModule ResolveAssembly(string name)
{
IModule module = typeSystem.Modules.FirstOrDefault(m => m.FullAssemblyName == name);
if (module == null)
throw new Exception("Could not resolve known assembly '" + name + "'!");
return module;
}

ITypeDefinition InitType(IModule assembly, string ns, string name) => assembly.GetTypeDefinition(new TopLevelTypeName(ns, name));
KnownMember InitMember(KnownTypes parent, string name, ITypeDefinition type) => new KnownMember(parent, types[parent], name, type);
}

0 comments on commit 71644bc

Please sign in to comment.
You can’t perform that action at this time.