Skip to content

Commit 057a25b

Browse files
Cover ConfigureAwait in the Async pretty test fixture.
Two methods exercise `Task<int>.ConfigureAwait(bool)`: a single false-flag form and a mixed false/true form that combines two awaits in a return expression. Both cases run through the regular state-machine and runtime-async pipelines (RuntimeAsync reuses Async.cs as its source). Gated by `#if ROSLYN2` because Roslyn 2+ preserves named-argument metadata at the call site, so the decompiler renders `continueOnCapturedContext: false` when the binary was compiled by Roslyn 2+ and positional `false` for default csc / Roslyn 1.3.2. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 896fb16 commit 057a25b

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

  • ICSharpCode.Decompiler.Tests/TestCases/Pretty

ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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
{

0 commit comments

Comments
 (0)