-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add proposal for async main codegen update #9826
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
AlekseyTs
left a comment
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 (commit 2)
| + Otherwise, the synthesized entry point waits for the returned task to complete, either passing the task to `System.Runtime.CompilerServices.AsyncHelpers.HandleAsyncEntryPoint` (if it exists) or calling `GetAwaiter().GetResult()` on the task, using either the parameterless instance method or the extension method described by [§C.3](standard-library.md#c3-standard-library-types-not-defined-in-isoiec-23271). If the task fails, the calling method form will throw an exception, and this exception is propagated by the synthesized method. | ||
| ``` | ||
|
|
||
| The compiler will look for the following APIs from the core libraries. We do not look at implementations defined outside the core library: |
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.
How is the determination in the second sentence accomplished?
Also, why add this restriction?
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.
The determination is done in the same way all core libraries checks are made.
The restriction is there because this is a key runtime scenario. Looking for user-defined handling isn't relevant.
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'm not able to find an example of the C# specification stating that any of the standard library APIs must not be found in third-party references. Do you know of an example of such an API where the compiler already has that requirement?
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.
All of the special types, anything coming from runtime async, all of the first-class span feature work, all of string.Concat, anything to do with decimal... anything in this file must come from corelib.
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.
any of the standard library APIs must not be found in third-party references
Nothing about the specification or this proposal states that other references cannot define methods. It just states that we won't use it.
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.
The current C# implementation depends on a reference being given from the SDK as a way to provide that API set, and thus it errors if these APIs are not present, right? In what way does this text require that the APIs came from a particular one of the references passed to the compiler from the SDK? If the compiler can "provide" one of these APIs by getting it from an SDK-provided reference, why can't it "provide" one of these APIs by getting it from a third-party-provided reference?
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.
This text requires that these types come from the BCL. I don't see any other way of reading it.
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 see it saying that the compiler shall provide the APIs in both C.2 and C.3, where only C.2 is related to something called Base Class Library published in ISO/IEC 23271:2012. It seems presented explicitly as happenstance that some of these are in C.2 and some are in C.3, with an explicit reference to this distinction shifting if a potential newer version of ISO/IEC 23271:2012 is produced. I don't see the process defined anywhere for a compiler to consider some references to be BCL references and other references not to be.
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.
The compiler does not provide any of these APIs. The APIs defined in C.2 must come from the BCL because they are defined in the BCL, as per "For a formal definition of the types and their members identified in (§C.2), refer to ISO/IEC 23271:2012 Common Language Infrastructure (CLI), Partition IV; Base Class Library (BCL), Extended Numerics Library, and Extended Array Library, which are included by reference in this specification."
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'm seeing a "this is how it already is" but no requirements or instructions for an implementation. I'm not sure how to bring this thread home, so I'll let it go. I don't think this will affect language users, only potentially those who are incorporating the proposals into the standard.
| public class AsyncHelpers | ||
| { | ||
| public static void HandleAsyncEntryPoint(System.Threading.Tasks.Task task); | ||
| public static void HandleAsyncEntryPoint(System.Threading.Tasks.Task<int> task); |
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.
| public static void HandleAsyncEntryPoint(System.Threading.Tasks.Task<int> task); | |
| public static int HandleAsyncEntryPoint(System.Threading.Tasks.Task<int> task); |
No description provided.