Conversation
|
@dotnet/roslyn-compiler for review. Suggest reviewing commit-by-commit: the first commit consolidates await information into the same location as the rest of the enumeration info, the second actually adds the API. |
src/Compilers/CSharp/Portable/Compilation/MemberSemanticModel.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Test/Symbol/Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests.csproj
Show resolved
Hide resolved
jcouv
left a comment
There was a problem hiding this comment.
Done with review pass (commit 3)
|
@jcouv @dotnet/roslyn-compiler for review |
|
I've already approved the latest commit. It looks like there's a merge conflict to resolve though |
Whoops, sorry. Apparently github didn't load that comment, I'd only seen the commit 3 comments. |
|
|
||
| public override AwaitExpressionInfo GetAwaitExpressionInfo(LocalDeclarationStatementSyntax node) | ||
| { | ||
| return GetEnclosingMemberModel(node).GetAwaitExpressionInfo(node); |
|
|
||
| public override AwaitExpressionInfo GetAwaitExpressionInfo(UsingStatementSyntax node) | ||
| { | ||
| return GetEnclosingMemberModel(node).GetAwaitExpressionInfo(node); |
| public override AwaitExpressionInfo GetAwaitExpressionInfo(LocalDeclarationStatementSyntax node) | ||
| { | ||
| MemberSemanticModel memberModel = GetMemberModel(node); | ||
| return memberModel == null ? default(AwaitExpressionInfo) : memberModel.GetAwaitExpressionInfo(node); |
There was a problem hiding this comment.
Yes, the existing tests go through here.
| public override AwaitExpressionInfo GetAwaitExpressionInfo(UsingStatementSyntax node) | ||
| { | ||
| MemberSemanticModel memberModel = GetMemberModel(node); | ||
| return memberModel == null ? default(AwaitExpressionInfo) : memberModel.GetAwaitExpressionInfo(node); |
There was a problem hiding this comment.
Yes, the existing tests go through here.
| return RewriteInlineArrayForEachStatementAsFor(node); | ||
| } | ||
| else if (node.AwaitOpt is null && CanRewriteForEachAsFor(node.Syntax, nodeExpressionType, out var indexerGet, out var lengthGetter)) | ||
| else if (node.EnumeratorInfoOpt is { MoveNextAwaitableInfo: null } && CanRewriteForEachAsFor(node.Syntax, nodeExpressionType, out var indexerGet, out var lengthGetter)) |
| SyntaxNode syntax = boundForEachStatement.Syntax; | ||
| bool isImplicit = boundForEachStatement.WasCompilerGenerated; | ||
| bool isAsynchronous = boundForEachStatement.AwaitOpt != null; | ||
| bool isAsynchronous = boundForEachStatement.EnumeratorInfoOpt is { IsAsync: true }; |
|
|
||
| var expectedOperationTree = @" | ||
| IBlockOperation (1 statements) (OperationKind.Block, Type: null) (Syntax: '{ ... }') | ||
| IForEachLoopOperation (LoopKind.ForEach, IsAsynchronous, Continue Label Id: 0, Exit Label Id: 1) (OperationKind.Loop, Type: null) (Syntax: 'await forea ... }') |
There was a problem hiding this comment.
As discussed offline, this is because of the error scenario that causes EnumeratorInfoOpt to not be populated. I'll investigate a followup change after to base this flag on just whether the loop is await foreach.
| { | ||
| if (semanticModel is CSharpSemanticModel csmodel) | ||
| { | ||
| return csmodel.GetAwaitExpressionInfo(awaitUsingDeclaration); |
There was a problem hiding this comment.
Yes, TestAwaitUsingDeclarationAwaitInfo
| { | ||
| if (semanticModel is CSharpSemanticModel csmodel) | ||
| { | ||
| return csmodel.GetAwaitExpressionInfo(awaitUsingStatement); |
There was a problem hiding this comment.
Yes, TestAwaitUsingStatementAwaitInfo
|
Done with review pass (commit 4) #Closed |
* upstream/main: (149 commits) Fix Simplify and add additional asserts Update proposal adjuster to acquire feature flags from VS (dotnet#80541) Remove First/Last Docs Docs Deprecate method and use workaround Remove support for ccreating EmbeddedStrings Remove methods Move more into extensions Move more into extensions Proper slice Proper slice Proper slice Move to slices Extract extensions Downstream Simplify the virtual char api Add telemetry indicating when file-based programs are used (dotnet#80538) Fix thread safety issue in BuildServerConnection.TryCreateServer environment variable handling (dotnet#80498) ...
* upstream/main: Extensions: Close some tracked follow-ups (dotnet#80527) Fix outdated 17.15 to 18.0 (dotnet#80570) Update dependencies from https://github.com/dotnet/dotnet build 285582 (dotnet#80551) Fix all-in-one tests [main] Update dependencies from dotnet/arcade (dotnet#80559) Improve error recovery when object initializer uses ':' instead of '=' (dotnet#80553) Support `field` keyword in EE. (dotnet#80515) Log a debug message for ContentModified exceptions. (dotnet#80549) Update dependencies from https://github.com/dotnet/arcade build 20251002.2 (dotnet#80550)
* upstream/main: (252 commits) Move Watch EA to a separate assembly Microsoft.CodeAnalysis.ExternalAccess.HotReload (dotnet#80556) Enable long paths for Windows DartLab CI (dotnet#80581) Ensure that CS8659 is reported on partial properties (dotnet#80573) Fix a wrong relative link in a doc (dotnet#80567) [main] Source code updates from dotnet/dotnet (dotnet#80578) Update dependencies from https://github.com/dotnet/arcade build 20251006.2 (dotnet#80577) Update main configs after VS snap (dotnet#80523) Add followup async public apis (dotnet#80455) Reduce allocations in CSharpSyntaxNode.GetStructure (dotnet#80562) Extensions: Close some tracked follow-ups (dotnet#80527) Fix outdated 17.15 to 18.0 (dotnet#80570) Update dependencies from https://github.com/dotnet/dotnet build 285582 (dotnet#80551) Fix all-in-one tests [main] Update dependencies from dotnet/arcade (dotnet#80559) Improve error recovery when object initializer uses ':' instead of '=' (dotnet#80553) Support `field` keyword in EE. (dotnet#80515) Log a debug message for ContentModified exceptions. (dotnet#80549) Update dependencies from https://github.com/dotnet/arcade build 20251002.2 (dotnet#80550) Fix Simplify and add additional asserts ...
Adds the followup APIs for await using and await foreach. Closes #80409.
Relates to test plan #75960