Merge pull request #527 from Nihlus/rewriter-cecil-0.10

Additional error check in rewriter
This commit is contained in:
varon 2017-05-30 21:51:35 +02:00 committed by GitHub
commit c697eaed75

View file

@ -90,6 +90,8 @@ namespace OpenTK.Rewrite
} }
// Load assembly and process all modules // Load assembly and process all modules
try
{
using (AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(file, read_params)) using (AssemblyDefinition assembly = AssemblyDefinition.ReadAssembly(file, read_params))
{ {
var rewritten = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.Name == "RewrittenAttribute"); var rewritten = assembly.CustomAttributes.FirstOrDefault(a => a.AttributeType.Name == "RewrittenAttribute");
@ -144,6 +146,11 @@ namespace OpenTK.Rewrite
assembly.Write(write_params); assembly.Write(write_params);
} }
} }
catch (InvalidOperationException inex)
{
Console.WriteLine("Failed to load the assembly. It may already have been rewritten, and the debug symbols no longer match.");
}
}
void Rewrite(TypeDefinition type, IEnumerable<string> options) void Rewrite(TypeDefinition type, IEnumerable<string> options)
{ {