Browse Source

Merge pull request #676 from d-s-x/fix-empty-async-method

FIX #675. Decompile empty async void methods
pull/681/head
Daniel Grunwald 9 years ago
parent
commit
085c81420c
  1. 19
      ICSharpCode.Decompiler/ILAst/StateRange.cs
  2. 4
      ICSharpCode.Decompiler/Tests/Async.cs

19
ICSharpCode.Decompiler/ILAst/StateRange.cs

@ -273,14 +273,23 @@ namespace ICSharpCode.Decompiler.ILAst @@ -273,14 +273,23 @@ namespace ICSharpCode.Decompiler.ILAst
{
if (pos > 0 && body[pos - 1] is ILLabel) {
pos--;
return; // label found
}
// ensure that the first element at body[pos] is a label:
ILLabel newLabel = new ILLabel();
newLabel.Name = "YieldReturnEntryPoint";
ILExpression expr = pos == 1 && body.Count == 1 ? body[0] as ILExpression : null;
if (expr != null && expr.Code == ILCode.Leave && expr.Operand is ILLabel) {
ranges[newLabel] = ranges[(ILLabel)expr.Operand];
pos = 0;
} else {
// ensure that the first element at body[pos] is a label:
ILLabel newLabel = new ILLabel();
newLabel.Name = "YieldReturnEntryPoint";
ranges[newLabel] = ranges[body[pos]]; // give the label the range of the instruction at body[pos]
body.Insert(pos, newLabel);
bodyLength++;
}
body.Insert(pos, newLabel);
bodyLength++;
}
public LabelRangeMapping CreateLabelRangeMapping(List<ILNode> body, int pos, int bodyLength)

4
ICSharpCode.Decompiler/Tests/Async.cs

@ -37,6 +37,10 @@ public class Async @@ -37,6 +37,10 @@ public class Async
Console.WriteLine("No Await");
}
public async void EmptyVoidMethod()
{
}
public async void AwaitYield()
{
await Task.Yield();

Loading…
Cancel
Save