-
Notifications
You must be signed in to change notification settings - Fork 5k
[RuntimeAsync] ilasm/ildasm support for the MethodImpl.Async (Take 2) #115658
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: main
Are you sure you want to change the base?
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 extends the support for MethodImpl attributes to include the async keyword, treating it similarly to other attributes like nooptimization and aggressiveoptimization.
- Added the async keyword definition in the ilasm header file.
- Updated the disassembler and parser grammar files to handle async as a valid attribute.
- Introduced a new token ASYNC_ in the parser definition for method implementation attributes.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
src/coreclr/inc/il_kywd.h | Added async attribute definition to the keyword table |
src/coreclr/ildasm/dasm.cpp | Added check to output " async" when the method is async |
src/coreclr/ilasm/prebuilt/asmparse.grammar | Updated grammar to accept async as an identifier |
src/coreclr/ilasm/asmparse.y | Added async token handling to the parser productions |
Tagging subscribers to this area: @JulieLeeMSFT |
Sounds reasonable to me - as long as it is non-breaking.
Is there an example of where Roslyn does identifier escaping like that? I am not aware of any. It does not sound right for Roslyn to be aware of keywords in textual IL representation. I see this as a problem specific to textual IL representation, so ilasm/ildasm are the right place to deal with it. |
For example, if you write |
Right, ildasm (and ILSpy?) encloses identifiers that happen to match IL keywords in quotes. These identifiers are not enclosed in quotes in the metadata emitted by Roslyn. For example, the following program prints noinlining without quotes:
|
It seems that all existing keywords defined in
because we have So I believe the correct fix is to take the breaking change here, and audit the existing IL code and correctly escape them. i.e. modifying all I would propose a fix that:
|
What's the problem with this solution? It matches what Roslyn does. When C# introduces a new keyword, they do not break all code that happened to use this keyword as an identifier. They only break code where it introduces ambiguity. For example, We prefer option with less breaking changes when there are multiple equal options. This PR does not need to solve it for all keywords. Switching just methodimpl related keywords to a less breaking plan is good enough for now. |
We still define
async
as a keyword, but allow it to appear as an identifier.cc @VSadov
Test code:
Code after ilasm-ildasm round-trip:
I found we have the same problem for some other MethodImpl attributes such as
nooptimization
,aggressiveinlining
,aggressiveoptimization
etc. Should I fix them as well? @jkotas