Browse Source

Fix #1343: Extend AwaitInCatchTransform to support catch blocks that leave the block container.

pull/1360/head
Siegfried Pammer 7 years ago
parent
commit
455d55dc46
  1. 32
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs
  2. 480
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.opt.roslyn.il
  3. 604
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.roslyn.il
  4. 25
      ICSharpCode.Decompiler/IL/ControlFlow/AwaitInCatchTransform.cs

32
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs

@ -94,6 +94,38 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -94,6 +94,38 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("Body");
}
}
#if CS60
public async Task AwaitInCatch(bool b, Task<int> task1, Task<int> task2)
{
try {
Console.WriteLine("Start try");
await task1;
Console.WriteLine("End try");
} catch (Exception) {
if (!b) {
await task2;
} else {
Console.WriteLine("No await");
}
}
}
public async Task AwaitInFinally(bool b, Task<int> task1, Task<int> task2)
{
try {
Console.WriteLine("Start try");
await task1;
Console.WriteLine("End try");
} finally {
if (!b) {
await task2;
} else {
Console.WriteLine("No await");
}
}
}
#endif
}
public struct HopToThreadPoolAwaitable : INotifyCompletion

480
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.opt.roslyn.il

@ -1126,6 +1126,404 @@ @@ -1126,6 +1126,404 @@
} // end of class '<AwaitInLoopCondition>d__10'
.class auto ansi sealed nested private beforefieldinit '<AwaitInCatch>d__11'
extends [mscorlib]System.ValueType
implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field public int32 '<>1__state'
.field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder '<>t__builder'
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task1
.field public bool b
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task2
.field private int32 '<>7__wrap1'
.field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> '<>u__1'
.method private hidebysig newslot virtual final
instance void MoveNext() cil managed
{
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext
// Code size 317 (0x13d)
.maxstack 3
.locals init (int32 V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> V_1,
int32 V_2,
class [mscorlib]System.Exception V_3)
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_0006: stloc.0
.try
{
IL_0007: ldloc.0
IL_0008: brfalse.s IL_0018
IL_000a: ldloc.0
IL_000b: ldc.i4.1
IL_000c: beq IL_00e0
IL_0011: ldarg.0
IL_0012: ldc.i4.0
IL_0013: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>7__wrap1'
IL_0018: nop
.try
{
IL_0019: ldloc.0
IL_001a: brfalse.s IL_005e
IL_001c: ldstr "Start try"
IL_0021: call void [mscorlib]System.Console::WriteLine(string)
IL_0026: ldarg.0
IL_0027: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task1
IL_002c: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_0031: stloc.1
IL_0032: ldloca.s V_1
IL_0034: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_0039: brtrue.s IL_007a
IL_003b: ldarg.0
IL_003c: ldc.i4.0
IL_003d: dup
IL_003e: stloc.0
IL_003f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_0044: ldarg.0
IL_0045: ldloc.1
IL_0046: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_004b: ldarg.0
IL_004c: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0051: ldloca.s V_1
IL_0053: ldarg.0
IL_0054: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'>(!!0&,
!!1&)
IL_0059: leave IL_013c
IL_005e: ldarg.0
IL_005f: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_0064: stloc.1
IL_0065: ldarg.0
IL_0066: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_006b: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_0071: ldarg.0
IL_0072: ldc.i4.m1
IL_0073: dup
IL_0074: stloc.0
IL_0075: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_007a: ldloca.s V_1
IL_007c: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_0081: pop
IL_0082: ldstr "End try"
IL_0087: call void [mscorlib]System.Console::WriteLine(string)
IL_008c: leave.s IL_0098
} // end .try
catch [mscorlib]System.Exception
{
IL_008e: pop
IL_008f: ldarg.0
IL_0090: ldc.i4.1
IL_0091: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>7__wrap1'
IL_0096: leave.s IL_0098
} // end handler
IL_0098: ldarg.0
IL_0099: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>7__wrap1'
IL_009e: stloc.2
IL_009f: ldloc.2
IL_00a0: ldc.i4.1
IL_00a1: bne.un.s IL_0110
IL_00a3: ldarg.0
IL_00a4: ldfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::b
IL_00a9: brtrue.s IL_0106
IL_00ab: ldarg.0
IL_00ac: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task2
IL_00b1: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_00b6: stloc.1
IL_00b7: ldloca.s V_1
IL_00b9: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_00be: brtrue.s IL_00fc
IL_00c0: ldarg.0
IL_00c1: ldc.i4.1
IL_00c2: dup
IL_00c3: stloc.0
IL_00c4: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_00c9: ldarg.0
IL_00ca: ldloc.1
IL_00cb: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_00d0: ldarg.0
IL_00d1: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_00d6: ldloca.s V_1
IL_00d8: ldarg.0
IL_00d9: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'>(!!0&,
!!1&)
IL_00de: leave.s IL_013c
IL_00e0: ldarg.0
IL_00e1: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_00e6: stloc.1
IL_00e7: ldarg.0
IL_00e8: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_00ed: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_00f3: ldarg.0
IL_00f4: ldc.i4.m1
IL_00f5: dup
IL_00f6: stloc.0
IL_00f7: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_00fc: ldloca.s V_1
IL_00fe: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_0103: pop
IL_0104: br.s IL_0110
IL_0106: ldstr "No await"
IL_010b: call void [mscorlib]System.Console::WriteLine(string)
IL_0110: leave.s IL_0129
} // end .try
catch [mscorlib]System.Exception
{
IL_0112: stloc.3
IL_0113: ldarg.0
IL_0114: ldc.i4.s -2
IL_0116: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_011b: ldarg.0
IL_011c: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0121: ldloc.3
IL_0122: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetException(class [mscorlib]System.Exception)
IL_0127: leave.s IL_013c
} // end handler
IL_0129: ldarg.0
IL_012a: ldc.i4.s -2
IL_012c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_0131: ldarg.0
IL_0132: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0137: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetResult()
IL_013c: ret
} // end of method '<AwaitInCatch>d__11'::MoveNext
.method private hidebysig newslot virtual final
instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine stateMachine) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0006: ldarg.1
IL_0007: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine)
IL_000c: ret
} // end of method '<AwaitInCatch>d__11'::SetStateMachine
} // end of class '<AwaitInCatch>d__11'
.class auto ansi sealed nested private beforefieldinit '<AwaitInFinally>d__12'
extends [mscorlib]System.ValueType
implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field public int32 '<>1__state'
.field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder '<>t__builder'
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task1
.field public bool b
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task2
.field private object '<>7__wrap1'
.field private int32 '<>7__wrap2'
.field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> '<>u__1'
.method private hidebysig newslot virtual final
instance void MoveNext() cil managed
{
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext
// Code size 354 (0x162)
.maxstack 3
.locals init (int32 V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> V_1,
object V_2,
class [mscorlib]System.Exception V_3)
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0006: stloc.0
.try
{
IL_0007: ldloc.0
IL_0008: brfalse.s IL_001f
IL_000a: ldloc.0
IL_000b: ldc.i4.1
IL_000c: beq IL_00df
IL_0011: ldarg.0
IL_0012: ldnull
IL_0013: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>7__wrap1'
IL_0018: ldarg.0
IL_0019: ldc.i4.0
IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>7__wrap2'
IL_001f: nop
.try
{
IL_0020: ldloc.0
IL_0021: brfalse.s IL_0065
IL_0023: ldstr "Start try"
IL_0028: call void [mscorlib]System.Console::WriteLine(string)
IL_002d: ldarg.0
IL_002e: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task1
IL_0033: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_0038: stloc.1
IL_0039: ldloca.s V_1
IL_003b: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_0040: brtrue.s IL_0081
IL_0042: ldarg.0
IL_0043: ldc.i4.0
IL_0044: dup
IL_0045: stloc.0
IL_0046: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_004b: ldarg.0
IL_004c: ldloc.1
IL_004d: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_0052: ldarg.0
IL_0053: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0058: ldloca.s V_1
IL_005a: ldarg.0
IL_005b: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'>(!!0&,
!!1&)
IL_0060: leave IL_0161
IL_0065: ldarg.0
IL_0066: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_006b: stloc.1
IL_006c: ldarg.0
IL_006d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_0072: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_0078: ldarg.0
IL_0079: ldc.i4.m1
IL_007a: dup
IL_007b: stloc.0
IL_007c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0081: ldloca.s V_1
IL_0083: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_0088: pop
IL_0089: ldstr "End try"
IL_008e: call void [mscorlib]System.Console::WriteLine(string)
IL_0093: leave.s IL_009f
} // end .try
catch [mscorlib]System.Object
{
IL_0095: stloc.2
IL_0096: ldarg.0
IL_0097: ldloc.2
IL_0098: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>7__wrap1'
IL_009d: leave.s IL_009f
} // end handler
IL_009f: ldarg.0
IL_00a0: ldfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::b
IL_00a5: brtrue.s IL_0105
IL_00a7: ldarg.0
IL_00a8: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task2
IL_00ad: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_00b2: stloc.1
IL_00b3: ldloca.s V_1
IL_00b5: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_00ba: brtrue.s IL_00fb
IL_00bc: ldarg.0
IL_00bd: ldc.i4.1
IL_00be: dup
IL_00bf: stloc.0
IL_00c0: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_00c5: ldarg.0
IL_00c6: ldloc.1
IL_00c7: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_00cc: ldarg.0
IL_00cd: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_00d2: ldloca.s V_1
IL_00d4: ldarg.0
IL_00d5: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'>(!!0&,
!!1&)
IL_00da: leave IL_0161
IL_00df: ldarg.0
IL_00e0: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_00e5: stloc.1
IL_00e6: ldarg.0
IL_00e7: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_00ec: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_00f2: ldarg.0
IL_00f3: ldc.i4.m1
IL_00f4: dup
IL_00f5: stloc.0
IL_00f6: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_00fb: ldloca.s V_1
IL_00fd: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_0102: pop
IL_0103: br.s IL_010f
IL_0105: ldstr "No await"
IL_010a: call void [mscorlib]System.Console::WriteLine(string)
IL_010f: ldarg.0
IL_0110: ldfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>7__wrap1'
IL_0115: stloc.2
IL_0116: ldloc.2
IL_0117: brfalse.s IL_012e
IL_0119: ldloc.2
IL_011a: isinst [mscorlib]System.Exception
IL_011f: dup
IL_0120: brtrue.s IL_0124
IL_0122: ldloc.2
IL_0123: throw
IL_0124: call class [mscorlib]System.Runtime.ExceptionServices.ExceptionDispatchInfo [mscorlib]System.Runtime.ExceptionServices.ExceptionDispatchInfo::Capture(class [mscorlib]System.Exception)
IL_0129: callvirt instance void [mscorlib]System.Runtime.ExceptionServices.ExceptionDispatchInfo::Throw()
IL_012e: ldarg.0
IL_012f: ldnull
IL_0130: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>7__wrap1'
IL_0135: leave.s IL_014e
} // end .try
catch [mscorlib]System.Exception
{
IL_0137: stloc.3
IL_0138: ldarg.0
IL_0139: ldc.i4.s -2
IL_013b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0140: ldarg.0
IL_0141: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0146: ldloc.3
IL_0147: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetException(class [mscorlib]System.Exception)
IL_014c: leave.s IL_0161
} // end handler
IL_014e: ldarg.0
IL_014f: ldc.i4.s -2
IL_0151: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0156: ldarg.0
IL_0157: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_015c: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetResult()
IL_0161: ret
} // end of method '<AwaitInFinally>d__12'::MoveNext
.method private hidebysig newslot virtual final
instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine stateMachine) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine
// Code size 13 (0xd)
.maxstack 8
IL_0000: ldarg.0
IL_0001: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0006: ldarg.1
IL_0007: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine)
IL_000c: ret
} // end of method '<AwaitInFinally>d__12'::SetStateMachine
} // end of class '<AwaitInFinally>d__12'
.method public hidebysig instance void
SimpleVoidMethod() cil managed
{
@ -1447,6 +1845,88 @@ @@ -1447,6 +1845,88 @@
IL_002c: ret
} // end of method Async::AwaitInLoopCondition
.method public hidebysig instance class [mscorlib]System.Threading.Tasks.Task
AwaitInCatch(bool b,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task1,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task2) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 47 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..GICSharpCode.D
65 63 6F 6D 70 69 6C 65 72 2E 54 65 73 74 73 2E // ecompiler.Tests.
54 65 73 74 43 61 73 65 73 2E 50 72 65 74 74 79 // TestCases.Pretty
2E 41 73 79 6E 63 2B 3C 41 77 61 69 74 49 6E 43 // .Async+<AwaitInC
61 74 63 68 3E 64 5F 5F 31 31 00 00 ) // atch>d__11..
// Code size 73 (0x49)
.maxstack 2
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11' V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder V_1)
IL_0000: ldloca.s V_0
IL_0002: ldarg.1
IL_0003: stfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::b
IL_0008: ldloca.s V_0
IL_000a: ldarg.2
IL_000b: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task1
IL_0010: ldloca.s V_0
IL_0012: ldarg.3
IL_0013: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task2
IL_0018: ldloca.s V_0
IL_001a: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Create()
IL_001f: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0024: ldloca.s V_0
IL_0026: ldc.i4.m1
IL_0027: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_002c: ldloc.0
IL_002d: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0032: stloc.1
IL_0033: ldloca.s V_1
IL_0035: ldloca.s V_0
IL_0037: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Start<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'>(!!0&)
IL_003c: ldloca.s V_0
IL_003e: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0043: call instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::get_Task()
IL_0048: ret
} // end of method Async::AwaitInCatch
.method public hidebysig instance class [mscorlib]System.Threading.Tasks.Task
AwaitInFinally(bool b,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task1,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task2) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 49 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..IICSharpCode.D
65 63 6F 6D 70 69 6C 65 72 2E 54 65 73 74 73 2E // ecompiler.Tests.
54 65 73 74 43 61 73 65 73 2E 50 72 65 74 74 79 // TestCases.Pretty
2E 41 73 79 6E 63 2B 3C 41 77 61 69 74 49 6E 46 // .Async+<AwaitInF
69 6E 61 6C 6C 79 3E 64 5F 5F 31 32 00 00 ) // inally>d__12..
// Code size 73 (0x49)
.maxstack 2
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12' V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder V_1)
IL_0000: ldloca.s V_0
IL_0002: ldarg.1
IL_0003: stfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::b
IL_0008: ldloca.s V_0
IL_000a: ldarg.2
IL_000b: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task1
IL_0010: ldloca.s V_0
IL_0012: ldarg.3
IL_0013: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task2
IL_0018: ldloca.s V_0
IL_001a: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Create()
IL_001f: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0024: ldloca.s V_0
IL_0026: ldc.i4.m1
IL_0027: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_002c: ldloc.0
IL_002d: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0032: stloc.1
IL_0033: ldloca.s V_1
IL_0035: ldloca.s V_0
IL_0037: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Start<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'>(!!0&)
IL_003c: ldloca.s V_0
IL_003e: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0043: call instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::get_Task()
IL_0048: ret
} // end of method Async::AwaitInFinally
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{

604
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.roslyn.il

@ -1360,6 +1360,516 @@ @@ -1360,6 +1360,516 @@
} // end of class '<AwaitInLoopCondition>d__10'
.class auto ansi sealed nested private beforefieldinit '<AwaitInCatch>d__11'
extends [mscorlib]System.Object
implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field public int32 '<>1__state'
.field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder '<>t__builder'
.field public bool b
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task1
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task2
.field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async '<>4__this'
.field private object '<>s__1'
.field private int32 '<>s__2'
.field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> '<>u__1'
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method '<AwaitInCatch>d__11'::.ctor
.method private hidebysig newslot virtual final
instance void MoveNext() cil managed
{
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext
// Code size 386 (0x182)
.maxstack 3
.locals init (int32 V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> V_1,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11' V_2,
class [mscorlib]System.Exception V_3,
int32 V_4,
bool V_5,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> V_6,
class [mscorlib]System.Exception V_7)
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_0006: stloc.0
.try
{
IL_0007: ldloc.0
IL_0008: brfalse.s IL_0012
IL_000a: br.s IL_000c
IL_000c: ldloc.0
IL_000d: ldc.i4.1
IL_000e: beq.s IL_0014
IL_0010: br.s IL_0019
IL_0012: br.s IL_0021
IL_0014: br IL_0112
IL_0019: nop
IL_001a: ldarg.0
IL_001b: ldc.i4.0
IL_001c: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>s__2'
IL_0021: nop
.try
{
IL_0022: ldloc.0
IL_0023: brfalse.s IL_0027
IL_0025: br.s IL_0029
IL_0027: br.s IL_0071
IL_0029: nop
IL_002a: ldstr "Start try"
IL_002f: call void [mscorlib]System.Console::WriteLine(string)
IL_0034: nop
IL_0035: ldarg.0
IL_0036: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task1
IL_003b: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_0040: stloc.1
IL_0041: ldloca.s V_1
IL_0043: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_0048: brtrue.s IL_008d
IL_004a: ldarg.0
IL_004b: ldc.i4.0
IL_004c: dup
IL_004d: stloc.0
IL_004e: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_0053: ldarg.0
IL_0054: ldloc.1
IL_0055: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_005a: ldarg.0
IL_005b: stloc.2
IL_005c: ldarg.0
IL_005d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0062: ldloca.s V_1
IL_0064: ldloca.s V_2
IL_0066: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'>(!!0&,
!!1&)
IL_006b: nop
IL_006c: leave IL_0181
IL_0071: ldarg.0
IL_0072: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_0077: stloc.1
IL_0078: ldarg.0
IL_0079: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_007e: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_0084: ldarg.0
IL_0085: ldc.i4.m1
IL_0086: dup
IL_0087: stloc.0
IL_0088: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_008d: ldloca.s V_1
IL_008f: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_0094: pop
IL_0095: ldstr "End try"
IL_009a: call void [mscorlib]System.Console::WriteLine(string)
IL_009f: nop
IL_00a0: nop
IL_00a1: leave.s IL_00b4
} // end .try
catch [mscorlib]System.Exception
{
IL_00a3: stloc.3
IL_00a4: ldarg.0
IL_00a5: ldloc.3
IL_00a6: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>s__1'
IL_00ab: ldarg.0
IL_00ac: ldc.i4.1
IL_00ad: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>s__2'
IL_00b2: leave.s IL_00b4
} // end handler
IL_00b4: ldarg.0
IL_00b5: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>s__2'
IL_00ba: stloc.s V_4
IL_00bc: ldloc.s V_4
IL_00be: ldc.i4.1
IL_00bf: beq.s IL_00c6
IL_00c1: br IL_014a
IL_00c6: nop
IL_00c7: ldarg.0
IL_00c8: ldfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::b
IL_00cd: ldc.i4.0
IL_00ce: ceq
IL_00d0: stloc.s V_5
IL_00d2: ldloc.s V_5
IL_00d4: brfalse.s IL_013a
IL_00d6: nop
IL_00d7: ldarg.0
IL_00d8: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task2
IL_00dd: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_00e2: stloc.s V_6
IL_00e4: ldloca.s V_6
IL_00e6: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_00eb: brtrue.s IL_012f
IL_00ed: ldarg.0
IL_00ee: ldc.i4.1
IL_00ef: dup
IL_00f0: stloc.0
IL_00f1: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_00f6: ldarg.0
IL_00f7: ldloc.s V_6
IL_00f9: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_00fe: ldarg.0
IL_00ff: stloc.2
IL_0100: ldarg.0
IL_0101: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0106: ldloca.s V_6
IL_0108: ldloca.s V_2
IL_010a: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'>(!!0&,
!!1&)
IL_010f: nop
IL_0110: leave.s IL_0181
IL_0112: ldarg.0
IL_0113: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_0118: stloc.s V_6
IL_011a: ldarg.0
IL_011b: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>u__1'
IL_0120: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_0126: ldarg.0
IL_0127: ldc.i4.m1
IL_0128: dup
IL_0129: stloc.0
IL_012a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_012f: ldloca.s V_6
IL_0131: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_0136: pop
IL_0137: nop
IL_0138: br.s IL_0147
IL_013a: nop
IL_013b: ldstr "No await"
IL_0140: call void [mscorlib]System.Console::WriteLine(string)
IL_0145: nop
IL_0146: nop
IL_0147: nop
IL_0148: br.s IL_014a
IL_014a: ldarg.0
IL_014b: ldnull
IL_014c: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>s__1'
IL_0151: leave.s IL_016d
} // end .try
catch [mscorlib]System.Exception
{
IL_0153: stloc.s V_7
IL_0155: ldarg.0
IL_0156: ldc.i4.s -2
IL_0158: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_015d: ldarg.0
IL_015e: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_0163: ldloc.s V_7
IL_0165: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetException(class [mscorlib]System.Exception)
IL_016a: nop
IL_016b: leave.s IL_0181
} // end handler
IL_016d: ldarg.0
IL_016e: ldc.i4.s -2
IL_0170: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_0175: ldarg.0
IL_0176: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_017b: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetResult()
IL_0180: nop
IL_0181: ret
} // end of method '<AwaitInCatch>d__11'::MoveNext
.method private hidebysig newslot virtual final
instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine stateMachine) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method '<AwaitInCatch>d__11'::SetStateMachine
} // end of class '<AwaitInCatch>d__11'
.class auto ansi sealed nested private beforefieldinit '<AwaitInFinally>d__12'
extends [mscorlib]System.Object
implements [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field public int32 '<>1__state'
.field public valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder '<>t__builder'
.field public bool b
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task1
.field public class [mscorlib]System.Threading.Tasks.Task`1<int32> task2
.field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async '<>4__this'
.field private object '<>s__1'
.field private int32 '<>s__2'
.field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> '<>u__1'
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method '<AwaitInFinally>d__12'::.ctor
.method private hidebysig newslot virtual final
instance void MoveNext() cil managed
{
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext
// Code size 413 (0x19d)
.maxstack 3
.locals init (int32 V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> V_1,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12' V_2,
object V_3,
bool V_4,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> V_5,
class [mscorlib]System.Exception V_6)
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0006: stloc.0
.try
{
IL_0007: ldloc.0
IL_0008: brfalse.s IL_0012
IL_000a: br.s IL_000c
IL_000c: ldloc.0
IL_000d: ldc.i4.1
IL_000e: beq.s IL_0014
IL_0010: br.s IL_0019
IL_0012: br.s IL_0028
IL_0014: br IL_0103
IL_0019: nop
IL_001a: ldarg.0
IL_001b: ldnull
IL_001c: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>s__1'
IL_0021: ldarg.0
IL_0022: ldc.i4.0
IL_0023: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>s__2'
IL_0028: nop
.try
{
IL_0029: ldloc.0
IL_002a: brfalse.s IL_002e
IL_002c: br.s IL_0030
IL_002e: br.s IL_0078
IL_0030: nop
IL_0031: ldstr "Start try"
IL_0036: call void [mscorlib]System.Console::WriteLine(string)
IL_003b: nop
IL_003c: ldarg.0
IL_003d: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task1
IL_0042: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_0047: stloc.1
IL_0048: ldloca.s V_1
IL_004a: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_004f: brtrue.s IL_0094
IL_0051: ldarg.0
IL_0052: ldc.i4.0
IL_0053: dup
IL_0054: stloc.0
IL_0055: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_005a: ldarg.0
IL_005b: ldloc.1
IL_005c: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_0061: ldarg.0
IL_0062: stloc.2
IL_0063: ldarg.0
IL_0064: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0069: ldloca.s V_1
IL_006b: ldloca.s V_2
IL_006d: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'>(!!0&,
!!1&)
IL_0072: nop
IL_0073: leave IL_019c
IL_0078: ldarg.0
IL_0079: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_007e: stloc.1
IL_007f: ldarg.0
IL_0080: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_0085: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_008b: ldarg.0
IL_008c: ldc.i4.m1
IL_008d: dup
IL_008e: stloc.0
IL_008f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0094: ldloca.s V_1
IL_0096: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_009b: pop
IL_009c: ldstr "End try"
IL_00a1: call void [mscorlib]System.Console::WriteLine(string)
IL_00a6: nop
IL_00a7: nop
IL_00a8: leave.s IL_00b4
} // end .try
catch [mscorlib]System.Object
{
IL_00aa: stloc.3
IL_00ab: ldarg.0
IL_00ac: ldloc.3
IL_00ad: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>s__1'
IL_00b2: leave.s IL_00b4
} // end handler
IL_00b4: nop
IL_00b5: ldarg.0
IL_00b6: ldfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::b
IL_00bb: ldc.i4.0
IL_00bc: ceq
IL_00be: stloc.s V_4
IL_00c0: ldloc.s V_4
IL_00c2: brfalse.s IL_012b
IL_00c4: nop
IL_00c5: ldarg.0
IL_00c6: ldfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task2
IL_00cb: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<int32>::GetAwaiter()
IL_00d0: stloc.s V_5
IL_00d2: ldloca.s V_5
IL_00d4: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::get_IsCompleted()
IL_00d9: brtrue.s IL_0120
IL_00db: ldarg.0
IL_00dc: ldc.i4.1
IL_00dd: dup
IL_00de: stloc.0
IL_00df: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_00e4: ldarg.0
IL_00e5: ldloc.s V_5
IL_00e7: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_00ec: ldarg.0
IL_00ed: stloc.2
IL_00ee: ldarg.0
IL_00ef: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_00f4: ldloca.s V_5
IL_00f6: ldloca.s V_2
IL_00f8: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>,class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'>(!!0&,
!!1&)
IL_00fd: nop
IL_00fe: leave IL_019c
IL_0103: ldarg.0
IL_0104: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_0109: stloc.s V_5
IL_010b: ldarg.0
IL_010c: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>u__1'
IL_0111: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>
IL_0117: ldarg.0
IL_0118: ldc.i4.m1
IL_0119: dup
IL_011a: stloc.0
IL_011b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0120: ldloca.s V_5
IL_0122: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<int32>::GetResult()
IL_0127: pop
IL_0128: nop
IL_0129: br.s IL_0138
IL_012b: nop
IL_012c: ldstr "No await"
IL_0131: call void [mscorlib]System.Console::WriteLine(string)
IL_0136: nop
IL_0137: nop
IL_0138: nop
IL_0139: ldarg.0
IL_013a: ldfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>s__1'
IL_013f: stloc.3
IL_0140: ldloc.3
IL_0141: brfalse.s IL_015e
IL_0143: ldloc.3
IL_0144: isinst [mscorlib]System.Exception
IL_0149: stloc.s V_6
IL_014b: ldloc.s V_6
IL_014d: brtrue.s IL_0151
IL_014f: ldloc.3
IL_0150: throw
IL_0151: ldloc.s V_6
IL_0153: call class [mscorlib]System.Runtime.ExceptionServices.ExceptionDispatchInfo [mscorlib]System.Runtime.ExceptionServices.ExceptionDispatchInfo::Capture(class [mscorlib]System.Exception)
IL_0158: callvirt instance void [mscorlib]System.Runtime.ExceptionServices.ExceptionDispatchInfo::Throw()
IL_015d: nop
IL_015e: ldarg.0
IL_015f: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>s__2'
IL_0164: pop
IL_0165: ldarg.0
IL_0166: ldnull
IL_0167: stfld object ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>s__1'
IL_016c: leave.s IL_0188
} // end .try
catch [mscorlib]System.Exception
{
IL_016e: stloc.s V_6
IL_0170: ldarg.0
IL_0171: ldc.i4.s -2
IL_0173: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0178: ldarg.0
IL_0179: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_017e: ldloc.s V_6
IL_0180: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetException(class [mscorlib]System.Exception)
IL_0185: nop
IL_0186: leave.s IL_019c
} // end handler
IL_0188: ldarg.0
IL_0189: ldc.i4.s -2
IL_018b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0190: ldarg.0
IL_0191: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_0196: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::SetResult()
IL_019b: nop
IL_019c: ret
} // end of method '<AwaitInFinally>d__12'::MoveNext
.method private hidebysig newslot virtual final
instance void SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine stateMachine) cil managed
{
.custom instance void [mscorlib]System.Diagnostics.DebuggerHiddenAttribute::.ctor() = ( 01 00 00 00 )
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::SetStateMachine
// Code size 1 (0x1)
.maxstack 8
IL_0000: ret
} // end of method '<AwaitInFinally>d__12'::SetStateMachine
} // end of class '<AwaitInFinally>d__12'
.method public hidebysig instance void
SimpleVoidMethod() cil managed
{
@ -1741,6 +2251,100 @@ @@ -1741,6 +2251,100 @@
IL_002f: ret
} // end of method Async::AwaitInLoopCondition
.method public hidebysig instance class [mscorlib]System.Threading.Tasks.Task
AwaitInCatch(bool b,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task1,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task2) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 47 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..GICSharpCode.D
65 63 6F 6D 70 69 6C 65 72 2E 54 65 73 74 73 2E // ecompiler.Tests.
54 65 73 74 43 61 73 65 73 2E 50 72 65 74 74 79 // TestCases.Pretty
2E 41 73 79 6E 63 2B 3C 41 77 61 69 74 49 6E 43 // .Async+<AwaitInC
61 74 63 68 3E 64 5F 5F 31 31 00 00 ) // atch>d__11..
.custom instance void [mscorlib]System.Diagnostics.DebuggerStepThroughAttribute::.ctor() = ( 01 00 00 00 )
// Code size 80 (0x50)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11' V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder V_1)
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldarg.0
IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>4__this'
IL_000d: ldloc.0
IL_000e: ldarg.1
IL_000f: stfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::b
IL_0014: ldloc.0
IL_0015: ldarg.2
IL_0016: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task1
IL_001b: ldloc.0
IL_001c: ldarg.3
IL_001d: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::task2
IL_0022: ldloc.0
IL_0023: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Create()
IL_0028: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_002d: ldloc.0
IL_002e: ldc.i4.m1
IL_002f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>1__state'
IL_0034: ldloc.0
IL_0035: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_003a: stloc.1
IL_003b: ldloca.s V_1
IL_003d: ldloca.s V_0
IL_003f: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Start<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'>(!!0&)
IL_0044: ldloc.0
IL_0045: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInCatch>d__11'::'<>t__builder'
IL_004a: call instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::get_Task()
IL_004f: ret
} // end of method Async::AwaitInCatch
.method public hidebysig instance class [mscorlib]System.Threading.Tasks.Task
AwaitInFinally(bool b,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task1,
class [mscorlib]System.Threading.Tasks.Task`1<int32> task2) cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 49 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..IICSharpCode.D
65 63 6F 6D 70 69 6C 65 72 2E 54 65 73 74 73 2E // ecompiler.Tests.
54 65 73 74 43 61 73 65 73 2E 50 72 65 74 74 79 // TestCases.Pretty
2E 41 73 79 6E 63 2B 3C 41 77 61 69 74 49 6E 46 // .Async+<AwaitInF
69 6E 61 6C 6C 79 3E 64 5F 5F 31 32 00 00 ) // inally>d__12..
.custom instance void [mscorlib]System.Diagnostics.DebuggerStepThroughAttribute::.ctor() = ( 01 00 00 00 )
// Code size 80 (0x50)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12' V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder V_1)
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldarg.0
IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>4__this'
IL_000d: ldloc.0
IL_000e: ldarg.1
IL_000f: stfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::b
IL_0014: ldloc.0
IL_0015: ldarg.2
IL_0016: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task1
IL_001b: ldloc.0
IL_001c: ldarg.3
IL_001d: stfld class [mscorlib]System.Threading.Tasks.Task`1<int32> ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::task2
IL_0022: ldloc.0
IL_0023: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Create()
IL_0028: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_002d: ldloc.0
IL_002e: ldc.i4.m1
IL_002f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>1__state'
IL_0034: ldloc.0
IL_0035: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_003a: stloc.1
IL_003b: ldloca.s V_1
IL_003d: ldloca.s V_0
IL_003f: call instance void [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::Start<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'>(!!0&)
IL_0044: ldloc.0
IL_0045: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder ICSharpCode.Decompiler.Tests.TestCases.Pretty.Async/'<AwaitInFinally>d__12'::'<>t__builder'
IL_004a: call instance class [mscorlib]System.Threading.Tasks.Task [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder::get_Task()
IL_004f: ret
} // end of method Async::AwaitInFinally
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{

25
ICSharpCode.Decompiler/IL/ControlFlow/AwaitInCatchTransform.cs

@ -53,10 +53,13 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -53,10 +53,13 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
var jumpTableBlock = (Block)result.JumpTableEntry.Parent;
jumpTableBlock.Instructions.RemoveAt(result.JumpTableEntry.ChildIndex);
if (result.NextBlock != null) {
foreach (var branch in tryCatch.Descendants.OfType<Branch>()) {
if (branch.TargetBlock == jumpTableBlock)
branch.ReplaceWith(new Branch(result.NextBlock));
foreach (var branch in tryCatch.Descendants.OfType<Branch>()) {
if (branch.TargetBlock == jumpTableBlock) {
if (result.NextBlockOrExitContainer is BlockContainer exitContainer) {
branch.ReplaceWith(new Leave(exitContainer));
} else {
branch.ReplaceWith(new Branch((Block)result.NextBlockOrExitContainer));
}
}
}
@ -104,17 +107,17 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -104,17 +107,17 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// <summary>
/// Analyzes all catch handlers and returns every handler that follows the await catch handler pattern.
/// </summary>
static bool AnalyzeHandlers(InstructionCollection<TryCatchHandler> handlers, out ILVariable catchHandlerIdentifier, out List<(int Id, TryCatchHandler Handler, Block RealCatchBlockEntryPoint, Block NextBlock, IfInstruction JumpTableEntry, StLoc ObjectVariableStore)> transformableCatchBlocks)
static bool AnalyzeHandlers(InstructionCollection<TryCatchHandler> handlers, out ILVariable catchHandlerIdentifier, out List<(int Id, TryCatchHandler Handler, Block RealCatchBlockEntryPoint, ILInstruction NextBlockOrExitContainer, IfInstruction JumpTableEntry, StLoc ObjectVariableStore)> transformableCatchBlocks)
{
transformableCatchBlocks = new List<(int Id, TryCatchHandler Handler, Block RealCatchBlockEntryPoint, Block NextBlock, IfInstruction JumpTableEntry, StLoc ObjectVariableStore)>();
transformableCatchBlocks = new List<(int Id, TryCatchHandler Handler, Block RealCatchBlockEntryPoint, ILInstruction NextBlockOrExitContainer, IfInstruction JumpTableEntry, StLoc ObjectVariableStore)>();
catchHandlerIdentifier = null;
foreach (var handler in handlers) {
if (!MatchAwaitCatchHandler((BlockContainer)handler.Body, out int id, out var identifierVariable, out var realEntryPoint, out var nextBlock, out var jumpTableEntry, out var objectVariableStore))
if (!MatchAwaitCatchHandler((BlockContainer)handler.Body, out int id, out var identifierVariable, out var realEntryPoint, out var nextBlockOrExitContainer, out var jumpTableEntry, out var objectVariableStore))
continue;
if (id < 1 || (catchHandlerIdentifier != null && identifierVariable != catchHandlerIdentifier))
continue;
catchHandlerIdentifier = identifierVariable;
transformableCatchBlocks.Add((id, handler, realEntryPoint, nextBlock, jumpTableEntry, objectVariableStore));
transformableCatchBlocks.Add((id, handler, realEntryPoint, nextBlockOrExitContainer, jumpTableEntry, objectVariableStore));
}
return transformableCatchBlocks.Count > 0;
}
@ -126,14 +129,14 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -126,14 +129,14 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
/// stloc V_5(ldc.i4 2) - store id of catch block in 'identifierVariable'
/// br IL_0075 - jump out of catch block to the head of the catch-handler jump table
/// </summary>
static bool MatchAwaitCatchHandler(BlockContainer container, out int id, out ILVariable identifierVariable, out Block realEntryPoint, out Block nextBlock, out IfInstruction jumpTableEntry, out StLoc objectVariableStore)
static bool MatchAwaitCatchHandler(BlockContainer container, out int id, out ILVariable identifierVariable, out Block realEntryPoint, out ILInstruction nextBlockOrExitContainer, out IfInstruction jumpTableEntry, out StLoc objectVariableStore)
{
id = default(int);
identifierVariable = null;
realEntryPoint = null;
jumpTableEntry = null;
objectVariableStore = null;
nextBlock = null;
nextBlockOrExitContainer = null;
var catchBlock = container.EntryPoint;
if (catchBlock.Instructions.Count < 2 || catchBlock.Instructions.Count > 4)
return false;
@ -181,7 +184,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow @@ -181,7 +184,7 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
if (!left.MatchLdLoc(identifierVariableCopy))
return false;
if (right.MatchLdcI4(id)) {
nextBlock = jumpTableEntryBlock;
nextBlockOrExitContainer = jumpTableEntryBlock ?? lastInst.Parent.Parent;
jumpTableEntry = ifInst;
return true;
}

Loading…
Cancel
Save