From cefe1007207e85a9ae1cdf13c3f5fa33d2ec4f1a Mon Sep 17 00:00:00 2001 From: Julien Couvreur Date: Tue, 26 Nov 2024 11:21:11 -0800 Subject: [PATCH] Remove ILVerify --- .../Test/Emit/CodeGen/CodeGenIterators.cs | 535 ++---------------- .../Test/Emit/CodeGen/CodeGenIterators.vb | 502 +--------------- 2 files changed, 52 insertions(+), 985 deletions(-) diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs index 4434f5dff2d76..f39272b7c209c 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenIterators.cs @@ -4245,56 +4245,6 @@ private static System.Collections.Generic.IEnumerator GetEnumerator(Node head } """; var verifier = CompileAndVerify(src, expectedOutput: "True two disposing disposed False two").VerifyDiagnostics(); - verifier.VerifyIL("C.d__4.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 107 (0x6b) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__4.<>1__state" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_003f - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: stfld "int C.d__4.<>1__state" - IL_0017: ldarg.0 - IL_0018: ldarg.0 - IL_0019: ldfld "C.Node C.d__4.head" - IL_001e: stfld "C.Node C.d__4.5__2" - IL_0023: br.s IL_0061 - IL_0025: ldarg.0 - IL_0026: ldarg.0 - IL_0027: ldfld "C.Node C.d__4.5__2" - IL_002c: ldfld "T C.Node._value" - IL_0031: stfld "T C.d__4.<>2__current" - IL_0036: ldarg.0 - IL_0037: ldc.i4.1 - IL_0038: stfld "int C.d__4.<>1__state" - IL_003d: ldc.i4.1 - IL_003e: ret - IL_003f: ldarg.0 - IL_0040: ldc.i4.m1 - IL_0041: stfld "int C.d__4.<>1__state" - IL_0046: ldarg.0 - IL_0047: ldarg.0 - IL_0048: ldfld "C.Node C.d__4.5__2" - IL_004d: ldfld "C.Node C.Node._next" - IL_0052: stfld "C.Node C.d__4.5__2" - IL_0057: ldstr "AFTER" - IL_005c: call "void System.Console.Write(string)" - IL_0061: ldarg.0 - IL_0062: ldfld "C.Node C.d__4.5__2" - IL_0067: brtrue.s IL_0025 - IL_0069: ldc.i4.0 - IL_006a: ret -} -"""); verifier.VerifyIL("C.d__4.System.IDisposable.Dispose()", """ { // Code size 16 (0x10) @@ -4375,17 +4325,8 @@ public static System.Collections.Generic.IEnumerable Produce() } } """; - var verifier = CompileAndVerify(src, expectedOutput: "True one disposed False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld "int C.d__0.<>1__state" - IL_0008: ret -} -"""); + CompileAndVerify(src, expectedOutput: "True one disposed False one").VerifyDiagnostics(); + // Verify GetEnumerator string src2 = """ var enumerable = C.Produce(); @@ -4449,46 +4390,6 @@ public static System.Collections.Generic.IEnumerator GetEnumerator() """; // Note: we actually set the state to "after"/"finished" and cleanup hoisted locals again var verifier = CompileAndVerify(src, expectedOutput: "True one disposed disposed2 False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 75 (0x4b) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_0036 - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: stfld "int C.d__0.<>1__state" - IL_0017: ldarg.0 - IL_0018: ldstr "" - IL_001d: stfld "string C.d__0.5__2" - IL_0022: ldarg.0 - IL_0023: ldstr " one " - IL_0028: stfld "string C.d__0.<>2__current" - IL_002d: ldarg.0 - IL_002e: ldc.i4.1 - IL_002f: stfld "int C.d__0.<>1__state" - IL_0034: ldc.i4.1 - IL_0035: ret - IL_0036: ldarg.0 - IL_0037: ldc.i4.m1 - IL_0038: stfld "int C.d__0.<>1__state" - IL_003d: ldarg.0 - IL_003e: ldfld "string C.d__0.5__2" - IL_0043: callvirt "string object.ToString()" - IL_0048: pop - IL_0049: ldc.i4.0 - IL_004a: ret -} -"""); verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ { // Code size 16 (0x10) @@ -4530,67 +4431,8 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool } } """; - var verifier = CompileAndVerify(src, expectedOutput: "True one False one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 100 (0x64) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: switch ( - IL_001b, - IL_0036, - IL_005b) - IL_0019: ldc.i4.0 - IL_001a: ret - IL_001b: ldarg.0 - IL_001c: ldc.i4.m1 - IL_001d: stfld "int C.d__0.<>1__state" - IL_0022: ldarg.0 - IL_0023: ldstr " one " - IL_0028: stfld "string C.d__0.<>2__current" - IL_002d: ldarg.0 - IL_002e: ldc.i4.1 - IL_002f: stfld "int C.d__0.<>1__state" - IL_0034: ldc.i4.1 - IL_0035: ret - IL_0036: ldarg.0 - IL_0037: ldc.i4.m1 - IL_0038: stfld "int C.d__0.<>1__state" - IL_003d: ldarg.0 - IL_003e: ldfld "bool C.d__0.b" - IL_0043: brfalse.s IL_0047 - IL_0045: ldc.i4.0 - IL_0046: ret - IL_0047: ldarg.0 - IL_0048: ldstr " two " - IL_004d: stfld "string C.d__0.<>2__current" - IL_0052: ldarg.0 - IL_0053: ldc.i4.2 - IL_0054: stfld "int C.d__0.<>1__state" - IL_0059: ldc.i4.1 - IL_005a: ret - IL_005b: ldarg.0 - IL_005c: ldc.i4.m1 - IL_005d: stfld "int C.d__0.<>1__state" - IL_0062: ldc.i4.0 - IL_0063: ret -} -"""); + CompileAndVerify(src, expectedOutput: "True one False one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld "int C.d__0.<>1__state" - IL_0008: ret -} -"""); // Verify GetEnumerator string src2 = """ var enumerable = C.Produce(true); @@ -4642,53 +4484,8 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool } } """; - var verifier = CompileAndVerify(src, expectedOutput: "True one done False one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 62 (0x3e) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_002b - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: stfld "int C.d__0.<>1__state" - IL_0017: ldarg.0 - IL_0018: ldstr " one " - IL_001d: stfld "string C.d__0.<>2__current" - IL_0022: ldarg.0 - IL_0023: ldc.i4.1 - IL_0024: stfld "int C.d__0.<>1__state" - IL_0029: ldc.i4.1 - IL_002a: ret - IL_002b: ldarg.0 - IL_002c: ldc.i4.m1 - IL_002d: stfld "int C.d__0.<>1__state" - IL_0032: ldstr "done " - IL_0037: call "void System.Console.Write(string)" - IL_003c: ldc.i4.0 - IL_003d: ret -} -"""); + CompileAndVerify(src, expectedOutput: "True one done False one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld "int C.d__0.<>1__state" - IL_0008: ret -} -"""); // Verify GetEnumerator string src2 = """ var enumerable = C.Produce(true); @@ -4746,52 +4543,8 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool } } """; - var verifier = CompileAndVerify(src, expectedOutput: "True one exception one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 61 (0x3d) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_002b - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: stfld "int C.d__0.<>1__state" - IL_0017: ldarg.0 - IL_0018: ldstr " one " - IL_001d: stfld "string C.d__0.<>2__current" - IL_0022: ldarg.0 - IL_0023: ldc.i4.1 - IL_0024: stfld "int C.d__0.<>1__state" - IL_0029: ldc.i4.1 - IL_002a: ret - IL_002b: ldarg.0 - IL_002c: ldc.i4.m1 - IL_002d: stfld "int C.d__0.<>1__state" - IL_0032: ldstr "exception" - IL_0037: newobj "System.Exception..ctor(string)" - IL_003c: throw -} -"""); + CompileAndVerify(src, expectedOutput: "True one exception one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld "int C.d__0.<>1__state" - IL_0008: ret -} -"""); // Verify GetEnumerator string src2 = """ var enumerable = C.Produce(); @@ -4903,6 +4656,19 @@ .locals init (int V_0) IL_0022: ret } """); + verifier.VerifyIL("C.d__0.<>m__Finally1()", """ +{ + // Code size 18 (0x12) + .maxstack 2 + IL_0000: ldarg.0 + IL_0001: ldc.i4.m1 + IL_0002: stfld "int C.d__0.<>1__state" + IL_0007: ldstr "exception" + IL_000c: newobj "System.Exception..ctor(string)" + IL_0011: throw +} +"""); + // Verify GetEnumerator string src2 = """ var enumerable = C.Produce(); @@ -4975,81 +4741,8 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool } } """; - var verifier = CompileAndVerify(src, expectedOutput: "True one finally False one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 117 (0x75) - .maxstack 2 - .locals init (bool V_0, - int V_1) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.1 - IL_0007: ldloc.1 - IL_0008: switch ( - IL_001b, - IL_0036, - IL_006a) - IL_0019: ldc.i4.0 - IL_001a: ret - IL_001b: ldarg.0 - IL_001c: ldc.i4.m1 - IL_001d: stfld "int C.d__0.<>1__state" - IL_0022: ldarg.0 - IL_0023: ldstr " one " - IL_0028: stfld "string C.d__0.<>2__current" - IL_002d: ldarg.0 - IL_002e: ldc.i4.1 - IL_002f: stfld "int C.d__0.<>1__state" - IL_0034: ldc.i4.1 - IL_0035: ret - IL_0036: ldarg.0 - IL_0037: ldc.i4.m1 - IL_0038: stfld "int C.d__0.<>1__state" - .try - { - IL_003d: ldarg.0 - IL_003e: ldfld "bool C.d__0.b" - IL_0043: brfalse.s IL_0049 - IL_0045: ldc.i4.0 - IL_0046: stloc.0 - IL_0047: leave.s IL_0073 - IL_0049: leave.s IL_0056 - } - finally - { - IL_004b: ldstr "finally " - IL_0050: call "void System.Console.Write(string)" - IL_0055: endfinally - } - IL_0056: ldarg.0 - IL_0057: ldstr " two " - IL_005c: stfld "string C.d__0.<>2__current" - IL_0061: ldarg.0 - IL_0062: ldc.i4.2 - IL_0063: stfld "int C.d__0.<>1__state" - IL_0068: ldc.i4.1 - IL_0069: ret - IL_006a: ldarg.0 - IL_006b: ldc.i4.m1 - IL_006c: stfld "int C.d__0.<>1__state" - IL_0071: ldc.i4.0 - IL_0072: ret - IL_0073: ldloc.0 - IL_0074: ret -} -"""); + CompileAndVerify(src, expectedOutput: "True one finally False one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld "int C.d__0.<>1__state" - IL_0008: ret -} -"""); // Verify GetEnumerator string src2 = """ var enumerable = C.Produce(true); @@ -5128,61 +4821,7 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool } } """; - var verifier = CompileAndVerify(src, expectedOutput: "True one finally exception one False one False one").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 72 (0x48) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_002b - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: stfld "int C.d__0.<>1__state" - IL_0017: ldarg.0 - IL_0018: ldstr " one " - IL_001d: stfld "string C.d__0.<>2__current" - IL_0022: ldarg.0 - IL_0023: ldc.i4.1 - IL_0024: stfld "int C.d__0.<>1__state" - IL_0029: ldc.i4.1 - IL_002a: ret - IL_002b: ldarg.0 - IL_002c: ldc.i4.m1 - IL_002d: stfld "int C.d__0.<>1__state" - .try - { - IL_0032: ldstr "exception" - IL_0037: newobj "System.Exception..ctor(string)" - IL_003c: throw - } - finally - { - IL_003d: ldstr "finally " - IL_0042: call "void System.Console.Write(string)" - IL_0047: endfinally - } -} -"""); - - verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld "int C.d__0.<>1__state" - IL_0008: ret -} -"""); + CompileAndVerify(src, expectedOutput: "True one finally exception one False one False one").VerifyDiagnostics(); // Verify GetEnumerator string src2 = """ @@ -5255,7 +4894,7 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool try { yield return " one "; - throw new System.Exception("exception"); + if (b) throw new System.Exception("exception"); } finally { @@ -5264,10 +4903,11 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool } } """; + // Note: we generate a `fault { Dispose(); }`, but only if there is a `yield` in a `try`, which is surprising var verifier = CompileAndVerify(src, expectedOutput: "True one finally exception one False one").VerifyDiagnostics(); verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ { - // Code size 83 (0x53) + // Code size 101 (0x65) .maxstack 2 .locals init (bool V_0, int V_1) @@ -5283,7 +4923,7 @@ .locals init (bool V_0, IL_000c: beq.s IL_0037 IL_000e: ldc.i4.0 IL_000f: stloc.0 - IL_0010: leave.s IL_0051 + IL_0010: leave.s IL_0063 IL_0012: ldarg.0 IL_0013: ldc.i4.m1 IL_0014: stfld "int C.d__0.<>1__state" @@ -5298,22 +4938,30 @@ .locals init (bool V_0, IL_002e: stfld "int C.d__0.<>1__state" IL_0033: ldc.i4.1 IL_0034: stloc.0 - IL_0035: leave.s IL_0051 + IL_0035: leave.s IL_0063 IL_0037: ldarg.0 IL_0038: ldc.i4.s -3 IL_003a: stfld "int C.d__0.<>1__state" - IL_003f: ldstr "exception" - IL_0044: newobj "System.Exception..ctor(string)" - IL_0049: throw + IL_003f: ldarg.0 + IL_0040: ldfld "bool C.d__0.b" + IL_0045: brfalse.s IL_0052 + IL_0047: ldstr "exception" + IL_004c: newobj "System.Exception..ctor(string)" + IL_0051: throw + IL_0052: ldarg.0 + IL_0053: call "void C.d__0.<>m__Finally1()" + IL_0058: ldc.i4.0 + IL_0059: stloc.0 + IL_005a: leave.s IL_0063 } fault { - IL_004a: ldarg.0 - IL_004b: call "void C.d__0.Dispose()" - IL_0050: endfinally + IL_005c: ldarg.0 + IL_005d: call "void C.d__0.Dispose()" + IL_0062: endfinally } - IL_0051: ldloc.0 - IL_0052: ret + IL_0063: ldloc.0 + IL_0064: ret } """); @@ -5419,106 +5067,7 @@ public static System.Collections.Generic.IEnumerator GetEnumerator(bool } } """; - var verifier = CompileAndVerify(src, expectedOutput: "True one finally True two False two").VerifyDiagnostics(); - verifier.VerifyIL("C.d__0.System.Collections.IEnumerator.MoveNext()", """ -{ - // Code size 132 (0x84) - .maxstack 2 - .locals init (bool V_0, - int V_1) - .try - { - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.1 - IL_0007: ldloc.1 - IL_0008: switch ( - IL_001d, - IL_0042, - IL_0066) - IL_0019: ldc.i4.0 - IL_001a: stloc.0 - IL_001b: leave.s IL_0082 - IL_001d: ldarg.0 - IL_001e: ldc.i4.m1 - IL_001f: stfld "int C.d__0.<>1__state" - IL_0024: ldarg.0 - IL_0025: ldc.i4.s -3 - IL_0027: stfld "int C.d__0.<>1__state" - IL_002c: ldarg.0 - IL_002d: ldstr " one " - IL_0032: stfld "string C.d__0.<>2__current" - IL_0037: ldarg.0 - IL_0038: ldc.i4.1 - IL_0039: stfld "int C.d__0.<>1__state" - IL_003e: ldc.i4.1 - IL_003f: stloc.0 - IL_0040: leave.s IL_0082 - IL_0042: ldarg.0 - IL_0043: ldc.i4.s -3 - IL_0045: stfld "int C.d__0.<>1__state" - IL_004a: ldarg.0 - IL_004b: call "void C.d__0.<>m__Finally1()" - IL_0050: ldarg.0 - IL_0051: ldstr " two " - IL_0056: stfld "string C.d__0.<>2__current" - IL_005b: ldarg.0 - IL_005c: ldc.i4.2 - IL_005d: stfld "int C.d__0.<>1__state" - IL_0062: ldc.i4.1 - IL_0063: stloc.0 - IL_0064: leave.s IL_0082 - IL_0066: ldarg.0 - IL_0067: ldc.i4.m1 - IL_0068: stfld "int C.d__0.<>1__state" - IL_006d: ldstr "not executed after disposal" - IL_0072: call "void System.Console.Write(string)" - IL_0077: ldc.i4.0 - IL_0078: stloc.0 - IL_0079: leave.s IL_0082 - } - fault - { - IL_007b: ldarg.0 - IL_007c: call "void C.d__0.Dispose()" - IL_0081: endfinally - } - IL_0082: ldloc.0 - IL_0083: ret -} -"""); - - verifier.VerifyIL("C.d__0.System.IDisposable.Dispose()", """ -{ - // Code size 35 (0x23) - .maxstack 2 - .locals init (int V_0) - IL_0000: ldarg.0 - IL_0001: ldfld "int C.d__0.<>1__state" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: ldc.i4.s -3 - IL_000a: beq.s IL_0010 - IL_000c: ldloc.0 - IL_000d: ldc.i4.1 - IL_000e: bne.un.s IL_001a - IL_0010: nop - .try - { - IL_0011: leave.s IL_001a - } - finally - { - IL_0013: ldarg.0 - IL_0014: call "void C.d__0.<>m__Finally1()" - IL_0019: endfinally - } - IL_001a: ldarg.0 - IL_001b: ldc.i4.s -2 - IL_001d: stfld "int C.d__0.<>1__state" - IL_0022: ret -} -"""); + CompileAndVerify(src, expectedOutput: "True one finally True two False two").VerifyDiagnostics(); // Verify GetEnumerator string src2 = """ diff --git a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenIterators.vb b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenIterators.vb index 73b45685c551e..1d10bf41d4dae 100644 --- a/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenIterators.vb +++ b/src/Compilers/VisualBasic/Test/Emit/CodeGen/CodeGenIterators.vb @@ -1913,17 +1913,7 @@ End Class - Dim verifier = CompileAndVerify(source, expectedOutput:="True one disposed False one") - verifier.VerifyIL("C.VB$StateMachine_1_Produce.Dispose()", " -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld ""C.VB$StateMachine_1_Produce.$State As Integer"" - IL_0008: ret -} -") + CompileAndVerify(source, expectedOutput:="True one disposed False one") ' Verify GetEnumerator Dim source2 = @@ -2000,17 +1990,7 @@ End Class - Dim verifier = CompileAndVerify(source, expectedOutput:="True one disposed disposed2 False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0008: ret -} -") + CompileAndVerify(source, expectedOutput:="True one disposed disposed2 False one") End Sub @@ -2047,74 +2027,7 @@ End Class - Dim verifier = CompileAndVerify(source, expectedOutput:="True one False one False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.MoveNext()", " -{ - // Code size 108 (0x6c) - .maxstack 3 - .locals init (Integer V_0) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: switch ( - IL_001b, - IL_003a, - IL_0061) - IL_0019: ldc.i4.0 - IL_001a: ret - IL_001b: ldarg.0 - IL_001c: ldc.i4.m1 - IL_001d: dup - IL_001e: stloc.0 - IL_001f: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0024: ldarg.0 - IL_0025: ldstr "" one "" - IL_002a: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_002f: ldarg.0 - IL_0030: ldc.i4.1 - IL_0031: dup - IL_0032: stloc.0 - IL_0033: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0038: ldc.i4.1 - IL_0039: ret - IL_003a: ldarg.0 - IL_003b: ldc.i4.m1 - IL_003c: dup - IL_003d: stloc.0 - IL_003e: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0043: ldarg.0 - IL_0044: ldfld ""C.VB$StateMachine_1_GetEnumerator.$VB$Local_b As Boolean"" - IL_0049: brtrue.s IL_006a - IL_004b: ldarg.0 - IL_004c: ldstr "" two "" - IL_0051: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_0056: ldarg.0 - IL_0057: ldc.i4.2 - IL_0058: dup - IL_0059: stloc.0 - IL_005a: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_005f: ldc.i4.1 - IL_0060: ret - IL_0061: ldarg.0 - IL_0062: ldc.i4.m1 - IL_0063: dup - IL_0064: stloc.0 - IL_0065: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_006a: ldc.i4.0 - IL_006b: ret -} -") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0008: ret -} -") + CompileAndVerify(source, expectedOutput:="True one False one False one") ' Verify GetEnumerator Dim source2 = @@ -2183,58 +2096,7 @@ End Class - Dim verifier = CompileAndVerify(source, expectedOutput:="True one done False one False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.MoveNext()", " -{ - // Code size 68 (0x44) - .maxstack 3 - .locals init (Integer V_0) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_002f - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: dup - IL_0013: stloc.0 - IL_0014: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0019: ldarg.0 - IL_001a: ldstr "" one "" - IL_001f: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_0024: ldarg.0 - IL_0025: ldc.i4.1 - IL_0026: dup - IL_0027: stloc.0 - IL_0028: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_002d: ldc.i4.1 - IL_002e: ret - IL_002f: ldarg.0 - IL_0030: ldc.i4.m1 - IL_0031: dup - IL_0032: stloc.0 - IL_0033: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0038: ldstr ""done "" - IL_003d: call ""Sub System.Console.Write(String)"" - IL_0042: ldc.i4.0 - IL_0043: ret -} -") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0008: ret -} -") + CompileAndVerify(source, expectedOutput:="True one done False one False one") ' Verify GetEnumerator Dim source2 = @@ -2304,57 +2166,7 @@ End Class - Dim verifier = CompileAndVerify(source, expectedOutput:="True one exception one False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.MoveNext()", " -{ - // Code size 67 (0x43) - .maxstack 3 - .locals init (Integer V_0) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_002f - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: dup - IL_0013: stloc.0 - IL_0014: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0019: ldarg.0 - IL_001a: ldstr "" one "" - IL_001f: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_0024: ldarg.0 - IL_0025: ldc.i4.1 - IL_0026: dup - IL_0027: stloc.0 - IL_0028: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_002d: ldc.i4.1 - IL_002e: ret - IL_002f: ldarg.0 - IL_0030: ldc.i4.m1 - IL_0031: dup - IL_0032: stloc.0 - IL_0033: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0038: ldstr ""exception"" - IL_003d: newobj ""Sub System.Exception..ctor(String)"" - IL_0042: throw -} -") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0008: ret -} -") + CompileAndVerify(source, expectedOutput:="True one exception one False one") ' Verify GetEnumerator Dim source2 = @@ -2432,83 +2244,6 @@ End Class Dim verifier = CompileAndVerify(source, expectedOutput:="True one disposing exception disposed False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.MoveNext()", " -{ - // Code size 127 (0x7f) - .maxstack 3 - .locals init (Boolean V_0, - Integer V_1) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0006: stloc.1 - IL_0007: ldloc.1 - IL_0008: ldc.i4.s -3 - IL_000a: sub - IL_000b: switch ( - IL_002f, - IL_0024, - IL_0024, - IL_0026, - IL_002f) - IL_0024: ldc.i4.0 - IL_0025: ret - IL_0026: ldarg.0 - IL_0027: ldc.i4.m1 - IL_0028: dup - IL_0029: stloc.1 - IL_002a: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_002f: nop - .try - { - IL_0030: ldloc.1 - IL_0031: ldc.i4.s -3 - IL_0033: beq.s IL_003b - IL_0035: ldloc.1 - IL_0036: ldc.i4.1 - IL_0037: beq.s IL_0060 - IL_0039: br.s IL_0048 - IL_003b: ldarg.0 - IL_003c: ldc.i4.m1 - IL_003d: dup - IL_003e: stloc.1 - IL_003f: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0044: ldc.i4.1 - IL_0045: stloc.0 - IL_0046: leave.s IL_007d - IL_0048: ldarg.0 - IL_0049: ldstr "" one "" - IL_004e: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_0053: ldarg.0 - IL_0054: ldc.i4.1 - IL_0055: dup - IL_0056: stloc.1 - IL_0057: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_005c: ldc.i4.1 - IL_005d: stloc.0 - IL_005e: leave.s IL_007d - IL_0060: ldarg.0 - IL_0061: ldc.i4.m1 - IL_0062: dup - IL_0063: stloc.1 - IL_0064: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0069: leave.s IL_007b - } - finally - { - IL_006b: ldloc.1 - IL_006c: ldc.i4.0 - IL_006d: bge.s IL_007a - IL_006f: ldstr ""exception"" - IL_0074: newobj ""Sub System.Exception..ctor(String)"" - IL_0079: throw - IL_007a: endfinally - } - IL_007b: ldc.i4.0 - IL_007c: ret - IL_007d: ldloc.0 - IL_007e: ret -} -") verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " { // Code size 44 (0x2c) @@ -2614,88 +2349,7 @@ End Class - Dim verifier = CompileAndVerify(source, expectedOutput:="True one finally False one False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.MoveNext()", " -{ - // Code size 127 (0x7f) - .maxstack 3 - .locals init (Integer V_0) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: switch ( - IL_001b, - IL_003a, - IL_0074) - IL_0019: ldc.i4.0 - IL_001a: ret - IL_001b: ldarg.0 - IL_001c: ldc.i4.m1 - IL_001d: dup - IL_001e: stloc.0 - IL_001f: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0024: ldarg.0 - IL_0025: ldstr "" one "" - IL_002a: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_002f: ldarg.0 - IL_0030: ldc.i4.1 - IL_0031: dup - IL_0032: stloc.0 - IL_0033: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0038: ldc.i4.1 - IL_0039: ret - IL_003a: ldarg.0 - IL_003b: ldc.i4.m1 - IL_003c: dup - IL_003d: stloc.0 - IL_003e: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - .try - { - IL_0043: ldarg.0 - IL_0044: ldfld ""C.VB$StateMachine_1_GetEnumerator.$VB$Local_b As Boolean"" - IL_0049: brfalse.s IL_004d - IL_004b: leave.s IL_007d - IL_004d: leave.s IL_005e - } - finally - { - IL_004f: ldloc.0 - IL_0050: ldc.i4.0 - IL_0051: bge.s IL_005d - IL_0053: ldstr ""finally "" - IL_0058: call ""Sub System.Console.Write(String)"" - IL_005d: endfinally - } - IL_005e: ldarg.0 - IL_005f: ldstr "" two "" - IL_0064: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_0069: ldarg.0 - IL_006a: ldc.i4.2 - IL_006b: dup - IL_006c: stloc.0 - IL_006d: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0072: ldc.i4.1 - IL_0073: ret - IL_0074: ldarg.0 - IL_0075: ldc.i4.m1 - IL_0076: dup - IL_0077: stloc.0 - IL_0078: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_007d: ldc.i4.0 - IL_007e: ret -} -") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0008: ret -} -") + CompileAndVerify(source, expectedOutput:="True one finally False one False one") ' Verify GetEnumerator Dim source2 = @@ -2783,69 +2437,7 @@ End Class - Dim verifier = CompileAndVerify(source, expectedOutput:="True one finally exception one False one False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.MoveNext()", " -{ - // Code size 82 (0x52) - .maxstack 3 - .locals init (Integer V_0) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0006: stloc.0 - IL_0007: ldloc.0 - IL_0008: brfalse.s IL_0010 - IL_000a: ldloc.0 - IL_000b: ldc.i4.1 - IL_000c: beq.s IL_002f - IL_000e: ldc.i4.0 - IL_000f: ret - IL_0010: ldarg.0 - IL_0011: ldc.i4.m1 - IL_0012: dup - IL_0013: stloc.0 - IL_0014: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0019: ldarg.0 - IL_001a: ldstr "" one "" - IL_001f: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_0024: ldarg.0 - IL_0025: ldc.i4.1 - IL_0026: dup - IL_0027: stloc.0 - IL_0028: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_002d: ldc.i4.1 - IL_002e: ret - IL_002f: ldarg.0 - IL_0030: ldc.i4.m1 - IL_0031: dup - IL_0032: stloc.0 - IL_0033: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - .try - { - IL_0038: ldstr ""exception"" - IL_003d: newobj ""Sub System.Exception..ctor(String)"" - IL_0042: throw - } - finally - { - IL_0043: ldloc.0 - IL_0044: ldc.i4.0 - IL_0045: bge.s IL_0051 - IL_0047: ldstr ""finally "" - IL_004c: call ""Sub System.Console.Write(String)"" - IL_0051: endfinally - } -} -") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " -{ - // Code size 9 (0x9) - .maxstack 2 - IL_0000: ldarg.0 - IL_0001: ldc.i4.s -2 - IL_0003: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0008: ret -} -") + CompileAndVerify(source, expectedOutput:="True one finally exception one False one False one") ' Verify GetEnumerator Dim source2 = @@ -2921,7 +2513,9 @@ Class C Public Shared Iterator Function GetEnumerator(b As Boolean) As System.Collections.Generic.IEnumerator(Of String) Try Yield " one " - Throw New Exception("exception") + If b Then + Throw New Exception("exception") + End If Finally Console.Write("finally ") End Try @@ -2931,82 +2525,6 @@ End Class Dim verifier = CompileAndVerify(source, expectedOutput:="True one finally exception one False one") - verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.MoveNext()", " -{ - // Code size 133 (0x85) - .maxstack 3 - .locals init (Boolean V_0, - Integer V_1) - IL_0000: ldarg.0 - IL_0001: ldfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0006: stloc.1 - IL_0007: ldloc.1 - IL_0008: ldc.i4.s -3 - IL_000a: sub - IL_000b: switch ( - IL_002f, - IL_0024, - IL_0024, - IL_0026, - IL_002f) - IL_0024: ldc.i4.0 - IL_0025: ret - IL_0026: ldarg.0 - IL_0027: ldc.i4.m1 - IL_0028: dup - IL_0029: stloc.1 - IL_002a: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_002f: nop - .try - { - IL_0030: ldloc.1 - IL_0031: ldc.i4.s -3 - IL_0033: beq.s IL_003b - IL_0035: ldloc.1 - IL_0036: ldc.i4.1 - IL_0037: beq.s IL_0060 - IL_0039: br.s IL_0048 - IL_003b: ldarg.0 - IL_003c: ldc.i4.m1 - IL_003d: dup - IL_003e: stloc.1 - IL_003f: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0044: ldc.i4.1 - IL_0045: stloc.0 - IL_0046: leave.s IL_0083 - IL_0048: ldarg.0 - IL_0049: ldstr "" one "" - IL_004e: stfld ""C.VB$StateMachine_1_GetEnumerator.$Current As String"" - IL_0053: ldarg.0 - IL_0054: ldc.i4.1 - IL_0055: dup - IL_0056: stloc.1 - IL_0057: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_005c: ldc.i4.1 - IL_005d: stloc.0 - IL_005e: leave.s IL_0083 - IL_0060: ldarg.0 - IL_0061: ldc.i4.m1 - IL_0062: dup - IL_0063: stloc.1 - IL_0064: stfld ""C.VB$StateMachine_1_GetEnumerator.$State As Integer"" - IL_0069: ldstr ""exception"" - IL_006e: newobj ""Sub System.Exception..ctor(String)"" - IL_0073: throw - } - finally - { - IL_0074: ldloc.1 - IL_0075: ldc.i4.0 - IL_0076: bge.s IL_0082 - IL_0078: ldstr ""finally "" - IL_007d: call ""Sub System.Console.Write(String)"" - IL_0082: endfinally - } - IL_0083: ldloc.0 - IL_0084: ret -} -") verifier.VerifyIL("C.VB$StateMachine_1_GetEnumerator.Dispose()", " { // Code size 44 (0x2c)