Browse Source

Add more switch pretty test cases

pull/887/head
Siegfried Pammer 8 years ago
parent
commit
4927de647b
  1. 337
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs
  2. 178
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il
  3. 176
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il
  4. 143
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il
  5. 144
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il

337
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs

@ -44,41 +44,41 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("SparseIntegerSwitch: " + i); Console.WriteLine("SparseIntegerSwitch: " + i);
switch (i) { switch (i) {
case -10000000: { case -10000000: {
return "-10 mln"; return "-10 mln";
} }
case -100: { case -100: {
return "-hundred"; return "-hundred";
} }
case -1: { case -1: {
return "-1"; return "-1";
} }
case 0: { case 0: {
return "0"; return "0";
} }
case 1: { case 1: {
return "1"; return "1";
} }
case 2: { case 2: {
return "2"; return "2";
} }
case 4: { case 4: {
return "4"; return "4";
} }
case 100: { case 100: {
return "hundred"; return "hundred";
} }
case 10000: { case 10000: {
return "ten thousand"; return "ten thousand";
} }
case 10001: { case 10001: {
return "ten thousand and one"; return "ten thousand and one";
} }
case 2147483647: { case 2147483647: {
return "int.MaxValue"; return "int.MaxValue";
} }
default: { default: {
return "something else"; return "something else";
} }
} }
} }
@ -86,20 +86,20 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
switch (i) { switch (i) {
case null: { case null: {
return "null"; return "null";
} }
case 0: { case 0: {
return "zero"; return "zero";
} }
case 5: { case 5: {
return "five"; return "five";
} }
case 10: { case 10: {
return "ten"; return "ten";
} }
default: { default: {
return "large"; return "large";
} }
} }
} }
@ -107,20 +107,20 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
switch (i + 5) { switch (i + 5) {
case null: { case null: {
return "null"; return "null";
} }
case 0: { case 0: {
return "zero"; return "zero";
} }
case 5: { case 5: {
return "five"; return "five";
} }
case 10: { case 10: {
return "ten"; return "ten";
} }
default: { default: {
return "large"; return "large";
} }
} }
} }
@ -128,17 +128,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
switch (i) { switch (i) {
case 0: { case 0: {
return "zero"; return "zero";
} }
case 5: { case 5: {
return "five"; return "five";
} }
case 10: { case 10: {
return "ten"; return "ten";
} }
default: { default: {
return "other"; return "other";
} }
} }
} }
@ -146,17 +146,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
{ {
switch (i + 5) { switch (i + 5) {
case 0: { case 0: {
return "zero"; return "zero";
} }
case 5: { case 5: {
return "five"; return "five";
} }
case 10: { case 10: {
return "ten"; return "ten";
} }
default: { default: {
return "other"; return "other";
} }
} }
} }
@ -199,17 +199,17 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("ShortSwitchOverString: " + text); Console.WriteLine("ShortSwitchOverString: " + text);
switch (text) { switch (text) {
case "First case": { case "First case": {
return "Text1"; return "Text1";
} }
case "Second case": { case "Second case": {
return "Text2"; return "Text2";
} }
case "Third case": { case "Third case": {
return "Text3"; return "Text3";
} }
default: { default: {
return "Default"; return "Default";
} }
} }
} }
@ -218,30 +218,30 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("SwitchOverString1: " + text); Console.WriteLine("SwitchOverString1: " + text);
switch (text) { switch (text) {
case "First case": { case "First case": {
return "Text1"; return "Text1";
} }
case "Second case": case "Second case":
case "2nd case": { case "2nd case": {
return "Text2"; return "Text2";
} }
case "Third case": { case "Third case": {
return "Text3"; return "Text3";
} }
case "Fourth case": { case "Fourth case": {
return "Text4"; return "Text4";
} }
case "Fifth case": { case "Fifth case": {
return "Text5"; return "Text5";
} }
case "Sixth case": { case "Sixth case": {
return "Text6"; return "Text6";
} }
case null: { case null: {
return null; return null;
} }
default: { default: {
return "Default"; return "Default";
} }
} }
} }
@ -251,41 +251,41 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
string userName = Environment.UserName; string userName = Environment.UserName;
switch (userName) { switch (userName) {
case "First case": { case "First case": {
return "Text1"; return "Text1";
} }
case "Second case": { case "Second case": {
return "Text2"; return "Text2";
} }
case "Third case": { case "Third case": {
return "Text3"; return "Text3";
} }
case "Fourth case": { case "Fourth case": {
return "Text4"; return "Text4";
} }
case "Fifth case": { case "Fifth case": {
return "Text5"; return "Text5";
} }
case "Sixth case": { case "Sixth case": {
return "Text6"; return "Text6";
} }
case "Seventh case": { case "Seventh case": {
return "Text7"; return "Text7";
} }
case "Eighth case": { case "Eighth case": {
return "Text8"; return "Text8";
} }
case "Ninth case": { case "Ninth case": {
return "Text9"; return "Text9";
} }
case "Tenth case": { case "Tenth case": {
return "Text10"; return "Text10";
} }
case "Eleventh case": { case "Eleventh case": {
return "Text11"; return "Text11";
} }
default: { default: {
return "Default"; return "Default";
} }
} }
} }
@ -294,14 +294,14 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("SwitchOverBool: " + b.ToString()); Console.WriteLine("SwitchOverBool: " + b.ToString());
switch (b) { switch (b) {
case true: { case true: {
return bool.TrueString; return bool.TrueString;
} }
case false: { case false: {
return bool.FalseString; return bool.FalseString;
} }
default: { default: {
return null; return null;
} }
} }
} }
@ -311,26 +311,26 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
while (true) { while (true) {
switch (i) { switch (i) {
case 1: { case 1: {
Console.WriteLine("one"); Console.WriteLine("one");
break; break;
} }
case 2: { case 2: {
Console.WriteLine("two"); Console.WriteLine("two");
break; break;
} }
case 3: { case 3: {
Console.WriteLine("three"); Console.WriteLine("three");
continue; continue;
} }
case 4: { case 4: {
Console.WriteLine("four"); Console.WriteLine("four");
return; return;
} }
default: { default: {
Console.WriteLine("default"); Console.WriteLine("default");
Console.WriteLine("more code"); Console.WriteLine("more code");
return; return;
} }
} }
i++; i++;
} }
@ -341,26 +341,27 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Console.WriteLine("SwitchWithGoto: " + i); Console.WriteLine("SwitchWithGoto: " + i);
switch (i) { switch (i) {
case 1: { case 1: {
Console.WriteLine("one"); Console.WriteLine("one");
goto default; goto default;
} }
case 2: { case 2: {
Console.WriteLine("two"); Console.WriteLine("two");
goto case 3; goto case 3;
} }
case 3: { case 3: {
Console.WriteLine("three"); Console.WriteLine("three");
break; break;
} }
case 4: { case 4: {
Console.WriteLine("four"); Console.WriteLine("four");
return; return;
} }
default: { default: {
Console.WriteLine("default"); Console.WriteLine("default");
break; break;
} }
} }
Console.WriteLine("End of method");
} }
private static SetProperty[] GetProperties() private static SetProperty[] GetProperties()
@ -409,5 +410,51 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
} }
} }
} }
public static void SwitchWithComplexCondition(string[] args)
{
switch (args.Length == 0 ? "dummy" : args[0]) {
case "a": {
Console.WriteLine("a");
break;
}
case "b": {
Console.WriteLine("b");
break;
}
case "c": {
Console.WriteLine("c");
break;
}
case "d": {
Console.WriteLine("d");
break;
}
}
Console.WriteLine("end");
}
public static void SwitchWithArray(string[] args)
{
switch (args[0]) {
case "a": {
Console.WriteLine("a");
break;
}
case "b": {
Console.WriteLine("b");
break;
}
case "c": {
Console.WriteLine("c");
break;
}
case "d": {
Console.WriteLine("d");
break;
}
}
Console.WriteLine("end");
}
} }
} }

178
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il

@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly cgwywrw0 .assembly y0cd2lcb
{ {
.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 .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
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
@ -20,15 +20,15 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module cgwywrw0.dll .module y0cd2lcb.dll
// MVID: {12C66A56-696F-4026-B79B-EFB40F4CD81E} // MVID: {85E7C039-2097-47F9-A636-4F4E3015541A}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x00B50000 // Image base: 0x02630000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -655,7 +655,7 @@
IL_0015: brfalse IL_00ef IL_0015: brfalse IL_00ef
IL_001a: volatile. IL_001a: volatile.
IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x6000008-1' IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000008-1'
IL_0021: brtrue.s IL_0084 IL_0021: brtrue.s IL_0084
IL_0023: ldc.i4.7 IL_0023: ldc.i4.7
@ -696,9 +696,9 @@
IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0, IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1) !1)
IL_007d: volatile. IL_007d: volatile.
IL_007f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x6000008-1' IL_007f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000008-1'
IL_0084: volatile. IL_0084: volatile.
IL_0086: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x6000008-1' IL_0086: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000008-1'
IL_008b: ldloc.1 IL_008b: ldloc.1
IL_008c: ldloca.s V_2 IL_008c: ldloca.s V_2
IL_008e: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0, IL_008e: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
@ -781,7 +781,7 @@
IL_0015: brfalse IL_0165 IL_0015: brfalse IL_0165
IL_001a: volatile. IL_001a: volatile.
IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x6000009-1' IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000009-1'
IL_0021: brtrue IL_00ba IL_0021: brtrue IL_00ba
IL_0026: ldc.i4.s 11 IL_0026: ldc.i4.s 11
@ -842,9 +842,9 @@
IL_00ae: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0, IL_00ae: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1) !1)
IL_00b3: volatile. IL_00b3: volatile.
IL_00b5: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x6000009-1' IL_00b5: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000009-1'
IL_00ba: volatile. IL_00ba: volatile.
IL_00bc: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x6000009-1' IL_00bc: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000009-1'
IL_00c1: ldloc.2 IL_00c1: ldloc.2
IL_00c2: ldloca.s V_3 IL_00c2: ldloca.s V_3
IL_00c4: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0, IL_00c4: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
@ -1048,7 +1048,7 @@
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed .method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{ {
// Code size 122 (0x7a) // Code size 133 (0x85)
.maxstack 2 .maxstack 2
.locals init (int32 V_0) .locals init (int32 V_0)
IL_0000: nop IL_0000: nop
@ -1093,7 +1093,7 @@
IL_005e: ldstr "four" IL_005e: ldstr "four"
IL_0063: call void [mscorlib]System.Console::WriteLine(string) IL_0063: call void [mscorlib]System.Console::WriteLine(string)
IL_0068: nop IL_0068: nop
IL_0069: br.s IL_0079 IL_0069: br.s IL_0084
IL_006b: nop IL_006b: nop
IL_006c: ldstr "default" IL_006c: ldstr "default"
@ -1101,7 +1101,10 @@
IL_0076: nop IL_0076: nop
IL_0077: br.s IL_0079 IL_0077: br.s IL_0079
IL_0079: ret IL_0079: ldstr "End of method"
IL_007e: call void [mscorlib]System.Console::WriteLine(string)
IL_0083: nop
IL_0084: ret
} // end of method Switch::SwitchWithGoto } // end of method Switch::SwitchWithGoto
.method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[]
@ -1159,7 +1162,7 @@
IL_0034: brfalse IL_012d IL_0034: brfalse IL_012d
IL_0039: volatile. IL_0039: volatile.
IL_003b: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x600000e-1' IL_003b: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x600000e-1'
IL_0040: brtrue.s IL_0097 IL_0040: brtrue.s IL_0097
IL_0042: ldc.i4.6 IL_0042: ldc.i4.6
@ -1195,9 +1198,9 @@
IL_008b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0, IL_008b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1) !1)
IL_0090: volatile. IL_0090: volatile.
IL_0092: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x600000e-1' IL_0092: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x600000e-1'
IL_0097: volatile. IL_0097: volatile.
IL_0099: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}'::'$$method0x600000e-1' IL_0099: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x600000e-1'
IL_009e: ldloc.s V_6 IL_009e: ldloc.s V_6
IL_00a0: ldloca.s V_7 IL_00a0: ldloca.s V_7
IL_00a2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0, IL_00a2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
@ -1289,16 +1292,155 @@
IL_014d: ret IL_014d: ret
} // end of method Switch::SwitchOnStringInForLoop } // end of method Switch::SwitchOnStringInForLoop
.method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed
{
// Code size 139 (0x8b)
.maxstack 2
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldlen
IL_0003: conv.i4
IL_0004: brfalse.s IL_000b
IL_0006: ldarg.0
IL_0007: ldc.i4.0
IL_0008: ldelem.ref
IL_0009: br.s IL_0010
IL_000b: ldstr "dummy"
IL_0010: nop
IL_0011: stloc.0
IL_0012: ldloc.0
IL_0013: brfalse.s IL_007f
IL_0015: ldloc.0
IL_0016: ldstr "a"
IL_001b: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0020: brtrue.s IL_004b
IL_0022: ldloc.0
IL_0023: ldstr "b"
IL_0028: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002d: brtrue.s IL_0058
IL_002f: ldloc.0
IL_0030: ldstr "c"
IL_0035: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_003a: brtrue.s IL_0065
IL_003c: ldloc.0
IL_003d: ldstr "d"
IL_0042: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0047: brtrue.s IL_0072
IL_0049: br.s IL_007f
IL_004b: ldstr "a"
IL_0050: call void [mscorlib]System.Console::WriteLine(string)
IL_0055: nop
IL_0056: br.s IL_007f
IL_0058: ldstr "b"
IL_005d: call void [mscorlib]System.Console::WriteLine(string)
IL_0062: nop
IL_0063: br.s IL_007f
IL_0065: ldstr "c"
IL_006a: call void [mscorlib]System.Console::WriteLine(string)
IL_006f: nop
IL_0070: br.s IL_007f
IL_0072: ldstr "d"
IL_0077: call void [mscorlib]System.Console::WriteLine(string)
IL_007c: nop
IL_007d: br.s IL_007f
IL_007f: ldstr "end"
IL_0084: call void [mscorlib]System.Console::WriteLine(string)
IL_0089: nop
IL_008a: ret
} // end of method Switch::SwitchWithComplexCondition
.method public hidebysig static void SwitchWithArray(string[] args) cil managed
{
// Code size 126 (0x7e)
.maxstack 2
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldc.i4.0
IL_0003: ldelem.ref
IL_0004: stloc.0
IL_0005: ldloc.0
IL_0006: brfalse.s IL_0072
IL_0008: ldloc.0
IL_0009: ldstr "a"
IL_000e: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0013: brtrue.s IL_003e
IL_0015: ldloc.0
IL_0016: ldstr "b"
IL_001b: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0020: brtrue.s IL_004b
IL_0022: ldloc.0
IL_0023: ldstr "c"
IL_0028: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002d: brtrue.s IL_0058
IL_002f: ldloc.0
IL_0030: ldstr "d"
IL_0035: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_003a: brtrue.s IL_0065
IL_003c: br.s IL_0072
IL_003e: ldstr "a"
IL_0043: call void [mscorlib]System.Console::WriteLine(string)
IL_0048: nop
IL_0049: br.s IL_0072
IL_004b: ldstr "b"
IL_0050: call void [mscorlib]System.Console::WriteLine(string)
IL_0055: nop
IL_0056: br.s IL_0072
IL_0058: ldstr "c"
IL_005d: call void [mscorlib]System.Console::WriteLine(string)
IL_0062: nop
IL_0063: br.s IL_0072
IL_0065: ldstr "d"
IL_006a: call void [mscorlib]System.Console::WriteLine(string)
IL_006f: nop
IL_0070: br.s IL_0072
IL_0072: ldstr "end"
IL_0077: call void [mscorlib]System.Console::WriteLine(string)
IL_007c: nop
IL_007d: ret
} // end of method Switch::SwitchWithArray
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}' .class private auto ansi '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'
extends [mscorlib]System.Object extends [mscorlib]System.Object
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000008-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000008-1'
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000009-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000009-1'
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x600000e-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x600000e-1'
} // end of class '<PrivateImplementationDetails>{12C66A56-696F-4026-B79B-EFB40F4CD81E}' } // end of class '<PrivateImplementationDetails>{85E7C039-2097-47F9-A636-4F4E3015541A}'
// ============================================================= // =============================================================

176
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il

@ -10,7 +10,7 @@
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0 .ver 4:0:0:0
} }
.assembly '2bmtzwrf' .assembly nwkzngd2
{ {
.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 .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
63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows. 63 65 70 74 69 6F 6E 54 68 72 6F 77 73 01 ) // ceptionThrows.
@ -20,15 +20,15 @@
.hash algorithm 0x00008004 .hash algorithm 0x00008004
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module '2bmtzwrf.dll' .module nwkzngd2.dll
// MVID: {F90E3F03-F070-45F0-AC05-0914EF70B327} // MVID: {2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x02E10000 // Image base: 0x008E0000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -527,7 +527,7 @@
IL_0013: brfalse IL_00db IL_0013: brfalse IL_00db
IL_0018: volatile. IL_0018: volatile.
IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x6000008-1' IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000008-1'
IL_001f: brtrue.s IL_0082 IL_001f: brtrue.s IL_0082
IL_0021: ldc.i4.7 IL_0021: ldc.i4.7
@ -568,9 +568,9 @@
IL_0076: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0, IL_0076: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1) !1)
IL_007b: volatile. IL_007b: volatile.
IL_007d: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x6000008-1' IL_007d: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000008-1'
IL_0082: volatile. IL_0082: volatile.
IL_0084: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x6000008-1' IL_0084: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000008-1'
IL_0089: ldloc.0 IL_0089: ldloc.0
IL_008a: ldloca.s V_1 IL_008a: ldloca.s V_1
IL_008c: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0, IL_008c: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
@ -631,7 +631,7 @@
IL_0013: brfalse IL_013f IL_0013: brfalse IL_013f
IL_0018: volatile. IL_0018: volatile.
IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x6000009-1' IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000009-1'
IL_001f: brtrue IL_00b8 IL_001f: brtrue IL_00b8
IL_0024: ldc.i4.s 11 IL_0024: ldc.i4.s 11
@ -692,9 +692,9 @@
IL_00ac: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0, IL_00ac: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1) !1)
IL_00b1: volatile. IL_00b1: volatile.
IL_00b3: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x6000009-1' IL_00b3: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000009-1'
IL_00b8: volatile. IL_00b8: volatile.
IL_00ba: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x6000009-1' IL_00ba: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000009-1'
IL_00bf: ldloc.1 IL_00bf: ldloc.1
IL_00c0: ldloca.s V_2 IL_00c0: ldloca.s V_2
IL_00c2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0, IL_00c2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
@ -837,7 +837,7 @@
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed .method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{ {
// Code size 104 (0x68) // Code size 115 (0x73)
.maxstack 2 .maxstack 2
.locals init (int32 V_0) .locals init (int32 V_0)
IL_0000: ldstr "SwitchWithGoto: " IL_0000: ldstr "SwitchWithGoto: "
@ -855,26 +855,28 @@
IL_0031, IL_0031,
IL_003d, IL_003d,
IL_0047, IL_0047,
IL_0052) IL_0053)
IL_002f: br.s IL_005d IL_002f: br.s IL_005e
IL_0031: ldstr "one" IL_0031: ldstr "one"
IL_0036: call void [mscorlib]System.Console::WriteLine(string) IL_0036: call void [mscorlib]System.Console::WriteLine(string)
IL_003b: br.s IL_005d IL_003b: br.s IL_005e
IL_003d: ldstr "two" IL_003d: ldstr "two"
IL_0042: call void [mscorlib]System.Console::WriteLine(string) IL_0042: call void [mscorlib]System.Console::WriteLine(string)
IL_0047: ldstr "three" IL_0047: ldstr "three"
IL_004c: call void [mscorlib]System.Console::WriteLine(string) IL_004c: call void [mscorlib]System.Console::WriteLine(string)
IL_0051: ret IL_0051: br.s IL_0068
IL_0052: ldstr "four" IL_0053: ldstr "four"
IL_0057: call void [mscorlib]System.Console::WriteLine(string) IL_0058: call void [mscorlib]System.Console::WriteLine(string)
IL_005c: ret IL_005d: ret
IL_005d: ldstr "default" IL_005e: ldstr "default"
IL_0062: call void [mscorlib]System.Console::WriteLine(string) IL_0063: call void [mscorlib]System.Console::WriteLine(string)
IL_0067: ret IL_0068: ldstr "End of method"
IL_006d: call void [mscorlib]System.Console::WriteLine(string)
IL_0072: ret
} // end of method Switch::SwitchWithGoto } // end of method Switch::SwitchWithGoto
.method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[]
@ -923,7 +925,7 @@
IL_0031: brfalse IL_0119 IL_0031: brfalse IL_0119
IL_0036: volatile. IL_0036: volatile.
IL_0038: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x600000e-1' IL_0038: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x600000e-1'
IL_003d: brtrue.s IL_0094 IL_003d: brtrue.s IL_0094
IL_003f: ldc.i4.6 IL_003f: ldc.i4.6
@ -959,9 +961,9 @@
IL_0088: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0, IL_0088: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::Add(!0,
!1) !1)
IL_008d: volatile. IL_008d: volatile.
IL_008f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x600000e-1' IL_008f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x600000e-1'
IL_0094: volatile. IL_0094: volatile.
IL_0096: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}'::'$$method0x600000e-1' IL_0096: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x600000e-1'
IL_009b: ldloc.s V_6 IL_009b: ldloc.s V_6
IL_009d: ldloca.s V_7 IL_009d: ldloca.s V_7
IL_009f: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0, IL_009f: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32>::TryGetValue(!0,
@ -1031,16 +1033,138 @@
IL_012e: ret IL_012e: ret
} // end of method Switch::SwitchOnStringInForLoop } // end of method Switch::SwitchOnStringInForLoop
.method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed
{
// Code size 130 (0x82)
.maxstack 2
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldlen
IL_0002: conv.i4
IL_0003: brfalse.s IL_000a
IL_0005: ldarg.0
IL_0006: ldc.i4.0
IL_0007: ldelem.ref
IL_0008: br.s IL_000f
IL_000a: ldstr "dummy"
IL_000f: dup
IL_0010: stloc.0
IL_0011: brfalse.s IL_0077
IL_0013: ldloc.0
IL_0014: ldstr "a"
IL_0019: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001e: brtrue.s IL_0049
IL_0020: ldloc.0
IL_0021: ldstr "b"
IL_0026: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002b: brtrue.s IL_0055
IL_002d: ldloc.0
IL_002e: ldstr "c"
IL_0033: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0038: brtrue.s IL_0061
IL_003a: ldloc.0
IL_003b: ldstr "d"
IL_0040: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0045: brtrue.s IL_006d
IL_0047: br.s IL_0077
IL_0049: ldstr "a"
IL_004e: call void [mscorlib]System.Console::WriteLine(string)
IL_0053: br.s IL_0077
IL_0055: ldstr "b"
IL_005a: call void [mscorlib]System.Console::WriteLine(string)
IL_005f: br.s IL_0077
IL_0061: ldstr "c"
IL_0066: call void [mscorlib]System.Console::WriteLine(string)
IL_006b: br.s IL_0077
IL_006d: ldstr "d"
IL_0072: call void [mscorlib]System.Console::WriteLine(string)
IL_0077: ldstr "end"
IL_007c: call void [mscorlib]System.Console::WriteLine(string)
IL_0081: ret
} // end of method Switch::SwitchWithComplexCondition
.method public hidebysig static void SwitchWithArray(string[] args) cil managed
{
// Code size 118 (0x76)
.maxstack 2
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldc.i4.0
IL_0002: ldelem.ref
IL_0003: dup
IL_0004: stloc.0
IL_0005: brfalse.s IL_006b
IL_0007: ldloc.0
IL_0008: ldstr "a"
IL_000d: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0012: brtrue.s IL_003d
IL_0014: ldloc.0
IL_0015: ldstr "b"
IL_001a: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001f: brtrue.s IL_0049
IL_0021: ldloc.0
IL_0022: ldstr "c"
IL_0027: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002c: brtrue.s IL_0055
IL_002e: ldloc.0
IL_002f: ldstr "d"
IL_0034: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0039: brtrue.s IL_0061
IL_003b: br.s IL_006b
IL_003d: ldstr "a"
IL_0042: call void [mscorlib]System.Console::WriteLine(string)
IL_0047: br.s IL_006b
IL_0049: ldstr "b"
IL_004e: call void [mscorlib]System.Console::WriteLine(string)
IL_0053: br.s IL_006b
IL_0055: ldstr "c"
IL_005a: call void [mscorlib]System.Console::WriteLine(string)
IL_005f: br.s IL_006b
IL_0061: ldstr "d"
IL_0066: call void [mscorlib]System.Console::WriteLine(string)
IL_006b: ldstr "end"
IL_0070: call void [mscorlib]System.Console::WriteLine(string)
IL_0075: ret
} // end of method Switch::SwitchWithArray
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}' .class private auto ansi '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'
extends [mscorlib]System.Object extends [mscorlib]System.Object
{ {
.custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 )
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000008-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000008-1'
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000009-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x6000009-1'
.field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x600000e-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2<string,int32> '$$method0x600000e-1'
} // end of class '<PrivateImplementationDetails>{F90E3F03-F070-45F0-AC05-0914EF70B327}' } // end of class '<PrivateImplementationDetails>{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'
// ============================================================= // =============================================================

143
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il

@ -25,14 +25,14 @@
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module Switch.dll .module Switch.dll
// MVID: {C83C2FCD-FA35-4E74-9418-9B91F2C0748A} // MVID: {94058166-F81D-4A82-ABCC-FB400C785214}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x01020000 // Image base: 0x00EF0000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -943,7 +943,7 @@
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed .method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{ {
// Code size 102 (0x66) // Code size 113 (0x71)
.maxstack 2 .maxstack 2
IL_0000: ldstr "SwitchWithGoto: " IL_0000: ldstr "SwitchWithGoto: "
IL_0005: ldarg.0 IL_0005: ldarg.0
@ -958,26 +958,28 @@
IL_002f, IL_002f,
IL_003b, IL_003b,
IL_0045, IL_0045,
IL_0050) IL_0051)
IL_002d: br.s IL_005b IL_002d: br.s IL_005c
IL_002f: ldstr "one" IL_002f: ldstr "one"
IL_0034: call void [mscorlib]System.Console::WriteLine(string) IL_0034: call void [mscorlib]System.Console::WriteLine(string)
IL_0039: br.s IL_005b IL_0039: br.s IL_005c
IL_003b: ldstr "two" IL_003b: ldstr "two"
IL_0040: call void [mscorlib]System.Console::WriteLine(string) IL_0040: call void [mscorlib]System.Console::WriteLine(string)
IL_0045: ldstr "three" IL_0045: ldstr "three"
IL_004a: call void [mscorlib]System.Console::WriteLine(string) IL_004a: call void [mscorlib]System.Console::WriteLine(string)
IL_004f: ret IL_004f: br.s IL_0066
IL_0050: ldstr "four" IL_0051: ldstr "four"
IL_0055: call void [mscorlib]System.Console::WriteLine(string) IL_0056: call void [mscorlib]System.Console::WriteLine(string)
IL_005a: ret IL_005b: ret
IL_005b: ldstr "default" IL_005c: ldstr "default"
IL_0060: call void [mscorlib]System.Console::WriteLine(string) IL_0061: call void [mscorlib]System.Console::WriteLine(string)
IL_0065: ret IL_0066: ldstr "End of method"
IL_006b: call void [mscorlib]System.Console::WriteLine(string)
IL_0070: ret
} // end of method Switch::SwitchWithGoto } // end of method Switch::SwitchWithGoto
.method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[]
@ -1109,6 +1111,121 @@
IL_00e9: ret IL_00e9: ret
} // end of method Switch::SwitchOnStringInForLoop } // end of method Switch::SwitchOnStringInForLoop
.method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed
{
// Code size 126 (0x7e)
.maxstack 2
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldlen
IL_0002: brfalse.s IL_0009
IL_0004: ldarg.0
IL_0005: ldc.i4.0
IL_0006: ldelem.ref
IL_0007: br.s IL_000e
IL_0009: ldstr "dummy"
IL_000e: stloc.0
IL_000f: ldloc.0
IL_0010: ldstr "a"
IL_0015: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001a: brtrue.s IL_0045
IL_001c: ldloc.0
IL_001d: ldstr "b"
IL_0022: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0027: brtrue.s IL_0051
IL_0029: ldloc.0
IL_002a: ldstr "c"
IL_002f: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0034: brtrue.s IL_005d
IL_0036: ldloc.0
IL_0037: ldstr "d"
IL_003c: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0041: brtrue.s IL_0069
IL_0043: br.s IL_0073
IL_0045: ldstr "a"
IL_004a: call void [mscorlib]System.Console::WriteLine(string)
IL_004f: br.s IL_0073
IL_0051: ldstr "b"
IL_0056: call void [mscorlib]System.Console::WriteLine(string)
IL_005b: br.s IL_0073
IL_005d: ldstr "c"
IL_0062: call void [mscorlib]System.Console::WriteLine(string)
IL_0067: br.s IL_0073
IL_0069: ldstr "d"
IL_006e: call void [mscorlib]System.Console::WriteLine(string)
IL_0073: ldstr "end"
IL_0078: call void [mscorlib]System.Console::WriteLine(string)
IL_007d: ret
} // end of method Switch::SwitchWithComplexCondition
.method public hidebysig static void SwitchWithArray(string[] args) cil managed
{
// Code size 115 (0x73)
.maxstack 2
.locals init (string V_0)
IL_0000: ldarg.0
IL_0001: ldc.i4.0
IL_0002: ldelem.ref
IL_0003: stloc.0
IL_0004: ldloc.0
IL_0005: ldstr "a"
IL_000a: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_000f: brtrue.s IL_003a
IL_0011: ldloc.0
IL_0012: ldstr "b"
IL_0017: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001c: brtrue.s IL_0046
IL_001e: ldloc.0
IL_001f: ldstr "c"
IL_0024: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0029: brtrue.s IL_0052
IL_002b: ldloc.0
IL_002c: ldstr "d"
IL_0031: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0036: brtrue.s IL_005e
IL_0038: br.s IL_0068
IL_003a: ldstr "a"
IL_003f: call void [mscorlib]System.Console::WriteLine(string)
IL_0044: br.s IL_0068
IL_0046: ldstr "b"
IL_004b: call void [mscorlib]System.Console::WriteLine(string)
IL_0050: br.s IL_0068
IL_0052: ldstr "c"
IL_0057: call void [mscorlib]System.Console::WriteLine(string)
IL_005c: br.s IL_0068
IL_005e: ldstr "d"
IL_0063: call void [mscorlib]System.Console::WriteLine(string)
IL_0068: ldstr "end"
IL_006d: call void [mscorlib]System.Console::WriteLine(string)
IL_0072: ret
} // end of method Switch::SwitchWithArray
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi sealed '<PrivateImplementationDetails>' .class private auto ansi sealed '<PrivateImplementationDetails>'

144
ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il

@ -25,14 +25,14 @@
.ver 0:0:0:0 .ver 0:0:0:0
} }
.module Switch.dll .module Switch.dll
// MVID: {B5801C4A-C979-4EC9-B5B2-295587FEEF30} // MVID: {1E0E6114-7796-44C6-B88B-AA126D09F561}
.custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 ) .custom instance void [mscorlib]System.Security.UnverifiableCodeAttribute::.ctor() = ( 01 00 00 00 )
.imagebase 0x10000000 .imagebase 0x10000000
.file alignment 0x00000200 .file alignment 0x00000200
.stackreserve 0x00100000 .stackreserve 0x00100000
.subsystem 0x0003 // WINDOWS_CUI .subsystem 0x0003 // WINDOWS_CUI
.corflags 0x00000001 // ILONLY .corflags 0x00000001 // ILONLY
// Image base: 0x005D0000 // Image base: 0x02FE0000
// =============== CLASS MEMBERS DECLARATION =================== // =============== CLASS MEMBERS DECLARATION ===================
@ -1240,7 +1240,7 @@
.method public hidebysig static void SwitchWithGoto(int32 i) cil managed .method public hidebysig static void SwitchWithGoto(int32 i) cil managed
{ {
// Code size 122 (0x7a) // Code size 133 (0x85)
.maxstack 2 .maxstack 2
.locals init (int32 V_0) .locals init (int32 V_0)
IL_0000: nop IL_0000: nop
@ -1285,7 +1285,7 @@
IL_005e: ldstr "four" IL_005e: ldstr "four"
IL_0063: call void [mscorlib]System.Console::WriteLine(string) IL_0063: call void [mscorlib]System.Console::WriteLine(string)
IL_0068: nop IL_0068: nop
IL_0069: br.s IL_0079 IL_0069: br.s IL_0084
IL_006b: nop IL_006b: nop
IL_006c: ldstr "default" IL_006c: ldstr "default"
@ -1293,7 +1293,10 @@
IL_0076: nop IL_0076: nop
IL_0077: br.s IL_0079 IL_0077: br.s IL_0079
IL_0079: ret IL_0079: ldstr "End of method"
IL_007e: call void [mscorlib]System.Console::WriteLine(string)
IL_0083: nop
IL_0084: ret
} // end of method Switch::SwitchWithGoto } // end of method Switch::SwitchWithGoto
.method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[] .method private hidebysig static class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty[]
@ -1459,6 +1462,137 @@
IL_0108: ret IL_0108: ret
} // end of method Switch::SwitchOnStringInForLoop } // end of method Switch::SwitchOnStringInForLoop
.method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed
{
// Code size 134 (0x86)
.maxstack 2
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldlen
IL_0003: brfalse.s IL_000a
IL_0005: ldarg.0
IL_0006: ldc.i4.0
IL_0007: ldelem.ref
IL_0008: br.s IL_000f
IL_000a: ldstr "dummy"
IL_000f: stloc.0
IL_0010: ldloc.0
IL_0011: ldstr "a"
IL_0016: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001b: brtrue.s IL_0046
IL_001d: ldloc.0
IL_001e: ldstr "b"
IL_0023: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0028: brtrue.s IL_0053
IL_002a: ldloc.0
IL_002b: ldstr "c"
IL_0030: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0035: brtrue.s IL_0060
IL_0037: ldloc.0
IL_0038: ldstr "d"
IL_003d: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0042: brtrue.s IL_006d
IL_0044: br.s IL_007a
IL_0046: ldstr "a"
IL_004b: call void [mscorlib]System.Console::WriteLine(string)
IL_0050: nop
IL_0051: br.s IL_007a
IL_0053: ldstr "b"
IL_0058: call void [mscorlib]System.Console::WriteLine(string)
IL_005d: nop
IL_005e: br.s IL_007a
IL_0060: ldstr "c"
IL_0065: call void [mscorlib]System.Console::WriteLine(string)
IL_006a: nop
IL_006b: br.s IL_007a
IL_006d: ldstr "d"
IL_0072: call void [mscorlib]System.Console::WriteLine(string)
IL_0077: nop
IL_0078: br.s IL_007a
IL_007a: ldstr "end"
IL_007f: call void [mscorlib]System.Console::WriteLine(string)
IL_0084: nop
IL_0085: ret
} // end of method Switch::SwitchWithComplexCondition
.method public hidebysig static void SwitchWithArray(string[] args) cil managed
{
// Code size 123 (0x7b)
.maxstack 2
.locals init (string V_0)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: ldc.i4.0
IL_0003: ldelem.ref
IL_0004: stloc.0
IL_0005: ldloc.0
IL_0006: ldstr "a"
IL_000b: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0010: brtrue.s IL_003b
IL_0012: ldloc.0
IL_0013: ldstr "b"
IL_0018: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_001d: brtrue.s IL_0048
IL_001f: ldloc.0
IL_0020: ldstr "c"
IL_0025: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_002a: brtrue.s IL_0055
IL_002c: ldloc.0
IL_002d: ldstr "d"
IL_0032: call bool [mscorlib]System.String::op_Equality(string,
string)
IL_0037: brtrue.s IL_0062
IL_0039: br.s IL_006f
IL_003b: ldstr "a"
IL_0040: call void [mscorlib]System.Console::WriteLine(string)
IL_0045: nop
IL_0046: br.s IL_006f
IL_0048: ldstr "b"
IL_004d: call void [mscorlib]System.Console::WriteLine(string)
IL_0052: nop
IL_0053: br.s IL_006f
IL_0055: ldstr "c"
IL_005a: call void [mscorlib]System.Console::WriteLine(string)
IL_005f: nop
IL_0060: br.s IL_006f
IL_0062: ldstr "d"
IL_0067: call void [mscorlib]System.Console::WriteLine(string)
IL_006c: nop
IL_006d: br.s IL_006f
IL_006f: ldstr "end"
IL_0074: call void [mscorlib]System.Console::WriteLine(string)
IL_0079: nop
IL_007a: ret
} // end of method Switch::SwitchWithArray
} // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch
.class private auto ansi sealed '<PrivateImplementationDetails>' .class private auto ansi sealed '<PrivateImplementationDetails>'

Loading…
Cancel
Save