-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add RuntimeAsyncMethodGenerationAttribute #77543
Add RuntimeAsyncMethodGenerationAttribute #77543
Conversation
Adds control for whether to use runtime async. The flowchart is as follows: 1. The flag `System.Runtime.CompilerServices.RuntimeFeature.Async` must be present. 2. Assuming that flag is present, we look for the presence of `System.Runtime.CompilerServices.RuntimeAsyncMethodGenerationAttribute` on the method. If that attribute is present, we use the preference expressed in the attribute. The preference does not carry to nested contexts, such as local functions or lambdas. 3. If the attribute is not present, we look for `features:runtime-async=on` on the command line. If that is present, then the feature is on by default. Otherwise, the feature is off.
@jcouv @RikkiGibson for reviews please. |
Just to confirm, my understanding is that the flag will be present in .NET 10, but marked with [Experimental]. Is that correct? Refers to: src/Compilers/CSharp/Portable/Compilation/CSharpCompilation.cs:323 in cd76c3b. [](commit_id = cd76c3b, deletion_comment = False) |
That's my understanding as well. Also |
SourceMethodSymbol { IsRuntimeAsyncEnabledInMethod: ThreeState.True } => true, | ||
SourceMethodSymbol { IsRuntimeAsyncEnabledInMethod: ThreeState.False } => false, | ||
_ => Feature("runtime-async") == "on" | ||
}; |
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.
Let's update the compiler spec for how those three flags (runtime feature flag, compiler feature flag, method-level attribute) work together
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.
Will update in main after this PR.
...rs/CSharp/Portable/Symbols/Attributes/WellKnownAttributeData/MethodWellKnownAttributeData.cs
Outdated
Show resolved
Hide resolved
src/Compilers/CSharp/Portable/Symbols/Source/SourceMethodSymbolWithAttributes.cs
Outdated
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.
Done with review pass (iteration 3). Tests not looked at yet
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 (iteration 4)
Adds control for whether to use runtime async. The flowchart is as follows:
System.Runtime.CompilerServices.RuntimeFeature.Async
must be present.System.Runtime.CompilerServices.RuntimeAsyncMethodGenerationAttribute
on the method. If that attribute is present, we use the preference expressed in the attribute. The preference does not carry to nested contexts, such as local functions or lambdas.features:runtime-async=on
on the command line. If that is present, then the feature is on by default. Otherwise, the feature is off.Relates to test plan #75960