-
Notifications
You must be signed in to change notification settings - Fork 5k
Use prototype Roslyn compiler for runtime-async #115531
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
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 codebase to use the new prototype Roslyn compiler's runtime-async implementation by replacing the deprecated "async2" keyword with the standard "async" keyword and adding runtime async method generation attributes where needed.
- Replaces "async2" with "async" across multiple test files and implementations.
- Adds [RuntimeAsyncMethodGeneration(false)] attributes to selected methods to control async state machine generation.
- Updates project configuration files (Directory.Build.props, NuGet.config) and runtime feature definitions to support the new async feature.
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/tests/async/pgo/pgo.cs | Replaced async2 with async in entry point and aggregate methods. |
src/tests/async/override/override.cs | Updated method signatures in base and derived classes to use async; added generation attributes. |
src/tests/async/objects-captured/objects-captured.cs | Updated async method signatures. |
src/tests/async/object/object.cs | Replaced async2 with async in asynchronous entry and object methods. |
src/tests/async/mincallcost-microbench/mincallcost-microbench.cs | Multiple async2 methods replaced with async and attributes added where needed. |
src/tests/async/implement/implement.cs | Simplified interface and implementation method signatures to use async. |
src/tests/async/gc-roots-scan/gc-roots-scan.cs | Replaced async2 with async in recursive methods. |
src/tests/async/fibonacci-without-yields/fibonacci-without-yields.cs | Updated async method signatures in Fibonacci test. |
src/tests/async/fibonacci-with-yields_struct_return/fibonacci-with-yields_struct_return.cs | Updated async method signatures and return types. |
src/tests/async/fibonacci-with-yields/fibonacci-with-yields.cs | Replaced async2 with async in test and Fibonacci methods. |
src/tests/async/eh-microbench/eh-microbench.cs | Updated multiple async2 method signatures to async and added attributes to benchmarking methods. |
src/tests/async/cse-array-index-byref/cse-array-index-byref.cs | Updated async method signature for hoisted byref test. |
src/tests/async/collectible-alc/collectible-alc.cs | Replaced async2 with async in async entry points and helper methods. |
src/tests/async/awaitingnotasync/awaitingnotasync.cs | Updated async method signature for the async entry point. |
src/tests/async/RuntimeAsyncMethodGenerationAttribute.cs | Added the attribute definition for runtime async generation. |
src/tests/async/Directory.Build.props | Added the features flag for runtime-async and included the attribute file. |
src/tests/Directory.Build.props | Overrode the compiler version to one that supports async changes. |
src/libraries/System.Runtime/ref/System.Runtime.cs | Updated runtime feature to include Async. |
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs | Updated runtime feature support for Async with proper attribute handling. |
NuGet.config | Added a package source for prototype Roslyn compiler testing. |
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs
Outdated
Show resolved
Hide resolved
Tagging subscribers to this area: @dotnet/area-infrastructure-libraries |
@VSadov any info on what I need to set to run tests locally? |
In #115499 (comment)
I think the part about patching the toolset compiler does not apply here. So it is really:
Then do regular:
|
from the failures it looks like it has built the tests successfully 👍, but runtime did not want to load them, because the feature is not enabled in the runtime - the step: |
62739c5
to
03becbe
Compare
<PropertyGroup> | ||
<!-- Override the compiler version with a private build that supports runtime-async --> | ||
<MicrosoftNetCompilersToolsetVersion>5.0.0-1.25259.6</MicrosoftNetCompilersToolsetVersion> | ||
</PropertyGroup> |
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.
Is there a reason to have this in src/tests/Directory.Build.props instead of src/tests/async/Directory.Build.props?
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 don't think this worked when I tried it earlier. Let me try again.
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.
It needs to be here because we don't restore individual test projects (there's too many). Instead we restore the test_dependencies projects and point the individual test projects at those restore results.
One day I'll get this cleaned up I hope.
Yup, this worked, thanks. For now I've kept the tests disabled in PR since we don't want to enable the ifdef. But it looks like everything passes now except the EH test. |
I believe this is all up-to-date now. This PR still keeps all the tests disabled since I'm not building the runtime with the if-def. |
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeFeature.cs
Outdated
Show resolved
Hide resolved
@@ -1,6 +1,7 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<Optimize>True</Optimize> | |||
<Features>$(Features);runtime-async</Features> |
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.
Why some .csproj
need runtime-async=on
and not others?
Any idea why this breaks the EH test? |
There is a known issue with C# compiler. |
@@ -24,7 +25,8 @@ public async Task<int> M1() | |||
|
|||
class Derived1a : IBase1 | |||
{ | |||
public async2 Task<int> M1() | |||
[MethodImpl(MethodImplOptions.Async)] |
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.
Are these necessary?
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 think these were a workaround for the change in the numerical value for the async methodimpl, that C# compiler was not updated for.
I thought that has been fixed and the workaround is no longer necessary. Maybe this one was just missed when others were reverted.
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.
Yup, just missed during cleanup
I pushed a change that also updates the test I added in #115605 to the new style. |
This pulls in the prototype Roslyn compiler from the Roslyn runtime-async prototype branch. Currently the feature in the runtime is gated on a feature flag, so the tests are disabled.
To run the tests locally, do the following:
add_compile_definitions(FEATURE_RUNTIME_ASYNC)
- to enable the feature in the product.DisableProjectBuild
fromsrc\tests\async\Directory.Build.targets