Browse Source

ad #885 and #886: add more tests

pull/879/merge
Siegfried Pammer 9 years ago
parent
commit
2857a8dcf9
  1. 27
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs
  2. 14
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.il
  3. 14
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.il
  4. 270
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.roslyn.il
  5. 328
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.roslyn.il
  6. 2
      ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs

27
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.cs

@ -17,13 +17,18 @@ @@ -17,13 +17,18 @@
// DEALINGS IN THE SOFTWARE.
using System;
#if !LEGACY_CSC
using System.IO;
#endif
using System.Threading;
using System.Threading.Tasks;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{
public abstract class ExceptionHandling
{
public abstract bool B(int i);
public abstract Task<bool> T();
public abstract void M(int i);
public bool ConditionalReturnInThrow()
@ -70,6 +75,28 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -70,6 +75,28 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
return false;
}
public bool SimpleTryCatchExceptionWithNameAndConditionWithOr()
{
try {
Console.WriteLine("Try");
return this.B(new Random().Next());
} catch (Exception ex) when (ex is ArgumentException || ex is IOException) {
Console.WriteLine("CatchException ex: " + ex.ToString());
}
return false;
}
public async Task<bool> SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr()
{
try {
Console.WriteLine("Try");
return await this.T();
} catch (Exception ex) when (ex is ArgumentException || ex is IOException) {
Console.WriteLine("CatchException ex: " + ex.ToString());
}
return false;
}
#endif
public bool SimpleTryFinally()

14
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.il

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly crlipbnv
.assembly lxxrs5dq
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
@ -20,15 +20,15 @@ @@ -20,15 +20,15 @@
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module crlipbnv.dll
// MVID: {2550E8B3-391D-448D-A5A5-7F434CA2D173}
.module lxxrs5dq.dll
// MVID: {82D6FFAF-FF9D-4E8C-AC93-080CC89EB80E}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x00A40000
// Image base: 0x02E30000
// =============== CLASS MEMBERS DECLARATION ===================
@ -41,6 +41,12 @@ @@ -41,6 +41,12 @@
{
} // end of method ExceptionHandling::B
.method public hidebysig newslot abstract virtual
instance class [mscorlib]System.Threading.Tasks.Task`1<bool>
T() cil managed
{
} // end of method ExceptionHandling::T
.method public hidebysig newslot abstract virtual
instance void M(int32 i) cil managed
{

14
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.il

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly '2nwcwyaz'
.assembly mydv32cl
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilationRelaxationsAttribute::.ctor(int32) = ( 01 00 08 00 00 00 00 00 )
.custom instance void [mscorlib]System.Runtime.CompilerServices.RuntimeCompatibilityAttribute::.ctor() = ( 01 00 01 00 54 02 16 57 72 61 70 4E 6F 6E 45 78 // ....T..WrapNonEx
@ -20,15 +20,15 @@ @@ -20,15 +20,15 @@
.hash algorithm 0x00008004
.ver 0:0:0:0
}
.module '2nwcwyaz.dll'
// MVID: {575315DD-46C2-4376-B77B-EDE5CA5A5039}
.module mydv32cl.dll
// MVID: {6B95C83E-B82F-493E-BD92-AF0A5E82F1B4}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x010F0000
// Image base: 0x014A0000
// =============== CLASS MEMBERS DECLARATION ===================
@ -41,6 +41,12 @@ @@ -41,6 +41,12 @@
{
} // end of method ExceptionHandling::B
.method public hidebysig newslot abstract virtual
instance class [mscorlib]System.Threading.Tasks.Task`1<bool>
T() cil managed
{
} // end of method ExceptionHandling::T
.method public hidebysig newslot abstract virtual
instance void M(int32 i) cil managed
{

270
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.opt.roslyn.il

@ -25,14 +25,14 @@ @@ -25,14 +25,14 @@
.ver 0:0:0:0
}
.module ExceptionHandling.dll
// MVID: {A8006418-E0B4-4B57-9F6D-4F358C3537B7}
// MVID: {07FDA375-CD7B-478B-922A-E82E4CA881CF}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x00E10000
// Image base: 0x02CE0000
// =============== CLASS MEMBERS DECLARATION ===================
@ -40,11 +40,177 @@ @@ -40,11 +40,177 @@
.class public abstract auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling
extends [mscorlib]System.Object
{
.class auto ansi sealed nested private beforefieldinit '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'
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`1<bool> '<>t__builder'
.field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling '<>4__this'
.field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> '<>u__1'
.method private hidebysig newslot virtual final
instance void MoveNext() cil managed
{
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext
// Code size 242 (0xf2)
.maxstack 3
.locals init (int32 V_0,
bool V_1,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> V_2,
class [mscorlib]System.Exception V_3,
class [mscorlib]System.Exception V_4)
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_0006: stloc.0
.try
{
IL_0007: ldloc.0
IL_0008: pop
IL_0009: nop
.try
{
IL_000a: ldloc.0
IL_000b: brfalse.s IL_0054
IL_000d: ldstr "Try"
IL_0012: call void [mscorlib]System.Console::WriteLine(string)
IL_0017: ldarg.0
IL_0018: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>4__this'
IL_001d: callvirt instance class [mscorlib]System.Threading.Tasks.Task`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling::T()
IL_0022: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<bool>::GetAwaiter()
IL_0027: stloc.2
IL_0028: ldloca.s V_2
IL_002a: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>::get_IsCompleted()
IL_002f: brtrue.s IL_0070
IL_0031: ldarg.0
IL_0032: ldc.i4.0
IL_0033: dup
IL_0034: stloc.0
IL_0035: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_003a: ldarg.0
IL_003b: ldloc.2
IL_003c: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>u__1'
IL_0041: ldarg.0
IL_0042: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0047: ldloca.s V_2
IL_0049: ldarg.0
IL_004a: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>,valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'>(!!0&,
!!1&)
IL_004f: leave IL_00f1
IL_0054: ldarg.0
IL_0055: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>u__1'
IL_005a: stloc.2
IL_005b: ldarg.0
IL_005c: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>u__1'
IL_0061: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>
IL_0067: ldarg.0
IL_0068: ldc.i4.m1
IL_0069: dup
IL_006a: stloc.0
IL_006b: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_0070: ldloca.s V_2
IL_0072: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>::GetResult()
IL_0077: ldloca.s V_2
IL_0079: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>
IL_007f: stloc.1
IL_0080: leave.s IL_00dd
} // end .try
filter
{
IL_0082: isinst [mscorlib]System.Exception
IL_0087: dup
IL_0088: brtrue.s IL_008e
IL_008a: pop
IL_008b: ldc.i4.0
IL_008c: br.s IL_00a6
IL_008e: stloc.3
IL_008f: ldloc.3
IL_0090: isinst [mscorlib]System.ArgumentException
IL_0095: brtrue.s IL_00a2
IL_0097: ldloc.3
IL_0098: isinst [mscorlib]System.IO.IOException
IL_009d: ldnull
IL_009e: cgt.un
IL_00a0: br.s IL_00a3
IL_00a2: ldc.i4.1
IL_00a3: ldc.i4.0
IL_00a4: cgt.un
IL_00a6: endfilter
} // end filter
{ // handler
IL_00a8: pop
IL_00a9: ldstr "CatchException ex: "
IL_00ae: ldloc.3
IL_00af: callvirt instance string [mscorlib]System.Object::ToString()
IL_00b4: call string [mscorlib]System.String::Concat(string,
string)
IL_00b9: call void [mscorlib]System.Console::WriteLine(string)
IL_00be: leave.s IL_00c0
} // end handler
IL_00c0: ldc.i4.0
IL_00c1: stloc.1
IL_00c2: leave.s IL_00dd
} // end .try
catch [mscorlib]System.Exception
{
IL_00c4: stloc.s V_4
IL_00c6: ldarg.0
IL_00c7: ldc.i4.s -2
IL_00c9: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_00ce: ldarg.0
IL_00cf: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_00d4: ldloc.s V_4
IL_00d6: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::SetException(class [mscorlib]System.Exception)
IL_00db: leave.s IL_00f1
} // end handler
IL_00dd: ldarg.0
IL_00de: ldc.i4.s -2
IL_00e0: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_00e5: ldarg.0
IL_00e6: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_00eb: ldloc.1
IL_00ec: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::SetResult(!0)
IL_00f1: ret
} // end of method '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::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`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0006: ldarg.1
IL_0007: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::SetStateMachine(class [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine)
IL_000c: ret
} // end of method '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::SetStateMachine
} // end of class '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'
.method public hidebysig newslot abstract virtual
instance bool B(int32 i) cil managed
{
} // end of method ExceptionHandling::B
.method public hidebysig newslot abstract virtual
instance class [mscorlib]System.Threading.Tasks.Task`1<bool>
T() cil managed
{
} // end of method ExceptionHandling::T
.method public hidebysig newslot abstract virtual
instance void M(int32 i) cil managed
{
@ -212,6 +378,106 @@ @@ -212,6 +378,106 @@
IL_005a: ret
} // end of method ExceptionHandling::SimpleTryCatchExceptionWithNameAndCondition
.method public hidebysig instance bool
SimpleTryCatchExceptionWithNameAndConditionWithOr() cil managed
{
// Code size 95 (0x5f)
.maxstack 2
.locals init (bool V_0,
class [mscorlib]System.Exception V_1)
.try
{
IL_0000: ldstr "Try"
IL_0005: call void [mscorlib]System.Console::WriteLine(string)
IL_000a: ldarg.0
IL_000b: newobj instance void [mscorlib]System.Random::.ctor()
IL_0010: callvirt instance int32 [mscorlib]System.Random::Next()
IL_0015: callvirt instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling::B(int32)
IL_001a: stloc.0
IL_001b: leave.s IL_005d
} // end .try
filter
{
IL_001d: isinst [mscorlib]System.Exception
IL_0022: dup
IL_0023: brtrue.s IL_0029
IL_0025: pop
IL_0026: ldc.i4.0
IL_0027: br.s IL_0041
IL_0029: stloc.1
IL_002a: ldloc.1
IL_002b: isinst [mscorlib]System.ArgumentException
IL_0030: brtrue.s IL_003d
IL_0032: ldloc.1
IL_0033: isinst [mscorlib]System.IO.IOException
IL_0038: ldnull
IL_0039: cgt.un
IL_003b: br.s IL_003e
IL_003d: ldc.i4.1
IL_003e: ldc.i4.0
IL_003f: cgt.un
IL_0041: endfilter
} // end filter
{ // handler
IL_0043: pop
IL_0044: ldstr "CatchException ex: "
IL_0049: ldloc.1
IL_004a: callvirt instance string [mscorlib]System.Object::ToString()
IL_004f: call string [mscorlib]System.String::Concat(string,
string)
IL_0054: call void [mscorlib]System.Console::WriteLine(string)
IL_0059: leave.s IL_005b
} // end handler
IL_005b: ldc.i4.0
IL_005c: ret
IL_005d: ldloc.0
IL_005e: ret
} // end of method ExceptionHandling::SimpleTryCatchExceptionWithNameAndConditionWithOr
.method public hidebysig instance class [mscorlib]System.Threading.Tasks.Task`1<bool>
SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 7C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..|ICSharpCode.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 45 78 63 65 70 74 69 6F 6E 48 61 6E 64 6C 69 // .ExceptionHandli
6E 67 2B 3C 53 69 6D 70 6C 65 41 73 79 6E 63 54 // ng+<SimpleAsyncT
72 79 43 61 74 63 68 45 78 63 65 70 74 69 6F 6E // ryCatchException
57 69 74 68 4E 61 6D 65 41 6E 64 43 6F 6E 64 69 // WithNameAndCondi
74 69 6F 6E 57 69 74 68 4F 72 3E 64 5F 5F 38 00 // tionWithOr>d__8.
00 )
// Code size 57 (0x39)
.maxstack 2
.locals init (valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8' V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> V_1)
IL_0000: ldloca.s V_0
IL_0002: ldarg.0
IL_0003: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>4__this'
IL_0008: ldloca.s V_0
IL_000a: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<!0> valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::Create()
IL_000f: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0014: ldloca.s V_0
IL_0016: ldc.i4.m1
IL_0017: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_001c: ldloc.0
IL_001d: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0022: stloc.1
IL_0023: ldloca.s V_1
IL_0025: ldloca.s V_0
IL_0027: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::Start<valuetype ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'>(!!0&)
IL_002c: ldloca.s V_0
IL_002e: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0033: call instance class [mscorlib]System.Threading.Tasks.Task`1<!0> valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::get_Task()
IL_0038: ret
} // end of method ExceptionHandling::SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr
.method public hidebysig instance bool
SimpleTryFinally() cil managed
{

328
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExceptionHandling.roslyn.il

@ -25,14 +25,14 @@ @@ -25,14 +25,14 @@
.ver 0:0:0:0
}
.module ExceptionHandling.dll
// MVID: {9E5D4825-3895-41C9-96B8-84EF4BB28F59}
// MVID: {07B52948-317B-4C30-A2A5-A7482568AD67}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000
.file alignment 0x00000200
.stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY
// Image base: 0x02A40000
// Image base: 0x00ED0000
// =============== CLASS MEMBERS DECLARATION ===================
@ -40,11 +40,222 @@ @@ -40,11 +40,222 @@
.class public abstract auto ansi beforefieldinit ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling
extends [mscorlib]System.Object
{
.class auto ansi sealed nested private beforefieldinit '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'
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`1<bool> '<>t__builder'
.field public class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling '<>4__this'
.field private bool '<>s__1'
.field private class [mscorlib]System.Exception '<ex>5__2'
.field private valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> '<>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 '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::.ctor
.method private hidebysig newslot virtual final
instance void MoveNext() cil managed
{
.override [mscorlib]System.Runtime.CompilerServices.IAsyncStateMachine::MoveNext
// Code size 306 (0x132)
.maxstack 3
.locals init (int32 V_0,
bool V_1,
valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> V_2,
bool V_3,
class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8' V_4,
class [mscorlib]System.Exception V_5,
bool V_6)
IL_0000: ldarg.0
IL_0001: ldfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_0006: stloc.0
.try
{
IL_0007: ldloc.0
IL_0008: brfalse.s IL_000c
IL_000a: br.s IL_000e
IL_000c: br.s IL_000f
IL_000e: nop
IL_000f: nop
.try
{
IL_0010: ldloc.0
IL_0011: brfalse.s IL_0015
IL_0013: br.s IL_0017
IL_0015: br.s IL_0065
IL_0017: nop
IL_0018: ldstr "Try"
IL_001d: call void [mscorlib]System.Console::WriteLine(string)
IL_0022: nop
IL_0023: ldarg.0
IL_0024: ldfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>4__this'
IL_0029: callvirt instance class [mscorlib]System.Threading.Tasks.Task`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling::T()
IL_002e: callvirt instance valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<!0> class [mscorlib]System.Threading.Tasks.Task`1<bool>::GetAwaiter()
IL_0033: stloc.2
IL_0034: ldloca.s V_2
IL_0036: call instance bool valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>::get_IsCompleted()
IL_003b: brtrue.s IL_0081
IL_003d: ldarg.0
IL_003e: ldc.i4.0
IL_003f: dup
IL_0040: stloc.0
IL_0041: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_0046: ldarg.0
IL_0047: ldloc.2
IL_0048: stfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>u__1'
IL_004d: ldarg.0
IL_004e: stloc.s V_4
IL_0050: ldarg.0
IL_0051: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0056: ldloca.s V_2
IL_0058: ldloca.s V_4
IL_005a: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::AwaitUnsafeOnCompleted<valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>,class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'>(!!0&,
!!1&)
IL_005f: nop
IL_0060: leave IL_0131
IL_0065: ldarg.0
IL_0066: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>u__1'
IL_006b: stloc.2
IL_006c: ldarg.0
IL_006d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>u__1'
IL_0072: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>
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.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_0081: ldloca.s V_2
IL_0083: call instance !0 valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>::GetResult()
IL_0088: stloc.3
IL_0089: ldloca.s V_2
IL_008b: initobj valuetype [mscorlib]System.Runtime.CompilerServices.TaskAwaiter`1<bool>
IL_0091: ldarg.0
IL_0092: ldloc.3
IL_0093: stfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>s__1'
IL_0098: ldarg.0
IL_0099: ldfld bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>s__1'
IL_009e: stloc.1
IL_009f: leave.s IL_011c
} // end .try
filter
{
IL_00a1: isinst [mscorlib]System.Exception
IL_00a6: dup
IL_00a7: brtrue.s IL_00ad
IL_00a9: pop
IL_00aa: ldc.i4.0
IL_00ab: br.s IL_00dc
IL_00ad: stloc.s V_5
IL_00af: ldarg.0
IL_00b0: ldloc.s V_5
IL_00b2: stfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<ex>5__2'
IL_00b7: ldarg.0
IL_00b8: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<ex>5__2'
IL_00bd: isinst [mscorlib]System.ArgumentException
IL_00c2: brtrue.s IL_00d4
IL_00c4: ldarg.0
IL_00c5: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<ex>5__2'
IL_00ca: isinst [mscorlib]System.IO.IOException
IL_00cf: ldnull
IL_00d0: cgt.un
IL_00d2: br.s IL_00d5
IL_00d4: ldc.i4.1
IL_00d5: stloc.s V_6
IL_00d7: ldloc.s V_6
IL_00d9: ldc.i4.0
IL_00da: cgt.un
IL_00dc: endfilter
} // end filter
{ // handler
IL_00de: pop
IL_00df: nop
IL_00e0: ldstr "CatchException ex: "
IL_00e5: ldarg.0
IL_00e6: ldfld class [mscorlib]System.Exception ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<ex>5__2'
IL_00eb: callvirt instance string [mscorlib]System.Object::ToString()
IL_00f0: call string [mscorlib]System.String::Concat(string,
string)
IL_00f5: call void [mscorlib]System.Console::WriteLine(string)
IL_00fa: nop
IL_00fb: nop
IL_00fc: leave.s IL_00fe
} // end handler
IL_00fe: ldc.i4.0
IL_00ff: stloc.1
IL_0100: leave.s IL_011c
} // end .try
catch [mscorlib]System.Exception
{
IL_0102: stloc.s V_5
IL_0104: ldarg.0
IL_0105: ldc.i4.s -2
IL_0107: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_010c: ldarg.0
IL_010d: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0112: ldloc.s V_5
IL_0114: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::SetException(class [mscorlib]System.Exception)
IL_0119: nop
IL_011a: leave.s IL_0131
} // end handler
IL_011c: ldarg.0
IL_011d: ldc.i4.s -2
IL_011f: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_0124: ldarg.0
IL_0125: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_012a: ldloc.1
IL_012b: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::SetResult(!0)
IL_0130: nop
IL_0131: ret
} // end of method '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::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 '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::SetStateMachine
} // end of class '<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'
.method public hidebysig newslot abstract virtual
instance bool B(int32 i) cil managed
{
} // end of method ExceptionHandling::B
.method public hidebysig newslot abstract virtual
instance class [mscorlib]System.Threading.Tasks.Task`1<bool>
T() cil managed
{
} // end of method ExceptionHandling::T
.method public hidebysig newslot abstract virtual
instance void M(int32 i) cil managed
{
@ -246,6 +457,119 @@ @@ -246,6 +457,119 @@
IL_0064: ret
} // end of method ExceptionHandling::SimpleTryCatchExceptionWithNameAndCondition
.method public hidebysig instance bool
SimpleTryCatchExceptionWithNameAndConditionWithOr() cil managed
{
// Code size 105 (0x69)
.maxstack 2
.locals init (bool V_0,
class [mscorlib]System.Exception V_1,
bool V_2)
IL_0000: nop
.try
{
IL_0001: nop
IL_0002: ldstr "Try"
IL_0007: call void [mscorlib]System.Console::WriteLine(string)
IL_000c: nop
IL_000d: ldarg.0
IL_000e: newobj instance void [mscorlib]System.Random::.ctor()
IL_0013: callvirt instance int32 [mscorlib]System.Random::Next()
IL_0018: callvirt instance bool ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling::B(int32)
IL_001d: stloc.0
IL_001e: leave.s IL_0067
} // end .try
filter
{
IL_0020: isinst [mscorlib]System.Exception
IL_0025: dup
IL_0026: brtrue.s IL_002c
IL_0028: pop
IL_0029: ldc.i4.0
IL_002a: br.s IL_0046
IL_002c: stloc.1
IL_002d: ldloc.1
IL_002e: isinst [mscorlib]System.ArgumentException
IL_0033: brtrue.s IL_0040
IL_0035: ldloc.1
IL_0036: isinst [mscorlib]System.IO.IOException
IL_003b: ldnull
IL_003c: cgt.un
IL_003e: br.s IL_0041
IL_0040: ldc.i4.1
IL_0041: stloc.2
IL_0042: ldloc.2
IL_0043: ldc.i4.0
IL_0044: cgt.un
IL_0046: endfilter
} // end filter
{ // handler
IL_0048: pop
IL_0049: nop
IL_004a: ldstr "CatchException ex: "
IL_004f: ldloc.1
IL_0050: callvirt instance string [mscorlib]System.Object::ToString()
IL_0055: call string [mscorlib]System.String::Concat(string,
string)
IL_005a: call void [mscorlib]System.Console::WriteLine(string)
IL_005f: nop
IL_0060: nop
IL_0061: leave.s IL_0063
} // end handler
IL_0063: ldc.i4.0
IL_0064: stloc.0
IL_0065: br.s IL_0067
IL_0067: ldloc.0
IL_0068: ret
} // end of method ExceptionHandling::SimpleTryCatchExceptionWithNameAndConditionWithOr
.method public hidebysig instance class [mscorlib]System.Threading.Tasks.Task`1<bool>
SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr() cil managed
{
.custom instance void [mscorlib]System.Runtime.CompilerServices.AsyncStateMachineAttribute::.ctor(class [mscorlib]System.Type) = ( 01 00 7C 49 43 53 68 61 72 70 43 6F 64 65 2E 44 // ..|ICSharpCode.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 45 78 63 65 70 74 69 6F 6E 48 61 6E 64 6C 69 // .ExceptionHandli
6E 67 2B 3C 53 69 6D 70 6C 65 41 73 79 6E 63 54 // ng+<SimpleAsyncT
72 79 43 61 74 63 68 45 78 63 65 70 74 69 6F 6E // ryCatchException
57 69 74 68 4E 61 6D 65 41 6E 64 43 6F 6E 64 69 // WithNameAndCondi
74 69 6F 6E 57 69 74 68 4F 72 3E 64 5F 5F 38 00 // tionWithOr>d__8.
00 )
.custom instance void [mscorlib]System.Diagnostics.DebuggerStepThroughAttribute::.ctor() = ( 01 00 00 00 )
// Code size 59 (0x3b)
.maxstack 2
.locals init (class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8' V_0,
valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> V_1)
IL_0000: newobj instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::.ctor()
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: ldarg.0
IL_0008: stfld class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>4__this'
IL_000d: ldloc.0
IL_000e: call valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<!0> valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::Create()
IL_0013: stfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0018: ldloc.0
IL_0019: ldc.i4.m1
IL_001a: stfld int32 ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>1__state'
IL_001f: ldloc.0
IL_0020: ldfld valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0025: stloc.1
IL_0026: ldloca.s V_1
IL_0028: ldloca.s V_0
IL_002a: call instance void valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::Start<class ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'>(!!0&)
IL_002f: ldloc.0
IL_0030: ldflda valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool> ICSharpCode.Decompiler.Tests.TestCases.Pretty.ExceptionHandling/'<SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr>d__8'::'<>t__builder'
IL_0035: call instance class [mscorlib]System.Threading.Tasks.Task`1<!0> valuetype [mscorlib]System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<bool>::get_Task()
IL_003a: ret
} // end of method ExceptionHandling::SimpleAsyncTryCatchExceptionWithNameAndConditionWithOr
.method public hidebysig instance bool
SimpleTryFinally() cil managed
{

2
ICSharpCode.Decompiler/IL/Transforms/CopyPropagation.cs

@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -83,7 +83,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
// note: the initialization by the caller is the first store -> StoreCount must be 1
return v.IsSingleDefinition;
case VariableKind.StackSlot:
case VariableKind.Exception:
case VariableKind.Exception: // Exception variables are normally generated as well.
// Variables are be copied only if both they and the target copy variable are generated,
// and if the variable has only a single assignment
return v.IsSingleDefinition && target.Kind == VariableKind.StackSlot;

Loading…
Cancel
Save