Version Used: c8b5f30
|
public void TryFinally_YieldBreakInDisposeMode(int iterations, string expectedOutput) |
|
{ |
|
string source = @" |
|
using static System.Console; |
|
public class C |
|
{ |
|
public static async System.Collections.Generic.IAsyncEnumerable<int> M() |
|
{ |
|
yield return 1; |
|
await System.Threading.Tasks.Task.CompletedTask; |
|
try |
|
{ |
|
try |
|
{ |
|
Write(""Break ""); |
|
yield break; |
|
} |
|
finally |
|
{ |
|
Write(""Throw ""); |
|
throw null; |
|
} |
|
} |
|
catch |
|
{ |
|
Write(""Caught ""); |
|
yield break; |
|
} |
|
finally |
|
{ |
|
Write(""Finally ""); |
|
} |
|
} |
|
}"; |
|
var comp = CreateCompilationWithAsyncIterator(new[] { Run(iterations), source }, options: TestOptions.DebugExe); |
|
comp.VerifyDiagnostics(); |
|
CompileAndVerify(comp, expectedOutput: expectedOutput); |
|
} |
When this test is run on .NET with ILVerify, the following warning is produced:
[MoveNext]: Leave into try block. { Offset = 0x11a }
Version Used: c8b5f30
roslyn/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAsyncIteratorTests.cs
Lines 4747 to 4784 in c8b5f30
When this test is run on .NET with ILVerify, the following warning is produced: