From c2761b0e0246aeeb4074d93174a218a59c80faa8 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 13 Oct 2017 13:28:11 +0200 Subject: [PATCH] Update test cases for switch. --- .../PrettyTestRunner.cs | 2 +- .../TestCases/Pretty/Switch.cs | 33 +- .../TestCases/Pretty/Switch.il | 807 ++++++++++-------- .../TestCases/Pretty/Switch.opt.il | 529 ++++++------ .../TestCases/Pretty/Switch.opt.roslyn.il | 84 +- .../TestCases/Pretty/Switch.roslyn.il | 785 +++++++++-------- 6 files changed, 1216 insertions(+), 1024 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs index 1acbd0023..6e340a2d3 100644 --- a/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs +++ b/ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs @@ -97,7 +97,7 @@ namespace ICSharpCode.Decompiler.Tests Run(cscOptions: cscOptions); } - [Test, Ignore("unnecessary casts on null literals, control-flow issues with switch in loops, goto, goto case, etc.")] + [Test] public void Switch([ValueSource("defaultOptions")] CompilerOptions cscOptions) { Run(cscOptions: cscOptions); diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs index 53ebea954..45c1c8274 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.cs @@ -213,6 +213,25 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } } + public static string ShortSwitchOverStringWithNullCase(string text) + { + Console.WriteLine("ShortSwitchOverStringWithNullCase: " + text); + switch (text) { + case "First case": { + return "Text1"; + } + case "Second case": { + return "Text2"; + } + case null: { + return "null"; + } + default: { + return "Default"; + } + } + } + public static string SwitchOverString1(string text) { Console.WriteLine("SwitchOverString1: " + text); @@ -248,8 +267,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty public static string SwitchOverString2() { Console.WriteLine("SwitchOverString2:"); - string userName = Environment.UserName; - switch (userName) { + switch (Environment.UserName) { case "First case": { return "Text1"; } @@ -318,10 +336,10 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty Console.WriteLine("two"); break; } - case 3: { - Console.WriteLine("three"); - continue; - } + //case 3: { + // Console.WriteLine("three"); + // continue; + // } case 4: { Console.WriteLine("four"); return; @@ -376,8 +394,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty SetProperty[] properties = Switch.GetProperties(); for (int i = 0; i < properties.Length; i++) { SetProperty setProperty = properties[i]; - string name = setProperty.Property.Name; - switch (name) { + switch (setProperty.Property.Name) { case "Name1": { setProperty.Set = 1; list.Add(setProperty); diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il index 91f9e4ff5..e4f06b1f6 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.il @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly y0cd2lcb +.assembly yojdxjhu { .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. @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module y0cd2lcb.dll -// MVID: {85E7C039-2097-47F9-A636-4F4E3015541A} +.module yojdxjhu.dll +// MVID: {7A918135-BE28-4F14-9240-86E34BA33540} .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: 0x02630000 +// Image base: 0x032F0000 // =============== CLASS MEMBERS DECLARATION =================== @@ -634,6 +634,63 @@ IL_0065: ret } // end of method Switch::ShortSwitchOverString + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 89 (0x59) + .maxstack 2 + .locals init (string V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.1 + IL_0014: ldloc.1 + IL_0015: brfalse.s IL_0045 + + IL_0017: ldloc.1 + IL_0018: ldstr "First case" + IL_001d: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0022: brtrue.s IL_0033 + + IL_0024: ldloc.1 + IL_0025: ldstr "Second case" + IL_002a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002f: brtrue.s IL_003c + + IL_0031: br.s IL_004e + + IL_0033: nop + IL_0034: ldstr "Text1" + IL_0039: stloc.0 + IL_003a: br.s IL_0057 + + IL_003c: nop + IL_003d: ldstr "Text2" + IL_0042: stloc.0 + IL_0043: br.s IL_0057 + + IL_0045: nop + IL_0046: ldstr "null" + IL_004b: stloc.0 + IL_004c: br.s IL_0057 + + IL_004e: nop + IL_004f: ldstr "Default" + IL_0054: stloc.0 + IL_0055: br.s IL_0057 + + IL_0057: ldloc.0 + IL_0058: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + .method public hidebysig static string SwitchOverString1(string text) cil managed { @@ -655,7 +712,7 @@ IL_0015: brfalse IL_00ef IL_001a: volatile. - IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000008-1' + IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x6000009-1' IL_0021: brtrue.s IL_0084 IL_0023: ldc.i4.7 @@ -696,9 +753,9 @@ IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) IL_007d: volatile. - IL_007f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000008-1' + IL_007f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x6000009-1' IL_0084: volatile. - IL_0086: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000008-1' + IL_0086: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x6000009-1' IL_008b: ldloc.1 IL_008c: ldloca.s V_2 IL_008e: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, @@ -763,171 +820,168 @@ .method public hidebysig static string SwitchOverString2() cil managed { - // Code size 368 (0x170) + // Code size 366 (0x16e) .maxstack 4 .locals init (string V_0, string V_1, - string V_2, - int32 V_3) + int32 V_2) IL_0000: nop IL_0001: ldstr "SwitchOverString2:" IL_0006: call void [mscorlib]System.Console::WriteLine(string) IL_000b: nop IL_000c: call string [mscorlib]System.Environment::get_UserName() - IL_0011: stloc.0 - IL_0012: ldloc.0 - IL_0013: stloc.2 - IL_0014: ldloc.2 - IL_0015: brfalse IL_0165 - - IL_001a: volatile. - IL_001c: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000009-1' - IL_0021: brtrue IL_00ba - - IL_0026: ldc.i4.s 11 - IL_0028: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) - IL_002d: dup - IL_002e: ldstr "First case" - IL_0033: ldc.i4.0 - IL_0034: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0011: stloc.1 + IL_0012: ldloc.1 + IL_0013: brfalse IL_0163 + + IL_0018: volatile. + IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x600000a-1' + IL_001f: brtrue IL_00b8 + + IL_0024: ldc.i4.s 11 + IL_0026: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_002b: dup + IL_002c: ldstr "First case" + IL_0031: ldc.i4.0 + IL_0032: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0039: dup - IL_003a: ldstr "Second case" - IL_003f: ldc.i4.1 - IL_0040: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0037: dup + IL_0038: ldstr "Second case" + IL_003d: ldc.i4.1 + IL_003e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0045: dup - IL_0046: ldstr "Third case" - IL_004b: ldc.i4.2 - IL_004c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0043: dup + IL_0044: ldstr "Third case" + IL_0049: ldc.i4.2 + IL_004a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0051: dup - IL_0052: ldstr "Fourth case" - IL_0057: ldc.i4.3 - IL_0058: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_004f: dup + IL_0050: ldstr "Fourth case" + IL_0055: ldc.i4.3 + IL_0056: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_005d: dup - IL_005e: ldstr "Fifth case" - IL_0063: ldc.i4.4 - IL_0064: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_005b: dup + IL_005c: ldstr "Fifth case" + IL_0061: ldc.i4.4 + IL_0062: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0069: dup - IL_006a: ldstr "Sixth case" - IL_006f: ldc.i4.5 - IL_0070: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0067: dup + IL_0068: ldstr "Sixth case" + IL_006d: ldc.i4.5 + IL_006e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0075: dup - IL_0076: ldstr "Seventh case" - IL_007b: ldc.i4.6 - IL_007c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0073: dup + IL_0074: ldstr "Seventh case" + IL_0079: ldc.i4.6 + IL_007a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0081: dup - IL_0082: ldstr "Eighth case" - IL_0087: ldc.i4.7 - IL_0088: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_007f: dup + IL_0080: ldstr "Eighth case" + IL_0085: ldc.i4.7 + IL_0086: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_008d: dup - IL_008e: ldstr "Ninth case" - IL_0093: ldc.i4.8 - IL_0094: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_008b: dup + IL_008c: ldstr "Ninth case" + IL_0091: ldc.i4.8 + IL_0092: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0099: dup - IL_009a: ldstr "Tenth case" - IL_009f: ldc.i4.s 9 - IL_00a1: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0097: dup + IL_0098: ldstr "Tenth case" + IL_009d: ldc.i4.s 9 + IL_009f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_00a6: dup - IL_00a7: ldstr "Eleventh case" - IL_00ac: ldc.i4.s 10 - IL_00ae: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_00a4: dup + IL_00a5: ldstr "Eleventh case" + IL_00aa: ldc.i4.s 10 + IL_00ac: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_00b3: volatile. - IL_00b5: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000009-1' - IL_00ba: volatile. - IL_00bc: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x6000009-1' - IL_00c1: ldloc.2 - IL_00c2: ldloca.s V_3 - IL_00c4: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + IL_00b1: volatile. + IL_00b3: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x600000a-1' + IL_00b8: volatile. + IL_00ba: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x600000a-1' + IL_00bf: ldloc.1 + IL_00c0: ldloca.s V_2 + IL_00c2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, !1&) - IL_00c9: brfalse IL_0165 + IL_00c7: brfalse IL_0163 + + IL_00cc: ldloc.2 + IL_00cd: switch ( + IL_0100, + IL_0109, + IL_0112, + IL_011b, + IL_0124, + IL_012d, + IL_0136, + IL_013f, + IL_0148, + IL_0151, + IL_015a) + IL_00fe: br.s IL_0163 - IL_00ce: ldloc.3 - IL_00cf: switch ( - IL_0102, - IL_010b, - IL_0114, - IL_011d, - IL_0126, - IL_012f, - IL_0138, - IL_0141, - IL_014a, - IL_0153, - IL_015c) - IL_0100: br.s IL_0165 - - IL_0102: nop - IL_0103: ldstr "Text1" - IL_0108: stloc.1 - IL_0109: br.s IL_016e - - IL_010b: nop - IL_010c: ldstr "Text2" - IL_0111: stloc.1 - IL_0112: br.s IL_016e - - IL_0114: nop - IL_0115: ldstr "Text3" - IL_011a: stloc.1 - IL_011b: br.s IL_016e + IL_0100: nop + IL_0101: ldstr "Text1" + IL_0106: stloc.0 + IL_0107: br.s IL_016c - IL_011d: nop - IL_011e: ldstr "Text4" - IL_0123: stloc.1 - IL_0124: br.s IL_016e + IL_0109: nop + IL_010a: ldstr "Text2" + IL_010f: stloc.0 + IL_0110: br.s IL_016c - IL_0126: nop - IL_0127: ldstr "Text5" - IL_012c: stloc.1 - IL_012d: br.s IL_016e - - IL_012f: nop - IL_0130: ldstr "Text6" - IL_0135: stloc.1 - IL_0136: br.s IL_016e - - IL_0138: nop - IL_0139: ldstr "Text7" - IL_013e: stloc.1 - IL_013f: br.s IL_016e - - IL_0141: nop - IL_0142: ldstr "Text8" - IL_0147: stloc.1 - IL_0148: br.s IL_016e - - IL_014a: nop - IL_014b: ldstr "Text9" - IL_0150: stloc.1 - IL_0151: br.s IL_016e - - IL_0153: nop - IL_0154: ldstr "Text10" - IL_0159: stloc.1 - IL_015a: br.s IL_016e - - IL_015c: nop - IL_015d: ldstr "Text11" - IL_0162: stloc.1 - IL_0163: br.s IL_016e - - IL_0165: nop - IL_0166: ldstr "Default" - IL_016b: stloc.1 - IL_016c: br.s IL_016e - - IL_016e: ldloc.1 - IL_016f: ret + IL_0112: nop + IL_0113: ldstr "Text3" + IL_0118: stloc.0 + IL_0119: br.s IL_016c + + IL_011b: nop + IL_011c: ldstr "Text4" + IL_0121: stloc.0 + IL_0122: br.s IL_016c + + IL_0124: nop + IL_0125: ldstr "Text5" + IL_012a: stloc.0 + IL_012b: br.s IL_016c + + IL_012d: nop + IL_012e: ldstr "Text6" + IL_0133: stloc.0 + IL_0134: br.s IL_016c + + IL_0136: nop + IL_0137: ldstr "Text7" + IL_013c: stloc.0 + IL_013d: br.s IL_016c + + IL_013f: nop + IL_0140: ldstr "Text8" + IL_0145: stloc.0 + IL_0146: br.s IL_016c + + IL_0148: nop + IL_0149: ldstr "Text9" + IL_014e: stloc.0 + IL_014f: br.s IL_016c + + IL_0151: nop + IL_0152: ldstr "Text10" + IL_0157: stloc.0 + IL_0158: br.s IL_016c + + IL_015a: nop + IL_015b: ldstr "Text11" + IL_0160: stloc.0 + IL_0161: br.s IL_016c + + IL_0163: nop + IL_0164: ldstr "Default" + IL_0169: stloc.0 + IL_016a: br.s IL_016c + + IL_016c: ldloc.0 + IL_016d: ret } // end of method Switch::SwitchOverString2 .method public hidebysig static string @@ -974,7 +1028,7 @@ .method public hidebysig static void SwitchInLoop(int32 i) cil managed { - // Code size 146 (0x92) + // Code size 132 (0x84) .maxstack 2 .locals init (int32 V_0, bool V_1) @@ -986,7 +1040,7 @@ object) IL_0011: call void [mscorlib]System.Console::WriteLine(string) IL_0016: nop - IL_0017: br.s IL_008d + IL_0017: br.s IL_007f IL_0019: nop IL_001a: ldarg.0 @@ -997,53 +1051,47 @@ IL_001f: switch ( IL_0036, IL_0044, - IL_0052, - IL_0060) - IL_0034: br.s IL_006e + IL_0060, + IL_0052) + IL_0034: br.s IL_0060 IL_0036: nop IL_0037: ldstr "one" IL_003c: call void [mscorlib]System.Console::WriteLine(string) IL_0041: nop - IL_0042: br.s IL_0087 + IL_0042: br.s IL_0079 IL_0044: nop IL_0045: ldstr "two" IL_004a: call void [mscorlib]System.Console::WriteLine(string) IL_004f: nop - IL_0050: br.s IL_0087 + IL_0050: br.s IL_0079 IL_0052: nop - IL_0053: ldstr "three" + IL_0053: ldstr "four" IL_0058: call void [mscorlib]System.Console::WriteLine(string) IL_005d: nop - IL_005e: br.s IL_008d + IL_005e: br.s IL_0083 IL_0060: nop - IL_0061: ldstr "four" + IL_0061: ldstr "default" IL_0066: call void [mscorlib]System.Console::WriteLine(string) IL_006b: nop - IL_006c: br.s IL_0091 - - IL_006e: nop - IL_006f: ldstr "default" - IL_0074: call void [mscorlib]System.Console::WriteLine(string) - IL_0079: nop - IL_007a: ldstr "more code" - IL_007f: call void [mscorlib]System.Console::WriteLine(string) - IL_0084: nop - IL_0085: br.s IL_0091 - - IL_0087: ldarg.0 - IL_0088: ldc.i4.1 - IL_0089: add - IL_008a: starg.s i - IL_008c: nop - IL_008d: ldc.i4.1 - IL_008e: stloc.1 - IL_008f: br.s IL_0019 - - IL_0091: ret + IL_006c: ldstr "more code" + IL_0071: call void [mscorlib]System.Console::WriteLine(string) + IL_0076: nop + IL_0077: br.s IL_0083 + + IL_0079: ldarg.0 + IL_007a: ldc.i4.1 + IL_007b: add + IL_007c: starg.s i + IL_007e: nop + IL_007f: ldc.i4.1 + IL_0080: stloc.1 + IL_0081: br.s IL_0019 + + IL_0083: ret } // end of method Switch::SwitchInLoop .method public hidebysig static void SwitchWithGoto(int32 i) cil managed @@ -1125,7 +1173,7 @@ .method public hidebysig static void SwitchOnStringInForLoop() cil managed { - // Code size 334 (0x14e) + // Code size 330 (0x14a) .maxstack 4 .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, class [mscorlib]System.Collections.Generic.List`1 V_1, @@ -1133,9 +1181,8 @@ int32 V_3, class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty V_4, string V_5, - string V_6, - int32 V_7, - bool V_8) + int32 V_6, + bool V_7) IL_0000: nop IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() IL_0006: stloc.0 @@ -1145,7 +1192,7 @@ IL_0012: stloc.2 IL_0013: ldc.i4.0 IL_0014: stloc.3 - IL_0015: br IL_013e + IL_0015: br IL_013a IL_001a: nop IL_001b: ldloc.2 @@ -1157,144 +1204,142 @@ IL_0027: callvirt instance string [mscorlib]System.Reflection.MemberInfo::get_Name() IL_002c: stloc.s V_5 IL_002e: ldloc.s V_5 - IL_0030: stloc.s V_6 - IL_0032: ldloc.s V_6 - IL_0034: brfalse IL_012d - - IL_0039: volatile. - IL_003b: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x600000e-1' - IL_0040: brtrue.s IL_0097 - - IL_0042: ldc.i4.6 - IL_0043: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) - IL_0048: dup - IL_0049: ldstr "Name1" - IL_004e: ldc.i4.0 - IL_004f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0030: brfalse IL_0129 + + IL_0035: volatile. + IL_0037: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x600000f-1' + IL_003c: brtrue.s IL_0093 + + IL_003e: ldc.i4.6 + IL_003f: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0044: dup + IL_0045: ldstr "Name1" + IL_004a: ldc.i4.0 + IL_004b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0054: dup - IL_0055: ldstr "Name2" - IL_005a: ldc.i4.1 - IL_005b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0050: dup + IL_0051: ldstr "Name2" + IL_0056: ldc.i4.1 + IL_0057: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0060: dup - IL_0061: ldstr "Name3" - IL_0066: ldc.i4.2 - IL_0067: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_005c: dup + IL_005d: ldstr "Name3" + IL_0062: ldc.i4.2 + IL_0063: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_006c: dup - IL_006d: ldstr "Name4" - IL_0072: ldc.i4.3 - IL_0073: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0068: dup + IL_0069: ldstr "Name4" + IL_006e: ldc.i4.3 + IL_006f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0078: dup - IL_0079: ldstr "Name5" - IL_007e: ldc.i4.4 - IL_007f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0074: dup + IL_0075: ldstr "Name5" + IL_007a: ldc.i4.4 + IL_007b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0084: dup - IL_0085: ldstr "Name6" - IL_008a: ldc.i4.5 - IL_008b: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0080: dup + IL_0081: ldstr "Name6" + IL_0086: ldc.i4.5 + IL_0087: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0090: volatile. - IL_0092: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x600000e-1' - IL_0097: volatile. - IL_0099: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{85E7C039-2097-47F9-A636-4F4E3015541A}'::'$$method0x600000e-1' - IL_009e: ldloc.s V_6 - IL_00a0: ldloca.s V_7 - IL_00a2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + IL_008c: volatile. + IL_008e: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x600000f-1' + IL_0093: volatile. + IL_0095: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{7A918135-BE28-4F14-9240-86E34BA33540}'::'$$method0x600000f-1' + IL_009a: ldloc.s V_5 + IL_009c: ldloca.s V_6 + IL_009e: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, !1&) - IL_00a7: brfalse IL_012d - - IL_00ac: ldloc.s V_7 - IL_00ae: switch ( - IL_00cd, - IL_00e2, - IL_00f7, - IL_010c, - IL_0121, - IL_0121) - IL_00cb: br.s IL_012d - - IL_00cd: nop - IL_00ce: ldloc.s V_4 - IL_00d0: ldc.i4.1 - IL_00d1: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00d6: nop - IL_00d7: ldloc.0 - IL_00d8: ldloc.s V_4 - IL_00da: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00df: nop - IL_00e0: br.s IL_0139 - - IL_00e2: nop - IL_00e3: ldloc.s V_4 - IL_00e5: ldc.i4.2 - IL_00e6: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00eb: nop - IL_00ec: ldloc.0 - IL_00ed: ldloc.s V_4 - IL_00ef: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00f4: nop - IL_00f5: br.s IL_0139 - - IL_00f7: nop - IL_00f8: ldloc.s V_4 - IL_00fa: ldc.i4.3 - IL_00fb: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_0100: nop - IL_0101: ldloc.0 - IL_0102: ldloc.s V_4 - IL_0104: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0109: nop - IL_010a: br.s IL_0139 - - IL_010c: nop - IL_010d: ldloc.s V_4 - IL_010f: ldc.i4.4 - IL_0110: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_0115: nop - IL_0116: ldloc.0 - IL_0117: ldloc.s V_4 - IL_0119: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_011e: nop - IL_011f: br.s IL_0139 - - IL_0121: nop - IL_0122: ldloc.0 - IL_0123: ldloc.s V_4 - IL_0125: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_012a: nop - IL_012b: br.s IL_0139 - - IL_012d: nop - IL_012e: ldloc.1 - IL_012f: ldloc.s V_4 - IL_0131: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0136: nop - IL_0137: br.s IL_0139 + IL_00a3: brfalse IL_0129 + + IL_00a8: ldloc.s V_6 + IL_00aa: switch ( + IL_00c9, + IL_00de, + IL_00f3, + IL_0108, + IL_011d, + IL_011d) + IL_00c7: br.s IL_0129 + + IL_00c9: nop + IL_00ca: ldloc.s V_4 + IL_00cc: ldc.i4.1 + IL_00cd: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00d2: nop + IL_00d3: ldloc.0 + IL_00d4: ldloc.s V_4 + IL_00d6: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00db: nop + IL_00dc: br.s IL_0135 + + IL_00de: nop + IL_00df: ldloc.s V_4 + IL_00e1: ldc.i4.2 + IL_00e2: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00e7: nop + IL_00e8: ldloc.0 + IL_00e9: ldloc.s V_4 + IL_00eb: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00f0: nop + IL_00f1: br.s IL_0135 + + IL_00f3: nop + IL_00f4: ldloc.s V_4 + IL_00f6: ldc.i4.3 + IL_00f7: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00fc: nop + IL_00fd: ldloc.0 + IL_00fe: ldloc.s V_4 + IL_0100: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0105: nop + IL_0106: br.s IL_0135 + + IL_0108: nop + IL_0109: ldloc.s V_4 + IL_010b: ldc.i4.4 + IL_010c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_0111: nop + IL_0112: ldloc.0 + IL_0113: ldloc.s V_4 + IL_0115: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_011a: nop + IL_011b: br.s IL_0135 - IL_0139: nop + IL_011d: nop + IL_011e: ldloc.0 + IL_011f: ldloc.s V_4 + IL_0121: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0126: nop + IL_0127: br.s IL_0135 + + IL_0129: nop + IL_012a: ldloc.1 + IL_012b: ldloc.s V_4 + IL_012d: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0132: nop + IL_0133: br.s IL_0135 + + IL_0135: nop + IL_0136: ldloc.3 + IL_0137: ldc.i4.1 + IL_0138: add + IL_0139: stloc.3 IL_013a: ldloc.3 - IL_013b: ldc.i4.1 - IL_013c: add - IL_013d: stloc.3 - IL_013e: ldloc.3 - IL_013f: ldloc.2 - IL_0140: ldlen - IL_0141: conv.i4 - IL_0142: clt - IL_0144: stloc.s V_8 - IL_0146: ldloc.s V_8 - IL_0148: brtrue IL_001a - - IL_014d: ret + IL_013b: ldloc.2 + IL_013c: ldlen + IL_013d: conv.i4 + IL_013e: clt + IL_0140: stloc.s V_7 + IL_0142: ldloc.s V_7 + IL_0144: brtrue IL_001a + + IL_0149: ret } // end of method Switch::SwitchOnStringInForLoop .method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed { - // Code size 139 (0x8b) + // Code size 143 (0x8f) .maxstack 2 .locals init (string V_0) IL_0000: nop @@ -1312,7 +1357,7 @@ IL_0010: nop IL_0011: stloc.0 IL_0012: ldloc.0 - IL_0013: brfalse.s IL_007f + IL_0013: brfalse.s IL_0083 IL_0015: ldloc.0 IL_0016: ldstr "a" @@ -1324,51 +1369,55 @@ IL_0023: ldstr "b" IL_0028: call bool [mscorlib]System.String::op_Equality(string, string) - IL_002d: brtrue.s IL_0058 + IL_002d: brtrue.s IL_0059 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_003a: brtrue.s IL_0067 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 + IL_0047: brtrue.s IL_0075 + + IL_0049: br.s IL_0083 + + IL_004b: nop + IL_004c: ldstr "a" + IL_0051: call void [mscorlib]System.Console::WriteLine(string) + IL_0056: nop + IL_0057: br.s IL_0083 + + IL_0059: nop + IL_005a: ldstr "b" + IL_005f: call void [mscorlib]System.Console::WriteLine(string) + IL_0064: nop + IL_0065: br.s IL_0083 + + IL_0067: nop + IL_0068: ldstr "c" + IL_006d: call void [mscorlib]System.Console::WriteLine(string) + IL_0072: nop + IL_0073: br.s IL_0083 + + IL_0075: nop + IL_0076: ldstr "d" + IL_007b: call void [mscorlib]System.Console::WriteLine(string) + IL_0080: nop + IL_0081: br.s IL_0083 + + IL_0083: ldstr "end" + IL_0088: call void [mscorlib]System.Console::WriteLine(string) + IL_008d: nop + IL_008e: ret } // end of method Switch::SwitchWithComplexCondition .method public hidebysig static void SwitchWithArray(string[] args) cil managed { - // Code size 126 (0x7e) + // Code size 130 (0x82) .maxstack 2 .locals init (string V_0) IL_0000: nop @@ -1377,7 +1426,7 @@ IL_0003: ldelem.ref IL_0004: stloc.0 IL_0005: ldloc.0 - IL_0006: brfalse.s IL_0072 + IL_0006: brfalse.s IL_0076 IL_0008: ldloc.0 IL_0009: ldstr "a" @@ -1389,58 +1438,62 @@ IL_0016: ldstr "b" IL_001b: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0020: brtrue.s IL_004b + IL_0020: brtrue.s IL_004c 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_002d: brtrue.s IL_005a 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 + IL_003a: brtrue.s IL_0068 + + IL_003c: br.s IL_0076 + + IL_003e: nop + IL_003f: ldstr "a" + IL_0044: call void [mscorlib]System.Console::WriteLine(string) + IL_0049: nop + IL_004a: br.s IL_0076 + + IL_004c: nop + IL_004d: ldstr "b" + IL_0052: call void [mscorlib]System.Console::WriteLine(string) + IL_0057: nop + IL_0058: br.s IL_0076 + + IL_005a: nop + IL_005b: ldstr "c" + IL_0060: call void [mscorlib]System.Console::WriteLine(string) + IL_0065: nop + IL_0066: br.s IL_0076 + + IL_0068: nop + IL_0069: ldstr "d" + IL_006e: call void [mscorlib]System.Console::WriteLine(string) + IL_0073: nop + IL_0074: br.s IL_0076 + + IL_0076: ldstr "end" + IL_007b: call void [mscorlib]System.Console::WriteLine(string) + IL_0080: nop + IL_0081: ret } // end of method Switch::SwitchWithArray } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch -.class private auto ansi '{85E7C039-2097-47F9-A636-4F4E3015541A}' +.class private auto ansi '{7A918135-BE28-4F14-9240-86E34BA33540}' extends [mscorlib]System.Object { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x6000008-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x6000009-1' - .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000e-1' -} // end of class '{85E7C039-2097-47F9-A636-4F4E3015541A}' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000a-1' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000f-1' +} // end of class '{7A918135-BE28-4F14-9240-86E34BA33540}' // ============================================================= diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il index 85eea31f3..c951dbce9 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.il @@ -10,7 +10,7 @@ .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4.. .ver 4:0:0:0 } -.assembly nwkzngd2 +.assembly '4wc22bae' { .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. @@ -20,15 +20,15 @@ .hash algorithm 0x00008004 .ver 0:0:0:0 } -.module nwkzngd2.dll -// MVID: {2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5} +.module '4wc22bae.dll' +// MVID: {B84EA70D-C67F-455B-9708-0E39585F7DA1} .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: 0x008E0000 +// Image base: 0x01140000 // =============== CLASS MEMBERS DECLARATION =================== @@ -509,6 +509,49 @@ IL_0055: ret } // end of method Switch::ShortSwitchOverString + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 73 (0x49) + .maxstack 2 + .locals init (string V_0) + IL_0000: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: dup + IL_0012: stloc.0 + IL_0013: brfalse.s IL_003d + + IL_0015: ldloc.0 + IL_0016: ldstr "First case" + IL_001b: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0020: brtrue.s IL_0031 + + IL_0022: ldloc.0 + IL_0023: ldstr "Second case" + IL_0028: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002d: brtrue.s IL_0037 + + IL_002f: br.s IL_0043 + + IL_0031: ldstr "Text1" + IL_0036: ret + + IL_0037: ldstr "Text2" + IL_003c: ret + + IL_003d: ldstr "null" + IL_0042: ret + + IL_0043: ldstr "Default" + IL_0048: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + .method public hidebysig static string SwitchOverString1(string text) cil managed { @@ -527,7 +570,7 @@ IL_0013: brfalse IL_00db IL_0018: volatile. - IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000008-1' + IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x6000009-1' IL_001f: brtrue.s IL_0082 IL_0021: ldc.i4.7 @@ -568,9 +611,9 @@ IL_0076: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) IL_007b: volatile. - IL_007d: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000008-1' + IL_007d: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x6000009-1' IL_0082: volatile. - IL_0084: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000008-1' + IL_0084: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x6000009-1' IL_0089: ldloc.0 IL_008a: ldloca.s V_1 IL_008c: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, @@ -616,141 +659,138 @@ .method public hidebysig static string SwitchOverString2() cil managed { - // Code size 325 (0x145) + // Code size 323 (0x143) .maxstack 4 .locals init (string V_0, - string V_1, - int32 V_2) + int32 V_1) IL_0000: ldstr "SwitchOverString2:" IL_0005: call void [mscorlib]System.Console::WriteLine(string) IL_000a: call string [mscorlib]System.Environment::get_UserName() - IL_000f: stloc.0 - IL_0010: ldloc.0 - IL_0011: dup - IL_0012: stloc.1 - IL_0013: brfalse IL_013f - - IL_0018: volatile. - IL_001a: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000009-1' - IL_001f: brtrue IL_00b8 - - IL_0024: ldc.i4.s 11 - IL_0026: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) - IL_002b: dup - IL_002c: ldstr "First case" - IL_0031: ldc.i4.0 - IL_0032: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_000f: dup + IL_0010: stloc.0 + IL_0011: brfalse IL_013d + + IL_0016: volatile. + IL_0018: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x600000a-1' + IL_001d: brtrue IL_00b6 + + IL_0022: ldc.i4.s 11 + IL_0024: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0029: dup + IL_002a: ldstr "First case" + IL_002f: ldc.i4.0 + IL_0030: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0037: dup - IL_0038: ldstr "Second case" - IL_003d: ldc.i4.1 - IL_003e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0035: dup + IL_0036: ldstr "Second case" + IL_003b: ldc.i4.1 + IL_003c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0043: dup - IL_0044: ldstr "Third case" - IL_0049: ldc.i4.2 - IL_004a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0041: dup + IL_0042: ldstr "Third case" + IL_0047: ldc.i4.2 + IL_0048: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_004f: dup - IL_0050: ldstr "Fourth case" - IL_0055: ldc.i4.3 - IL_0056: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_004d: dup + IL_004e: ldstr "Fourth case" + IL_0053: ldc.i4.3 + IL_0054: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_005b: dup - IL_005c: ldstr "Fifth case" - IL_0061: ldc.i4.4 - IL_0062: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0059: dup + IL_005a: ldstr "Fifth case" + IL_005f: ldc.i4.4 + IL_0060: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0067: dup - IL_0068: ldstr "Sixth case" - IL_006d: ldc.i4.5 - IL_006e: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0065: dup + IL_0066: ldstr "Sixth case" + IL_006b: ldc.i4.5 + IL_006c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0073: dup - IL_0074: ldstr "Seventh case" - IL_0079: ldc.i4.6 - IL_007a: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0071: dup + IL_0072: ldstr "Seventh case" + IL_0077: ldc.i4.6 + IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_007f: dup - IL_0080: ldstr "Eighth case" - IL_0085: ldc.i4.7 - IL_0086: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_007d: dup + IL_007e: ldstr "Eighth case" + IL_0083: ldc.i4.7 + IL_0084: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_008b: dup - IL_008c: ldstr "Ninth case" - IL_0091: ldc.i4.8 - IL_0092: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0089: dup + IL_008a: ldstr "Ninth case" + IL_008f: ldc.i4.8 + IL_0090: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0097: dup - IL_0098: ldstr "Tenth case" - IL_009d: ldc.i4.s 9 - IL_009f: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0095: dup + IL_0096: ldstr "Tenth case" + IL_009b: ldc.i4.s 9 + IL_009d: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_00a4: dup - IL_00a5: ldstr "Eleventh case" - IL_00aa: ldc.i4.s 10 - IL_00ac: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_00a2: dup + IL_00a3: ldstr "Eleventh case" + IL_00a8: ldc.i4.s 10 + IL_00aa: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_00b1: volatile. - IL_00b3: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000009-1' - IL_00b8: volatile. - IL_00ba: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x6000009-1' - IL_00bf: ldloc.1 - IL_00c0: ldloca.s V_2 - IL_00c2: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + IL_00af: volatile. + IL_00b1: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x600000a-1' + IL_00b6: volatile. + IL_00b8: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x600000a-1' + IL_00bd: ldloc.0 + IL_00be: ldloca.s V_1 + IL_00c0: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, !1&) - IL_00c7: brfalse.s IL_013f + IL_00c5: brfalse.s IL_013d - IL_00c9: ldloc.2 - IL_00ca: switch ( - IL_00fd, - IL_0103, - IL_0109, - IL_010f, - IL_0115, - IL_011b, - IL_0121, - IL_0127, - IL_012d, - IL_0133, - IL_0139) - IL_00fb: br.s IL_013f + IL_00c7: ldloc.1 + IL_00c8: switch ( + IL_00fb, + IL_0101, + IL_0107, + IL_010d, + IL_0113, + IL_0119, + IL_011f, + IL_0125, + IL_012b, + IL_0131, + IL_0137) + IL_00f9: br.s IL_013d - IL_00fd: ldstr "Text1" - IL_0102: ret + IL_00fb: ldstr "Text1" + IL_0100: ret - IL_0103: ldstr "Text2" - IL_0108: ret + IL_0101: ldstr "Text2" + IL_0106: ret - IL_0109: ldstr "Text3" - IL_010e: ret + IL_0107: ldstr "Text3" + IL_010c: ret - IL_010f: ldstr "Text4" - IL_0114: ret + IL_010d: ldstr "Text4" + IL_0112: ret - IL_0115: ldstr "Text5" - IL_011a: ret + IL_0113: ldstr "Text5" + IL_0118: ret - IL_011b: ldstr "Text6" - IL_0120: ret + IL_0119: ldstr "Text6" + IL_011e: ret - IL_0121: ldstr "Text7" - IL_0126: ret + IL_011f: ldstr "Text7" + IL_0124: ret - IL_0127: ldstr "Text8" - IL_012c: ret + IL_0125: ldstr "Text8" + IL_012a: ret - IL_012d: ldstr "Text9" - IL_0132: ret + IL_012b: ldstr "Text9" + IL_0130: ret - IL_0133: ldstr "Text10" - IL_0138: ret + IL_0131: ldstr "Text10" + IL_0136: ret - IL_0139: ldstr "Text11" - IL_013e: ret + IL_0137: ldstr "Text11" + IL_013c: ret - IL_013f: ldstr "Default" - IL_0144: ret + IL_013d: ldstr "Default" + IL_0142: ret } // end of method Switch::SwitchOverString2 .method public hidebysig static string @@ -785,7 +825,7 @@ .method public hidebysig static void SwitchInLoop(int32 i) cil managed { - // Code size 124 (0x7c) + // Code size 112 (0x70) .maxstack 2 .locals init (int32 V_0) IL_0000: ldstr "SwitchInLoop: " @@ -802,37 +842,33 @@ IL_001a: switch ( IL_0031, IL_003d, - IL_0049, - IL_0055) - IL_002f: br.s IL_0060 + IL_0054, + IL_0049) + IL_002f: br.s IL_0054 IL_0031: ldstr "one" IL_0036: call void [mscorlib]System.Console::WriteLine(string) - IL_003b: br.s IL_0075 + IL_003b: br.s IL_0069 IL_003d: ldstr "two" IL_0042: call void [mscorlib]System.Console::WriteLine(string) - IL_0047: br.s IL_0075 + IL_0047: br.s IL_0069 - IL_0049: ldstr "three" + IL_0049: ldstr "four" IL_004e: call void [mscorlib]System.Console::WriteLine(string) - IL_0053: br.s IL_0015 + IL_0053: ret - IL_0055: ldstr "four" - IL_005a: call void [mscorlib]System.Console::WriteLine(string) - IL_005f: ret - - IL_0060: ldstr "default" - IL_0065: call void [mscorlib]System.Console::WriteLine(string) - IL_006a: ldstr "more code" - IL_006f: call void [mscorlib]System.Console::WriteLine(string) - IL_0074: ret - - IL_0075: ldarg.0 - IL_0076: ldc.i4.1 - IL_0077: add - IL_0078: starg.s i - IL_007a: br.s IL_0015 + IL_0054: ldstr "default" + IL_0059: call void [mscorlib]System.Console::WriteLine(string) + IL_005e: ldstr "more code" + IL_0063: call void [mscorlib]System.Console::WriteLine(string) + IL_0068: ret + + IL_0069: ldarg.0 + IL_006a: ldc.i4.1 + IL_006b: add + IL_006c: starg.s i + IL_006e: br.s IL_0015 } // end of method Switch::SwitchInLoop .method public hidebysig static void SwitchWithGoto(int32 i) cil managed @@ -891,7 +927,7 @@ .method public hidebysig static void SwitchOnStringInForLoop() cil managed { - // Code size 303 (0x12f) + // Code size 299 (0x12b) .maxstack 4 .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, class [mscorlib]System.Collections.Generic.List`1 V_1, @@ -899,8 +935,7 @@ int32 V_3, class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty V_4, string V_5, - string V_6, - int32 V_7) + int32 V_6) IL_0000: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() IL_0005: stloc.0 IL_0006: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() @@ -909,7 +944,7 @@ IL_0011: stloc.2 IL_0012: ldc.i4.0 IL_0013: stloc.3 - IL_0014: br IL_0125 + IL_0014: br IL_0121 IL_0019: ldloc.2 IL_001a: ldloc.3 @@ -918,119 +953,117 @@ IL_001e: ldloc.s V_4 IL_0020: ldfld class [mscorlib]System.Reflection.PropertyInfo ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::Property IL_0025: callvirt instance string [mscorlib]System.Reflection.MemberInfo::get_Name() - IL_002a: stloc.s V_5 - IL_002c: ldloc.s V_5 - IL_002e: dup - IL_002f: stloc.s V_6 - IL_0031: brfalse IL_0119 - - IL_0036: volatile. - IL_0038: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x600000e-1' - IL_003d: brtrue.s IL_0094 - - IL_003f: ldc.i4.6 - IL_0040: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) - IL_0045: dup - IL_0046: ldstr "Name1" - IL_004b: ldc.i4.0 - IL_004c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_002a: dup + IL_002b: stloc.s V_5 + IL_002d: brfalse IL_0115 + + IL_0032: volatile. + IL_0034: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x600000f-1' + IL_0039: brtrue.s IL_0090 + + IL_003b: ldc.i4.6 + IL_003c: newobj instance void class [mscorlib]System.Collections.Generic.Dictionary`2::.ctor(int32) + IL_0041: dup + IL_0042: ldstr "Name1" + IL_0047: ldc.i4.0 + IL_0048: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0051: dup - IL_0052: ldstr "Name2" - IL_0057: ldc.i4.1 - IL_0058: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_004d: dup + IL_004e: ldstr "Name2" + IL_0053: ldc.i4.1 + IL_0054: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_005d: dup - IL_005e: ldstr "Name3" - IL_0063: ldc.i4.2 - IL_0064: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0059: dup + IL_005a: ldstr "Name3" + IL_005f: ldc.i4.2 + IL_0060: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0069: dup - IL_006a: ldstr "Name4" - IL_006f: ldc.i4.3 - IL_0070: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0065: dup + IL_0066: ldstr "Name4" + IL_006b: ldc.i4.3 + IL_006c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0075: dup - IL_0076: ldstr "Name5" - IL_007b: ldc.i4.4 - IL_007c: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_0071: dup + IL_0072: ldstr "Name5" + IL_0077: ldc.i4.4 + IL_0078: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_0081: dup - IL_0082: ldstr "Name6" - IL_0087: ldc.i4.5 - IL_0088: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, + IL_007d: dup + IL_007e: ldstr "Name6" + IL_0083: ldc.i4.5 + IL_0084: call instance void class [mscorlib]System.Collections.Generic.Dictionary`2::Add(!0, !1) - IL_008d: volatile. - IL_008f: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x600000e-1' - IL_0094: volatile. - IL_0096: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}'::'$$method0x600000e-1' - IL_009b: ldloc.s V_6 - IL_009d: ldloca.s V_7 - IL_009f: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, + IL_0089: volatile. + IL_008b: stsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x600000f-1' + IL_0090: volatile. + IL_0092: ldsfld class [mscorlib]System.Collections.Generic.Dictionary`2 '{B84EA70D-C67F-455B-9708-0E39585F7DA1}'::'$$method0x600000f-1' + IL_0097: ldloc.s V_5 + IL_0099: ldloca.s V_6 + IL_009b: call instance bool class [mscorlib]System.Collections.Generic.Dictionary`2::TryGetValue(!0, !1&) - IL_00a4: brfalse.s IL_0119 - - IL_00a6: ldloc.s V_7 - IL_00a8: switch ( - IL_00c7, - IL_00d9, - IL_00eb, - IL_00fd, - IL_010f, - IL_010f) - IL_00c5: br.s IL_0119 - - IL_00c7: ldloc.s V_4 - IL_00c9: ldc.i4.1 - IL_00ca: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00cf: ldloc.0 - IL_00d0: ldloc.s V_4 - IL_00d2: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00d7: br.s IL_0121 - - IL_00d9: ldloc.s V_4 - IL_00db: ldc.i4.2 - IL_00dc: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00e1: ldloc.0 - IL_00e2: ldloc.s V_4 - IL_00e4: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00e9: br.s IL_0121 - - IL_00eb: ldloc.s V_4 - IL_00ed: ldc.i4.3 - IL_00ee: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00f3: ldloc.0 - IL_00f4: ldloc.s V_4 - IL_00f6: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00fb: br.s IL_0121 - - IL_00fd: ldloc.s V_4 - IL_00ff: ldc.i4.4 - IL_0100: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_0105: ldloc.0 - IL_0106: ldloc.s V_4 - IL_0108: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_010d: br.s IL_0121 - - IL_010f: ldloc.0 - IL_0110: ldloc.s V_4 - IL_0112: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_0117: br.s IL_0121 - - IL_0119: ldloc.1 - IL_011a: ldloc.s V_4 - IL_011c: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00a0: brfalse.s IL_0115 + + IL_00a2: ldloc.s V_6 + IL_00a4: switch ( + IL_00c3, + IL_00d5, + IL_00e7, + IL_00f9, + IL_010b, + IL_010b) + IL_00c1: br.s IL_0115 + + IL_00c3: ldloc.s V_4 + IL_00c5: ldc.i4.1 + IL_00c6: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00cb: ldloc.0 + IL_00cc: ldloc.s V_4 + IL_00ce: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00d3: br.s IL_011d + + IL_00d5: ldloc.s V_4 + IL_00d7: ldc.i4.2 + IL_00d8: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00dd: ldloc.0 + IL_00de: ldloc.s V_4 + IL_00e0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00e5: br.s IL_011d + + IL_00e7: ldloc.s V_4 + IL_00e9: ldc.i4.3 + IL_00ea: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00ef: ldloc.0 + IL_00f0: ldloc.s V_4 + IL_00f2: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00f7: br.s IL_011d + + IL_00f9: ldloc.s V_4 + IL_00fb: ldc.i4.4 + IL_00fc: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_0101: ldloc.0 + IL_0102: ldloc.s V_4 + IL_0104: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0109: br.s IL_011d + + IL_010b: ldloc.0 + IL_010c: ldloc.s V_4 + IL_010e: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0113: br.s IL_011d + + IL_0115: ldloc.1 + IL_0116: ldloc.s V_4 + IL_0118: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_011d: ldloc.3 + IL_011e: ldc.i4.1 + IL_011f: add + IL_0120: stloc.3 IL_0121: ldloc.3 - IL_0122: ldc.i4.1 - IL_0123: add - IL_0124: stloc.3 - IL_0125: ldloc.3 - IL_0126: ldloc.2 - IL_0127: ldlen - IL_0128: conv.i4 - IL_0129: blt IL_0019 - - IL_012e: ret + IL_0122: ldloc.2 + IL_0123: ldlen + IL_0124: conv.i4 + IL_0125: blt IL_0019 + + IL_012a: ret } // end of method Switch::SwitchOnStringInForLoop .method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed @@ -1157,14 +1190,14 @@ } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch -.class private auto ansi '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}' +.class private auto ansi '{B84EA70D-C67F-455B-9708-0E39585F7DA1}' extends [mscorlib]System.Object { .custom instance void [mscorlib]System.Runtime.CompilerServices.CompilerGeneratedAttribute::.ctor() = ( 01 00 00 00 ) - .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x6000008-1' .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x6000009-1' - .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000e-1' -} // end of class '{2FE2A6DB-2DD1-4526-BE2D-8029A91D5DA5}' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000a-1' + .field static assembly class [mscorlib]System.Collections.Generic.Dictionary`2 '$$method0x600000f-1' +} // end of class '{B84EA70D-C67F-455B-9708-0E39585F7DA1}' // ============================================================= diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il index c28f0e721..00d6cacd1 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.opt.roslyn.il @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module Switch.dll -// MVID: {94058166-F81D-4A82-ABCC-FB400C785214} +// MVID: {F38BF1C4-C0E5-4BAD-8838-849DFFFA97DF} .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: 0x00EF0000 +// Image base: 0x00300000 // =============== CLASS MEMBERS DECLARATION =================== @@ -510,6 +510,46 @@ IL_0050: ret } // end of method Switch::ShortSwitchOverString + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 71 (0x47) + .maxstack 2 + IL_0000: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0005: ldarg.0 + IL_0006: call string [mscorlib]System.String::Concat(string, + string) + IL_000b: call void [mscorlib]System.Console::WriteLine(string) + IL_0010: ldarg.0 + IL_0011: ldstr "First case" + IL_0016: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001b: brtrue.s IL_002f + + IL_001d: ldarg.0 + IL_001e: ldstr "Second case" + IL_0023: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_0028: brtrue.s IL_0035 + + IL_002a: ldarg.0 + IL_002b: brfalse.s IL_003b + + IL_002d: br.s IL_0041 + + IL_002f: ldstr "Text1" + IL_0034: ret + + IL_0035: ldstr "Text2" + IL_003a: ret + + IL_003b: ldstr "null" + IL_0040: ret + + IL_0041: ldstr "Default" + IL_0046: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + .method public hidebysig static string SwitchOverString1(string text) cil managed { @@ -894,7 +934,7 @@ .method public hidebysig static void SwitchInLoop(int32 i) cil managed { - // Code size 122 (0x7a) + // Code size 110 (0x6e) .maxstack 2 IL_0000: ldstr "SwitchInLoop: " IL_0005: ldarg.0 @@ -908,37 +948,33 @@ IL_0018: switch ( IL_002f, IL_003b, - IL_0047, - IL_0053) - IL_002d: br.s IL_005e + IL_0052, + IL_0047) + IL_002d: br.s IL_0052 IL_002f: ldstr "one" IL_0034: call void [mscorlib]System.Console::WriteLine(string) - IL_0039: br.s IL_0073 + IL_0039: br.s IL_0067 IL_003b: ldstr "two" IL_0040: call void [mscorlib]System.Console::WriteLine(string) - IL_0045: br.s IL_0073 + IL_0045: br.s IL_0067 - IL_0047: ldstr "three" + IL_0047: ldstr "four" IL_004c: call void [mscorlib]System.Console::WriteLine(string) - IL_0051: br.s IL_0015 - - IL_0053: ldstr "four" - IL_0058: call void [mscorlib]System.Console::WriteLine(string) - IL_005d: ret + IL_0051: ret - IL_005e: ldstr "default" - IL_0063: call void [mscorlib]System.Console::WriteLine(string) - IL_0068: ldstr "more code" - IL_006d: call void [mscorlib]System.Console::WriteLine(string) - IL_0072: ret + IL_0052: ldstr "default" + IL_0057: call void [mscorlib]System.Console::WriteLine(string) + IL_005c: ldstr "more code" + IL_0061: call void [mscorlib]System.Console::WriteLine(string) + IL_0066: ret - IL_0073: ldarg.0 - IL_0074: ldc.i4.1 - IL_0075: add - IL_0076: starg.s i - IL_0078: br.s IL_0015 + IL_0067: ldarg.0 + IL_0068: ldc.i4.1 + IL_0069: add + IL_006a: starg.s i + IL_006c: br.s IL_0015 } // end of method Switch::SwitchInLoop .method public hidebysig static void SwitchWithGoto(int32 i) cil managed diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il index b74cb403c..0ce401e0a 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Switch.roslyn.il @@ -25,14 +25,14 @@ .ver 0:0:0:0 } .module Switch.dll -// MVID: {1E0E6114-7796-44C6-B88B-AA126D09F561} +// MVID: {25920C54-28DD-4B8C-9EBF-16E716D0EC15} .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: 0x02FE0000 +// Image base: 0x01040000 // =============== CLASS MEMBERS DECLARATION =================== @@ -683,6 +683,63 @@ IL_0062: ret } // end of method Switch::ShortSwitchOverString + .method public hidebysig static string + ShortSwitchOverStringWithNullCase(string text) cil managed + { + // Code size 89 (0x59) + .maxstack 2 + .locals init (string V_0, + string V_1) + IL_0000: nop + IL_0001: ldstr "ShortSwitchOverStringWithNullCase: " + IL_0006: ldarg.0 + IL_0007: call string [mscorlib]System.String::Concat(string, + string) + IL_000c: call void [mscorlib]System.Console::WriteLine(string) + IL_0011: nop + IL_0012: ldarg.0 + IL_0013: stloc.0 + IL_0014: ldloc.0 + IL_0015: ldstr "First case" + IL_001a: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_001f: brtrue.s IL_0033 + + IL_0021: ldloc.0 + IL_0022: ldstr "Second case" + IL_0027: call bool [mscorlib]System.String::op_Equality(string, + string) + IL_002c: brtrue.s IL_003c + + IL_002e: ldloc.0 + IL_002f: brfalse.s IL_0045 + + IL_0031: br.s IL_004e + + IL_0033: nop + IL_0034: ldstr "Text1" + IL_0039: stloc.1 + IL_003a: br.s IL_0057 + + IL_003c: nop + IL_003d: ldstr "Text2" + IL_0042: stloc.1 + IL_0043: br.s IL_0057 + + IL_0045: nop + IL_0046: ldstr "null" + IL_004b: stloc.1 + IL_004c: br.s IL_0057 + + IL_004e: nop + IL_004f: ldstr "Default" + IL_0054: stloc.1 + IL_0055: br.s IL_0057 + + IL_0057: ldloc.1 + IL_0058: ret + } // end of method Switch::ShortSwitchOverStringWithNullCase + .method public hidebysig static string SwitchOverString1(string text) cil managed { @@ -870,12 +927,11 @@ .method public hidebysig static string SwitchOverString2() cil managed { - // Code size 520 (0x208) + // Code size 518 (0x206) .maxstack 2 .locals init (string V_0, - string V_1, - uint32 V_2, - string V_3) + uint32 V_1, + string V_2) IL_0000: nop IL_0001: ldstr "SwitchOverString2:" IL_0006: call void [mscorlib]System.Console::WriteLine(string) @@ -883,238 +939,236 @@ IL_000c: call string [mscorlib]System.Environment::get_UserName() IL_0011: stloc.0 IL_0012: ldloc.0 - IL_0013: stloc.1 - IL_0014: ldloc.1 - IL_0015: call uint32 ''::ComputeStringHash(string) - IL_001a: stloc.2 - IL_001b: ldloc.2 - IL_001c: ldc.i4 0x4c7c71f6 - IL_0021: bgt.un.s IL_0072 + IL_0013: call uint32 ''::ComputeStringHash(string) + IL_0018: stloc.1 + IL_0019: ldloc.1 + IL_001a: ldc.i4 0x4c7c71f6 + IL_001f: bgt.un.s IL_0070 - IL_0023: ldloc.2 - IL_0024: ldc.i4 0xc9a8f4f - IL_0029: bgt.un.s IL_0048 + IL_0021: ldloc.1 + IL_0022: ldc.i4 0xc9a8f4f + IL_0027: bgt.un.s IL_0046 - IL_002b: ldloc.2 - IL_002c: ldc.i4 0x8861b86 - IL_0031: beq IL_011c + IL_0029: ldloc.1 + IL_002a: ldc.i4 0x8861b86 + IL_002f: beq IL_011a - IL_0036: br.s IL_0038 + IL_0034: br.s IL_0036 - IL_0038: ldloc.2 - IL_0039: ldc.i4 0xc9a8f4f - IL_003e: beq IL_00c8 + IL_0036: ldloc.1 + IL_0037: ldc.i4 0xc9a8f4f + IL_003c: beq IL_00c6 - IL_0043: br IL_01fd + IL_0041: br IL_01fb - IL_0048: ldloc.2 - IL_0049: ldc.i4 0xf3d44a6 - IL_004e: beq IL_00f2 + IL_0046: ldloc.1 + IL_0047: ldc.i4 0xf3d44a6 + IL_004c: beq IL_00f0 - IL_0053: br.s IL_0055 + IL_0051: br.s IL_0053 - IL_0055: ldloc.2 - IL_0056: ldc.i4 0x20289804 - IL_005b: beq IL_0158 + IL_0053: ldloc.1 + IL_0054: ldc.i4 0x20289804 + IL_0059: beq IL_0156 - IL_0060: br.s IL_0062 + IL_005e: br.s IL_0060 - IL_0062: ldloc.2 - IL_0063: ldc.i4 0x4c7c71f6 - IL_0068: beq IL_016a + IL_0060: ldloc.1 + IL_0061: ldc.i4 0x4c7c71f6 + IL_0066: beq IL_0168 - IL_006d: br IL_01fd + IL_006b: br IL_01fb - IL_0072: ldloc.2 - IL_0073: ldc.i4 0xa151b28a - IL_0078: bgt.un.s IL_00a4 + IL_0070: ldloc.1 + IL_0071: ldc.i4 0xa151b28a + IL_0076: bgt.un.s IL_00a2 - IL_007a: ldloc.2 - IL_007b: ldc.i4 0x4d0cea48 - IL_0080: beq IL_018b + IL_0078: ldloc.1 + IL_0079: ldc.i4 0x4d0cea48 + IL_007e: beq IL_0189 - IL_0085: br.s IL_0087 + IL_0083: br.s IL_0085 - IL_0087: ldloc.2 - IL_0088: ldc.i4 0x51650fb9 - IL_008d: beq IL_0131 + IL_0085: ldloc.1 + IL_0086: ldc.i4 0x51650fb9 + IL_008b: beq IL_012f - IL_0092: br.s IL_0094 + IL_0090: br.s IL_0092 - IL_0094: ldloc.2 - IL_0095: ldc.i4 0xa151b28a - IL_009a: beq IL_0146 + IL_0092: ldloc.1 + IL_0093: ldc.i4 0xa151b28a + IL_0098: beq IL_0144 - IL_009f: br IL_01fd + IL_009d: br IL_01fb - IL_00a4: ldloc.2 - IL_00a5: ldc.i4 0xea3d096b - IL_00aa: beq.s IL_00dd + IL_00a2: ldloc.1 + IL_00a3: ldc.i4 0xea3d096b + IL_00a8: beq.s IL_00db - IL_00ac: br.s IL_00ae + IL_00aa: br.s IL_00ac - IL_00ae: ldloc.2 - IL_00af: ldc.i4 0xed5134d4 - IL_00b4: beq IL_017c + IL_00ac: ldloc.1 + IL_00ad: ldc.i4 0xed5134d4 + IL_00b2: beq IL_017a - IL_00b9: br.s IL_00bb + IL_00b7: br.s IL_00b9 - IL_00bb: ldloc.2 - IL_00bc: ldc.i4 0xf701cc7f - IL_00c1: beq.s IL_0107 + IL_00b9: ldloc.1 + IL_00ba: ldc.i4 0xf701cc7f + IL_00bf: beq.s IL_0105 - IL_00c3: br IL_01fd + IL_00c1: br IL_01fb - IL_00c8: ldloc.1 - IL_00c9: ldstr "First case" - IL_00ce: call bool [mscorlib]System.String::op_Equality(string, + IL_00c6: ldloc.0 + IL_00c7: ldstr "First case" + IL_00cc: call bool [mscorlib]System.String::op_Equality(string, string) - IL_00d3: brtrue IL_019a + IL_00d1: brtrue IL_0198 - IL_00d8: br IL_01fd + IL_00d6: br IL_01fb - IL_00dd: ldloc.1 - IL_00de: ldstr "Second case" - IL_00e3: call bool [mscorlib]System.String::op_Equality(string, + IL_00db: ldloc.0 + IL_00dc: ldstr "Second case" + IL_00e1: call bool [mscorlib]System.String::op_Equality(string, string) - IL_00e8: brtrue IL_01a3 + IL_00e6: brtrue IL_01a1 - IL_00ed: br IL_01fd + IL_00eb: br IL_01fb - IL_00f2: ldloc.1 - IL_00f3: ldstr "Third case" - IL_00f8: call bool [mscorlib]System.String::op_Equality(string, + IL_00f0: ldloc.0 + IL_00f1: ldstr "Third case" + IL_00f6: call bool [mscorlib]System.String::op_Equality(string, string) - IL_00fd: brtrue IL_01ac + IL_00fb: brtrue IL_01aa - IL_0102: br IL_01fd + IL_0100: br IL_01fb - IL_0107: ldloc.1 - IL_0108: ldstr "Fourth case" - IL_010d: call bool [mscorlib]System.String::op_Equality(string, + IL_0105: ldloc.0 + IL_0106: ldstr "Fourth case" + IL_010b: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0112: brtrue IL_01b5 + IL_0110: brtrue IL_01b3 - IL_0117: br IL_01fd + IL_0115: br IL_01fb - IL_011c: ldloc.1 - IL_011d: ldstr "Fifth case" - IL_0122: call bool [mscorlib]System.String::op_Equality(string, + IL_011a: ldloc.0 + IL_011b: ldstr "Fifth case" + IL_0120: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0127: brtrue IL_01be + IL_0125: brtrue IL_01bc - IL_012c: br IL_01fd + IL_012a: br IL_01fb - IL_0131: ldloc.1 - IL_0132: ldstr "Sixth case" - IL_0137: call bool [mscorlib]System.String::op_Equality(string, + IL_012f: ldloc.0 + IL_0130: ldstr "Sixth case" + IL_0135: call bool [mscorlib]System.String::op_Equality(string, string) - IL_013c: brtrue IL_01c7 + IL_013a: brtrue IL_01c5 - IL_0141: br IL_01fd + IL_013f: br IL_01fb - IL_0146: ldloc.1 - IL_0147: ldstr "Seventh case" - IL_014c: call bool [mscorlib]System.String::op_Equality(string, + IL_0144: ldloc.0 + IL_0145: ldstr "Seventh case" + IL_014a: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0151: brtrue.s IL_01d0 + IL_014f: brtrue.s IL_01ce - IL_0153: br IL_01fd + IL_0151: br IL_01fb - IL_0158: ldloc.1 - IL_0159: ldstr "Eighth case" - IL_015e: call bool [mscorlib]System.String::op_Equality(string, + IL_0156: ldloc.0 + IL_0157: ldstr "Eighth case" + IL_015c: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0163: brtrue.s IL_01d9 + IL_0161: brtrue.s IL_01d7 - IL_0165: br IL_01fd + IL_0163: br IL_01fb - IL_016a: ldloc.1 - IL_016b: ldstr "Ninth case" - IL_0170: call bool [mscorlib]System.String::op_Equality(string, + IL_0168: ldloc.0 + IL_0169: ldstr "Ninth case" + IL_016e: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0175: brtrue.s IL_01e2 + IL_0173: brtrue.s IL_01e0 - IL_0177: br IL_01fd + IL_0175: br IL_01fb - IL_017c: ldloc.1 - IL_017d: ldstr "Tenth case" - IL_0182: call bool [mscorlib]System.String::op_Equality(string, + IL_017a: ldloc.0 + IL_017b: ldstr "Tenth case" + IL_0180: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0187: brtrue.s IL_01eb + IL_0185: brtrue.s IL_01e9 - IL_0189: br.s IL_01fd + IL_0187: br.s IL_01fb - IL_018b: ldloc.1 - IL_018c: ldstr "Eleventh case" - IL_0191: call bool [mscorlib]System.String::op_Equality(string, + IL_0189: ldloc.0 + IL_018a: ldstr "Eleventh case" + IL_018f: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0196: brtrue.s IL_01f4 - - IL_0198: br.s IL_01fd - - IL_019a: nop - IL_019b: ldstr "Text1" - IL_01a0: stloc.3 - IL_01a1: br.s IL_0206 - - IL_01a3: nop - IL_01a4: ldstr "Text2" - IL_01a9: stloc.3 - IL_01aa: br.s IL_0206 - - IL_01ac: nop - IL_01ad: ldstr "Text3" - IL_01b2: stloc.3 - IL_01b3: br.s IL_0206 - - IL_01b5: nop - IL_01b6: ldstr "Text4" - IL_01bb: stloc.3 - IL_01bc: br.s IL_0206 - - IL_01be: nop - IL_01bf: ldstr "Text5" - IL_01c4: stloc.3 - IL_01c5: br.s IL_0206 - - IL_01c7: nop - IL_01c8: ldstr "Text6" - IL_01cd: stloc.3 - IL_01ce: br.s IL_0206 - - IL_01d0: nop - IL_01d1: ldstr "Text7" - IL_01d6: stloc.3 - IL_01d7: br.s IL_0206 - - IL_01d9: nop - IL_01da: ldstr "Text8" - IL_01df: stloc.3 - IL_01e0: br.s IL_0206 - - IL_01e2: nop - IL_01e3: ldstr "Text9" - IL_01e8: stloc.3 - IL_01e9: br.s IL_0206 - - IL_01eb: nop - IL_01ec: ldstr "Text10" - IL_01f1: stloc.3 - IL_01f2: br.s IL_0206 - - IL_01f4: nop - IL_01f5: ldstr "Text11" - IL_01fa: stloc.3 - IL_01fb: br.s IL_0206 - - IL_01fd: nop - IL_01fe: ldstr "Default" - IL_0203: stloc.3 - IL_0204: br.s IL_0206 - - IL_0206: ldloc.3 - IL_0207: ret + IL_0194: brtrue.s IL_01f2 + + IL_0196: br.s IL_01fb + + IL_0198: nop + IL_0199: ldstr "Text1" + IL_019e: stloc.2 + IL_019f: br.s IL_0204 + + IL_01a1: nop + IL_01a2: ldstr "Text2" + IL_01a7: stloc.2 + IL_01a8: br.s IL_0204 + + IL_01aa: nop + IL_01ab: ldstr "Text3" + IL_01b0: stloc.2 + IL_01b1: br.s IL_0204 + + IL_01b3: nop + IL_01b4: ldstr "Text4" + IL_01b9: stloc.2 + IL_01ba: br.s IL_0204 + + IL_01bc: nop + IL_01bd: ldstr "Text5" + IL_01c2: stloc.2 + IL_01c3: br.s IL_0204 + + IL_01c5: nop + IL_01c6: ldstr "Text6" + IL_01cb: stloc.2 + IL_01cc: br.s IL_0204 + + IL_01ce: nop + IL_01cf: ldstr "Text7" + IL_01d4: stloc.2 + IL_01d5: br.s IL_0204 + + IL_01d7: nop + IL_01d8: ldstr "Text8" + IL_01dd: stloc.2 + IL_01de: br.s IL_0204 + + IL_01e0: nop + IL_01e1: ldstr "Text9" + IL_01e6: stloc.2 + IL_01e7: br.s IL_0204 + + IL_01e9: nop + IL_01ea: ldstr "Text10" + IL_01ef: stloc.2 + IL_01f0: br.s IL_0204 + + IL_01f2: nop + IL_01f3: ldstr "Text11" + IL_01f8: stloc.2 + IL_01f9: br.s IL_0204 + + IL_01fb: nop + IL_01fc: ldstr "Default" + IL_0201: stloc.2 + IL_0202: br.s IL_0204 + + IL_0204: ldloc.2 + IL_0205: ret } // end of method Switch::SwitchOverString2 .method public hidebysig static string @@ -1166,7 +1220,7 @@ .method public hidebysig static void SwitchInLoop(int32 i) cil managed { - // Code size 146 (0x92) + // Code size 132 (0x84) .maxstack 2 .locals init (int32 V_0, bool V_1) @@ -1178,7 +1232,7 @@ object) IL_0011: call void [mscorlib]System.Console::WriteLine(string) IL_0016: nop - IL_0017: br.s IL_008d + IL_0017: br.s IL_007f IL_0019: nop IL_001a: ldarg.0 @@ -1189,53 +1243,47 @@ IL_001f: switch ( IL_0036, IL_0044, - IL_0052, - IL_0060) - IL_0034: br.s IL_006e + IL_0060, + IL_0052) + IL_0034: br.s IL_0060 IL_0036: nop IL_0037: ldstr "one" IL_003c: call void [mscorlib]System.Console::WriteLine(string) IL_0041: nop - IL_0042: br.s IL_0087 + IL_0042: br.s IL_0079 IL_0044: nop IL_0045: ldstr "two" IL_004a: call void [mscorlib]System.Console::WriteLine(string) IL_004f: nop - IL_0050: br.s IL_0087 + IL_0050: br.s IL_0079 IL_0052: nop - IL_0053: ldstr "three" + IL_0053: ldstr "four" IL_0058: call void [mscorlib]System.Console::WriteLine(string) IL_005d: nop - IL_005e: br.s IL_008d + IL_005e: br.s IL_0083 IL_0060: nop - IL_0061: ldstr "four" + IL_0061: ldstr "default" IL_0066: call void [mscorlib]System.Console::WriteLine(string) IL_006b: nop - IL_006c: br.s IL_0091 - - IL_006e: nop - IL_006f: ldstr "default" - IL_0074: call void [mscorlib]System.Console::WriteLine(string) - IL_0079: nop - IL_007a: ldstr "more code" - IL_007f: call void [mscorlib]System.Console::WriteLine(string) - IL_0084: nop - IL_0085: br.s IL_0091 - - IL_0087: ldarg.0 - IL_0088: ldc.i4.1 - IL_0089: add - IL_008a: starg.s i - IL_008c: nop - IL_008d: ldc.i4.1 - IL_008e: stloc.1 - IL_008f: br.s IL_0019 - - IL_0091: ret + IL_006c: ldstr "more code" + IL_0071: call void [mscorlib]System.Console::WriteLine(string) + IL_0076: nop + IL_0077: br.s IL_0083 + + IL_0079: ldarg.0 + IL_007a: ldc.i4.1 + IL_007b: add + IL_007c: starg.s i + IL_007e: nop + IL_007f: ldc.i4.1 + IL_0080: stloc.1 + IL_0081: br.s IL_0019 + + IL_0083: ret } // end of method Switch::SwitchInLoop .method public hidebysig static void SwitchWithGoto(int32 i) cil managed @@ -1317,7 +1365,7 @@ .method public hidebysig static void SwitchOnStringInForLoop() cil managed { - // Code size 265 (0x109) + // Code size 261 (0x105) .maxstack 2 .locals init (class [mscorlib]System.Collections.Generic.List`1 V_0, class [mscorlib]System.Collections.Generic.List`1 V_1, @@ -1325,8 +1373,7 @@ int32 V_3, class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty V_4, string V_5, - string V_6, - bool V_7) + bool V_6) IL_0000: nop IL_0001: newobj instance void class [mscorlib]System.Collections.Generic.List`1::.ctor() IL_0006: stloc.0 @@ -1336,7 +1383,7 @@ IL_0012: stloc.2 IL_0013: ldc.i4.0 IL_0014: stloc.3 - IL_0015: br IL_00f9 + IL_0015: br IL_00f5 IL_001a: nop IL_001b: ldloc.2 @@ -1348,123 +1395,121 @@ IL_0027: callvirt instance string [mscorlib]System.Reflection.MemberInfo::get_Name() IL_002c: stloc.s V_5 IL_002e: ldloc.s V_5 - IL_0030: stloc.s V_6 - IL_0032: ldloc.s V_6 - IL_0034: ldstr "Name1" - IL_0039: call bool [mscorlib]System.String::op_Equality(string, + IL_0030: ldstr "Name1" + IL_0035: call bool [mscorlib]System.String::op_Equality(string, string) - IL_003e: brtrue.s IL_0088 + IL_003a: brtrue.s IL_0084 - IL_0040: ldloc.s V_6 - IL_0042: ldstr "Name2" - IL_0047: call bool [mscorlib]System.String::op_Equality(string, + IL_003c: ldloc.s V_5 + IL_003e: ldstr "Name2" + IL_0043: call bool [mscorlib]System.String::op_Equality(string, string) - IL_004c: brtrue.s IL_009d + IL_0048: brtrue.s IL_0099 - IL_004e: ldloc.s V_6 - IL_0050: ldstr "Name3" - IL_0055: call bool [mscorlib]System.String::op_Equality(string, + IL_004a: ldloc.s V_5 + IL_004c: ldstr "Name3" + IL_0051: call bool [mscorlib]System.String::op_Equality(string, string) - IL_005a: brtrue.s IL_00b2 + IL_0056: brtrue.s IL_00ae - IL_005c: ldloc.s V_6 - IL_005e: ldstr "Name4" - IL_0063: call bool [mscorlib]System.String::op_Equality(string, + IL_0058: ldloc.s V_5 + IL_005a: ldstr "Name4" + IL_005f: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0068: brtrue.s IL_00c7 + IL_0064: brtrue.s IL_00c3 - IL_006a: ldloc.s V_6 - IL_006c: ldstr "Name5" - IL_0071: call bool [mscorlib]System.String::op_Equality(string, + IL_0066: ldloc.s V_5 + IL_0068: ldstr "Name5" + IL_006d: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0076: brtrue.s IL_00dc + IL_0072: brtrue.s IL_00d8 - IL_0078: ldloc.s V_6 - IL_007a: ldstr "Name6" - IL_007f: call bool [mscorlib]System.String::op_Equality(string, + IL_0074: ldloc.s V_5 + IL_0076: ldstr "Name6" + IL_007b: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0084: brtrue.s IL_00dc + IL_0080: brtrue.s IL_00d8 - IL_0086: br.s IL_00e8 + IL_0082: br.s IL_00e4 - IL_0088: nop - IL_0089: ldloc.s V_4 - IL_008b: ldc.i4.1 - IL_008c: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_0091: nop - IL_0092: ldloc.0 - IL_0093: ldloc.s V_4 - IL_0095: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_009a: nop - IL_009b: br.s IL_00f4 - - IL_009d: nop - IL_009e: ldloc.s V_4 - IL_00a0: ldc.i4.2 - IL_00a1: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00a6: nop - IL_00a7: ldloc.0 - IL_00a8: ldloc.s V_4 - IL_00aa: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00af: nop - IL_00b0: br.s IL_00f4 - - IL_00b2: nop - IL_00b3: ldloc.s V_4 - IL_00b5: ldc.i4.3 - IL_00b6: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00bb: nop - IL_00bc: ldloc.0 - IL_00bd: ldloc.s V_4 - IL_00bf: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00c4: nop - IL_00c5: br.s IL_00f4 - - IL_00c7: nop - IL_00c8: ldloc.s V_4 - IL_00ca: ldc.i4.4 - IL_00cb: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) - IL_00d0: nop - IL_00d1: ldloc.0 - IL_00d2: ldloc.s V_4 - IL_00d4: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00d9: nop - IL_00da: br.s IL_00f4 - - IL_00dc: nop - IL_00dd: ldloc.0 - IL_00de: ldloc.s V_4 - IL_00e0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00e5: nop - IL_00e6: br.s IL_00f4 - - IL_00e8: nop - IL_00e9: ldloc.1 - IL_00ea: ldloc.s V_4 - IL_00ec: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) - IL_00f1: nop - IL_00f2: br.s IL_00f4 - - IL_00f4: nop + IL_0084: nop + IL_0085: ldloc.s V_4 + IL_0087: ldc.i4.1 + IL_0088: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_008d: nop + IL_008e: ldloc.0 + IL_008f: ldloc.s V_4 + IL_0091: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_0096: nop + IL_0097: br.s IL_00f0 + + IL_0099: nop + IL_009a: ldloc.s V_4 + IL_009c: ldc.i4.2 + IL_009d: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00a2: nop + IL_00a3: ldloc.0 + IL_00a4: ldloc.s V_4 + IL_00a6: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00ab: nop + IL_00ac: br.s IL_00f0 + + IL_00ae: nop + IL_00af: ldloc.s V_4 + IL_00b1: ldc.i4.3 + IL_00b2: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00b7: nop + IL_00b8: ldloc.0 + IL_00b9: ldloc.s V_4 + IL_00bb: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00c0: nop + IL_00c1: br.s IL_00f0 + + IL_00c3: nop + IL_00c4: ldloc.s V_4 + IL_00c6: ldc.i4.4 + IL_00c7: callvirt instance void ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch/SetProperty::set_Set(int32) + IL_00cc: nop + IL_00cd: ldloc.0 + IL_00ce: ldloc.s V_4 + IL_00d0: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00d5: nop + IL_00d6: br.s IL_00f0 + + IL_00d8: nop + IL_00d9: ldloc.0 + IL_00da: ldloc.s V_4 + IL_00dc: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00e1: nop + IL_00e2: br.s IL_00f0 + + IL_00e4: nop + IL_00e5: ldloc.1 + IL_00e6: ldloc.s V_4 + IL_00e8: callvirt instance void class [mscorlib]System.Collections.Generic.List`1::Add(!0) + IL_00ed: nop + IL_00ee: br.s IL_00f0 + + IL_00f0: nop + IL_00f1: ldloc.3 + IL_00f2: ldc.i4.1 + IL_00f3: add + IL_00f4: stloc.3 IL_00f5: ldloc.3 - IL_00f6: ldc.i4.1 - IL_00f7: add - IL_00f8: stloc.3 - IL_00f9: ldloc.3 - IL_00fa: ldloc.2 - IL_00fb: ldlen - IL_00fc: conv.i4 - IL_00fd: clt - IL_00ff: stloc.s V_7 - IL_0101: ldloc.s V_7 - IL_0103: brtrue IL_001a - - IL_0108: ret + IL_00f6: ldloc.2 + IL_00f7: ldlen + IL_00f8: conv.i4 + IL_00f9: clt + IL_00fb: stloc.s V_6 + IL_00fd: ldloc.s V_6 + IL_00ff: brtrue IL_001a + + IL_0104: ret } // end of method Switch::SwitchOnStringInForLoop .method public hidebysig static void SwitchWithComplexCondition(string[] args) cil managed { - // Code size 134 (0x86) + // Code size 138 (0x8a) .maxstack 2 .locals init (string V_0) IL_0000: nop @@ -1489,51 +1534,55 @@ IL_001e: ldstr "b" IL_0023: call bool [mscorlib]System.String::op_Equality(string, string) - IL_0028: brtrue.s IL_0053 + IL_0028: brtrue.s IL_0054 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_0035: brtrue.s IL_0062 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_0042: brtrue.s IL_0070 - IL_0044: br.s IL_007a + IL_0044: br.s IL_007e - IL_0046: ldstr "a" - IL_004b: call void [mscorlib]System.Console::WriteLine(string) - IL_0050: nop - IL_0051: br.s IL_007a + IL_0046: nop + IL_0047: ldstr "a" + IL_004c: call void [mscorlib]System.Console::WriteLine(string) + IL_0051: nop + IL_0052: br.s IL_007e - IL_0053: ldstr "b" - IL_0058: call void [mscorlib]System.Console::WriteLine(string) - IL_005d: nop - IL_005e: br.s IL_007a + IL_0054: nop + IL_0055: ldstr "b" + IL_005a: call void [mscorlib]System.Console::WriteLine(string) + IL_005f: nop + IL_0060: br.s IL_007e - IL_0060: ldstr "c" - IL_0065: call void [mscorlib]System.Console::WriteLine(string) - IL_006a: nop - IL_006b: br.s IL_007a + IL_0062: nop + IL_0063: ldstr "c" + IL_0068: call void [mscorlib]System.Console::WriteLine(string) + IL_006d: nop + IL_006e: br.s IL_007e - IL_006d: ldstr "d" - IL_0072: call void [mscorlib]System.Console::WriteLine(string) - IL_0077: nop - IL_0078: br.s IL_007a + IL_0070: nop + IL_0071: ldstr "d" + IL_0076: call void [mscorlib]System.Console::WriteLine(string) + IL_007b: nop + IL_007c: br.s IL_007e - IL_007a: ldstr "end" - IL_007f: call void [mscorlib]System.Console::WriteLine(string) - IL_0084: nop - IL_0085: ret + IL_007e: ldstr "end" + IL_0083: call void [mscorlib]System.Console::WriteLine(string) + IL_0088: nop + IL_0089: ret } // end of method Switch::SwitchWithComplexCondition .method public hidebysig static void SwitchWithArray(string[] args) cil managed { - // Code size 123 (0x7b) + // Code size 127 (0x7f) .maxstack 2 .locals init (string V_0) IL_0000: nop @@ -1551,46 +1600,50 @@ IL_0013: ldstr "b" IL_0018: call bool [mscorlib]System.String::op_Equality(string, string) - IL_001d: brtrue.s IL_0048 + IL_001d: brtrue.s IL_0049 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_002a: brtrue.s IL_0057 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_0037: brtrue.s IL_0065 - IL_003b: ldstr "a" - IL_0040: call void [mscorlib]System.Console::WriteLine(string) - IL_0045: nop - IL_0046: br.s IL_006f + IL_0039: br.s IL_0073 - IL_0048: ldstr "b" - IL_004d: call void [mscorlib]System.Console::WriteLine(string) - IL_0052: nop - IL_0053: br.s IL_006f + IL_003b: nop + IL_003c: ldstr "a" + IL_0041: call void [mscorlib]System.Console::WriteLine(string) + IL_0046: nop + IL_0047: br.s IL_0073 - IL_0055: ldstr "c" - IL_005a: call void [mscorlib]System.Console::WriteLine(string) - IL_005f: nop - IL_0060: br.s IL_006f + IL_0049: nop + IL_004a: ldstr "b" + IL_004f: call void [mscorlib]System.Console::WriteLine(string) + IL_0054: nop + IL_0055: br.s IL_0073 - IL_0062: ldstr "d" - IL_0067: call void [mscorlib]System.Console::WriteLine(string) - IL_006c: nop - IL_006d: br.s IL_006f + IL_0057: nop + IL_0058: ldstr "c" + IL_005d: call void [mscorlib]System.Console::WriteLine(string) + IL_0062: nop + IL_0063: br.s IL_0073 - IL_006f: ldstr "end" - IL_0074: call void [mscorlib]System.Console::WriteLine(string) - IL_0079: nop - IL_007a: ret + IL_0065: nop + IL_0066: ldstr "d" + IL_006b: call void [mscorlib]System.Console::WriteLine(string) + IL_0070: nop + IL_0071: br.s IL_0073 + + IL_0073: ldstr "end" + IL_0078: call void [mscorlib]System.Console::WriteLine(string) + IL_007d: nop + IL_007e: ret } // end of method Switch::SwitchWithArray } // end of class ICSharpCode.Decompiler.Tests.TestCases.Pretty.Switch