From 92f6c6f3e6643c52935b26d3f97cd6a1b4c82c7a Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sat, 4 Jul 2026 13:14:14 +0200 Subject: [PATCH] Add pretty tests for await in expression positions await inside a null-coalescing expression, as a do-while condition, on a ValueTask, and inside an interpolated-string hole (the DefaultInterpolatedStringHandler lowering) were not covered. Assisted-by: Claude:claude-fable-5:Claude Code --- .../TestCases/Pretty/Async.cs | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs index f5d2e7a71..2c4e38545 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/Async.cs @@ -583,6 +583,39 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty } } #endif + +#if ROSLYN + // The legacy csc lowering of await inside the null-coalescing operator is not + // reconstructed; the raw awaiter state machine leaks into the output. + public static async Task AwaitInCoalesce(Task t, Task u) + { + return (await t) ?? (await u); + } +#endif + + public static async Task DoWhileAwaitCondition(Func> t) + { + do + { + Console.WriteLine("body"); + } while (await t()); + } + +#if CS70 && !NET40 + // The legacy csc and Roslyn 1.x configurations compile against the legacy + // .NET Framework reference assemblies, which have no ValueTask. + public static async Task AwaitValueTask(ValueTask t) + { + return await t + 1; + } +#endif + +#if CS100 && !NET40 + public static async Task AwaitInInterpolationHole(Task t) + { + return $"val={await t,5:x} end"; + } +#endif } public struct AsyncInStruct