-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Update DetectPreviewFeatureAnalyzer for runtime async #50937
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
Conversation
We need to be giving warnings around enabling preview features for runtime async. This updates the analyzer to do this.
This comment was marked as resolved.
This comment was marked as resolved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the DetectPreviewFeatureAnalyzer to support runtime async features by adding support for detecting when await operations use preview features. The changes specifically add handling for IAwaitOperation
in the analyzer and create infrastructure to check if await expressions use runtime-specific methods that require preview feature opt-in.
- Adds await operation handling to the core analyzer framework
- Implements C# and VB.NET specific symbol extraction for await operations
- Creates lightup wrapper for accessing RuntimeAwaitMethod property
- Adds comprehensive unit tests for runtime async preview feature detection
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
DetectPreviewFeatureUnitTests.Misc.cs | Adds unit tests for verifying runtime async preview feature diagnostics |
LightupHelpers.cs | Changes CreatePropertyAccessor method visibility from private to internal |
AwaitExpressionInfoWrapper.cs | New lightup wrapper for accessing RuntimeAwaitMethod property from AwaitExpressionInfo |
Analyzer.CSharp.Utilities.projitems | Includes the new AwaitExpressionInfoWrapper in the build |
BasicDetectPreviewFeatureAnalyzer.vb | Implements VB.NET-specific SymbolFromAwaitOperation method (returns null) |
DetectPreviewFeatureAnalyzer.cs | Adds await operation support to the core analyzer with abstract method for language-specific handling |
CSharpDetectPreviewFeatureAnalyzer.cs | Implements C#-specific await operation symbol extraction using RuntimeAwaitMethod |
...odeAnalysis.NetAnalyzers/src/Utilities/Compiler.CSharp/Lightup/AwaitExpressionInfoWrapper.cs
Show resolved
Hide resolved
...odeAnalysis.NetAnalyzers/src/Utilities/Compiler.CSharp/Lightup/AwaitExpressionInfoWrapper.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
using Microsoft.CodeAnalysis.Diagnostics; | ||
using Microsoft.CodeAnalysis.Operations; | ||
using Microsoft.NetCore.Analyzers.Runtime; | ||
using Analyzer.Utilities.Lightup; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sort usings?
{ | ||
protected override ISymbol? SymbolFromAwaitOperation(IAwaitOperation operation) | ||
{ | ||
if (operation.Syntax is not AwaitExpressionSyntax awaitSyntax) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider testing with await using
and await foreach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are going to need new public APIs. I'll open a followup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fallbackResult: null); | ||
}); | ||
|
||
return s_RuntimeAwaitMethodAccessor!(info); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | ||
async Task M() | ||
{ | ||
await Task.Yield(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't follow, what's the "custom awaiter" part here. From the name of the test, I expected to see a definition with a custom type with a custom awaiter. Never mind, it's using UnsafeAwaitAwaiter
#Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done with review pass (commit 1)
@jcouv please take another look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks (commit 2)
Failures![]() FullFramework: Windows x64I have no idea. My teammates said we could update the version used for the test, but I don't know why it is failing in this PR. Also, @dsplaisted said:
![]() TemplateEngine Windows x64Also have no idea. It got a completely different set of table outputs with missing entries. Also, the Type and Language columns are not populated. ![]() TestBuild Linux x64This is a know test failure. We just rerun this one until it passes. Thread about it here: #50784 |
We need to be giving warnings around enabling preview features for runtime async. This updates the analyzer to do this.
Relates to test plan dotnet/roslyn#75960