From abd5ab8080afe40e4ecab4b66c19b4cbf1cf5e0b Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 7 Feb 2019 09:47:42 -0800 Subject: [PATCH] Add @await foreach for C# 8 - Added general C# 8 tests that we can use to include nullability when the time comes. - Added statement test to ensure syntax tree is correct for await foreach. aspnet/AspNetCoredotnet/aspnetcore-tooling#5078 \n\nCommit migrated from https://github.com/dotnet/aspnetcore-tooling/commit/27e1d8c0113034b85d7f8443403d9737d21c1c82 --- .../src/Legacy/CSharpCodeParser.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs index b9dc3bc9d2..e0fc7790c1 100644 --- a/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs +++ b/src/Razor/Microsoft.AspNetCore.Razor.Language/src/Legacy/CSharpCodeParser.cs @@ -1651,7 +1651,18 @@ namespace Microsoft.AspNetCore.Razor.Language.Legacy // Therefore, if we're top level then we want to act like an implicit expression, // otherwise just act as whatever we're contained in. var topLevel = transition != null; - if (topLevel) + if (!topLevel) + { + return; + } + + if (At(CSharpKeyword.Foreach)) + { + // C# 8 async streams. @await foreach (var value in asyncEnumerable) { .... } + + ParseConditionalBlock(builder, transition); + } + else { // Setup the Span to be an async implicit expression (an implicit expresison that allows spaces). // Spaces are allowed because of "@await Foo()".