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 27e1d8c011
This commit is contained in:
N. Taylor Mullen 2019-02-07 09:47:42 -08:00
parent 824796b4e4
commit abd5ab8080
1 changed files with 12 additions and 1 deletions

View File

@ -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()".