@@ -74,6 +74,12 @@ public async Task SimpleVoidTaskMethod()
7474 Console . WriteLine ( "After" ) ;
7575 }
7676
77+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
78+ public async Task NoInliningTaskMethod ( )
79+ {
80+ await Task . Yield ( ) ;
81+ }
82+
7783 public async Task TaskMethodWithoutAwait ( )
7884 {
7985 Console . WriteLine ( "No Await" ) ;
@@ -115,6 +121,24 @@ public async void AwaitInLoopCondition()
115121 }
116122 }
117123
124+ public async Task AwaitConfigureAwaitFalse ( Task < int > task )
125+ {
126+ #if ROSLYN2
127+ Console . WriteLine ( await task . ConfigureAwait ( continueOnCapturedContext : false ) ) ;
128+ #else
129+ Console . WriteLine ( await task . ConfigureAwait ( false ) ) ;
130+ #endif
131+ }
132+
133+ public async Task < int > AwaitConfigureAwaitMixed ( Task < int > task1 , Task < int > task2 )
134+ {
135+ #if ROSLYN2
136+ return await task1 . ConfigureAwait ( continueOnCapturedContext : false ) + await task2 . ConfigureAwait ( continueOnCapturedContext : true ) ;
137+ #else
138+ return await task1 . ConfigureAwait ( false ) + await task2 . ConfigureAwait ( true ) ;
139+ #endif
140+ }
141+
118142#if CS60
119143 public async Task AwaitInCatch ( bool b , Task < int > task1 , Task < int > task2 )
120144 {
@@ -359,6 +383,127 @@ public async Task<object> Issue2436()
359383 }
360384 return new object ( ) ;
361385 }
386+
387+ public async Task TryCatchFinallyAllAwait ( )
388+ {
389+ try
390+ {
391+ await Task . CompletedTask ;
392+ Console . WriteLine ( "try" ) ;
393+ }
394+ catch ( Exception )
395+ {
396+ await Task . CompletedTask ;
397+ Console . WriteLine ( "catch" ) ;
398+ }
399+ finally
400+ {
401+ await Task . CompletedTask ;
402+ Console . WriteLine ( "finally" ) ;
403+ }
404+ }
405+
406+ public async Task ThrowInsideTryFinally ( )
407+ {
408+ try
409+ {
410+ throw new InvalidOperationException ( ) ;
411+ }
412+ finally
413+ {
414+ await Task . Yield ( ) ;
415+ }
416+ }
417+
418+ public async Task HeterogeneousMultiCatch1 ( )
419+ {
420+ try
421+ {
422+ await Task . Yield ( ) ;
423+ }
424+ catch ( InvalidOperationException ex )
425+ {
426+ await Task . Yield ( ) ;
427+ Console . WriteLine ( ex . Message ) ;
428+ }
429+ catch ( ArgumentException ex2 )
430+ {
431+ await Task . Yield ( ) ;
432+ Console . WriteLine ( ex2 . Message ) ;
433+ }
434+ }
435+
436+ public async Task HeterogeneousMultiCatch2 ( )
437+ {
438+ try
439+ {
440+ await Task . Yield ( ) ;
441+ }
442+ catch ( InvalidOperationException ex )
443+ {
444+ await Task . Yield ( ) ;
445+ Console . WriteLine ( ex . Message ) ;
446+ }
447+ catch
448+ {
449+ await Task . Yield ( ) ;
450+ Console . WriteLine ( "other" ) ;
451+ }
452+ }
453+
454+ public async Task HeterogeneousMultiCatch3 ( )
455+ {
456+ try
457+ {
458+ await Task . Yield ( ) ;
459+ }
460+ catch ( InvalidOperationException ex )
461+ {
462+ await Task . Yield ( ) ;
463+ Console . WriteLine ( ex . Message ) ;
464+ }
465+ catch ( Exception )
466+ {
467+ await Task . Yield ( ) ;
468+ throw ;
469+ }
470+ }
471+ #if RUNTIMEASYNC
472+ // The state-machine async lowering doesn't recognize return-from-try-with-await-in-finally
473+ // and decompiles these as `int result; try { ... } finally { ... } return result;`. The
474+ // runtime-async exception rewrite recovers the source-level form. Gate these tests so the
475+ // (state-machine) Async test doesn't run them against the more aggressive output.
476+ public async Task < int > ReturnFromTryFinally ( )
477+ {
478+ try
479+ {
480+ return 42 ;
481+ }
482+ finally
483+ {
484+ await Task . CompletedTask ;
485+ }
486+ }
487+
488+ public async Task < int > ReturnFromInsideNestedTryFinally ( )
489+ {
490+ try
491+ {
492+ try
493+ {
494+ return 42 ;
495+ }
496+ finally
497+ {
498+ await Task . CompletedTask ;
499+ }
500+ }
501+ finally
502+ {
503+ await Task . CompletedTask ;
504+ }
505+ }
506+ #endif
362507#endif
363508
364509 public static async Task < int > GetIntegerSumAsync ( IEnumerable < int > items )
0 commit comments