Browse Source

#993: Move empty body special case to ILAst.

pull/1012/head
Daniel Grunwald 8 years ago
parent
commit
03cb637798
  1. 9
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs
  2. 8
      ICSharpCode.Decompiler/IL/BlockBuilder.cs

9
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -738,15 +738,6 @@ namespace ICSharpCode.Decompiler.CSharp @@ -738,15 +738,6 @@ namespace ICSharpCode.Decompiler.CSharp
void DecompileBody(MethodDefinition methodDefinition, IMethod method, EntityDeclaration entityDecl, ITypeResolveContext decompilationContext)
{
try {
// Special case: code size is 0
// This might be a reference assembly:
if (methodDefinition.Body.CodeSize == 0) {
var dummy = new BlockStatement();
dummy.InsertChildAfter(null, new EmptyStatement(), BlockStatement.StatementRole);
dummy.InsertChildAfter(null, new Comment(" Empty body found. Decompiled assembly might be a reference assembly."), Roles.Comment);
entityDecl.AddChild(dummy, Roles.Body);
return;
}
var specializingTypeSystem = typeSystem.GetSpecializingTypeSystem(decompilationContext);
var ilReader = new ILReader(specializingTypeSystem);
ilReader.UseDebugSymbols = settings.UseDebugSymbols;

8
ICSharpCode.Decompiler/IL/BlockBuilder.cs

@ -113,6 +113,14 @@ namespace ICSharpCode.Decompiler.IL @@ -113,6 +113,14 @@ namespace ICSharpCode.Decompiler.IL
CreateContainerStructure();
mainContainer.ILRange = new Interval(0, body.CodeSize);
currentContainer = mainContainer;
if (instructions.Count == 0) {
currentContainer.Blocks.Add(new Block {
Instructions = {
new InvalidBranch("Empty body found. Decompiled assembly might be a reference assembly.")
}
});
return;
}
foreach (var inst in instructions) {
cancellationToken.ThrowIfCancellationRequested();

Loading…
Cancel
Save