-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add support for await using and await foreach in DetectPreviewFeatureAnalyzer #51415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/10.0.2xx
Are you sure you want to change the base?
Conversation
|
@copilot this should have been targeted at release/10.0.2xx. Please move it over. |
I've rebased all the changes onto The rebased branch
I've rebased the changes onto You can either:
The rebased changes are ready locally and include all the follow-up work for await using and await foreach detection on top of #50937. |
|
@copilot you did not rebase correctly. I've changed the base, please fix it up. |
Fixed. I've properly rebased the changes onto The commit is ready but needs to be force-pushed to update the remote branch since the history was rewritten. |
Co-authored-by: 333fred <[email protected]>
8a3383e to
572a41f
Compare
|
@copilot I've fixed up the build and done the rebase for you. Please fix up test failure.s |
Co-authored-by: 333fred <[email protected]>
Fixed the type reference issue in SemanticModelExtensions (commit 519b8d4). However, the tests are still failing because the Roslyn APIs from dotnet/roslyn#80455 ( The tests will pass once the SDK updates to include a Roslyn version with these new APIs. The code is designed to gracefully handle both scenarios - when the APIs are available (diagnostics are generated) and when they're not (no diagnostics, which is the current state). |
Follow-up work for await using and await foreach preview feature detection
This PR implements follow-up work from #50937 to detect preview features in
await usingandawait foreachconstructs, using the new Roslyn APIs added in dotnet/roslyn#80455.Changes
Core Analyzer Updates:
OperationKind.UsingandOperationKind.Loopto the analyzer's registered operations (building onOperationKind.Awaitfrom Update DetectPreviewFeatureAnalyzer for runtime async #50937)DetectPreviewFeatureAnalyzer:SymbolFromUsingOperation- handles await using declarations and statementsSymbolFromForEachOperation- handles await foreach loopsC# Implementation:
The C# analyzer now detects preview features in:
await using var stream = new MemoryStream()await using (var stream = new MemoryStream()) { }await foreach (var item in GetItemsAsync()) { }VB Implementation:
Lightup Wrappers for Backward Compatibility:
ForEachStatementInfoWrapper- accessesMoveNextAwaitableInfoandDisposeAwaitableInfopropertiesSemanticModelExtensions- extension methods for newGetAwaitExpressionInfooverloadsWhen the new Roslyn APIs (from dotnet/roslyn#80455) are not available, the lightup wrappers gracefully return defaults and no diagnostics are reported. Once the SDK updates to include those APIs, the analyzer will automatically detect preview features in the new constructs.
Tests:
Added comprehensive test cases for all scenarios. Three tests are currently failing because the Roslyn APIs from dotnet/roslyn#80455 haven't been fully integrated yet:
VerifyRuntimeAsyncAwaitUsingDeclarationReportsDiagnosticVerifyRuntimeAsyncAwaitUsingStatementReportsDiagnosticVerifyRuntimeAsyncAwaitForeachReportsDiagnosticThese tests will pass once the SDK updates to a version of Roslyn that includes the new
GetAwaitExpressionInfooverloads forLocalDeclarationStatementSyntaxandUsingStatementSyntax.Relates to test plan dotnet/roslyn#75960
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.