Skip to content

Conversation

@333fred
Copy link
Member

@333fred 333fred commented Nov 17, 2025

No description provided.

@333fred 333fred requested a review from a team as a code owner November 17, 2025 18:28
Copy link
Contributor

@AlekseyTs AlekseyTs left a 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:
Copy link
Contributor

@jnm2 jnm2 Nov 17, 2025

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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.

Copy link
Contributor

@jnm2 jnm2 Nov 18, 2025

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?

Copy link
Member Author

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.

Copy link
Contributor

@jnm2 jnm2 Nov 19, 2025

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.

Copy link
Member Author

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."

Copy link
Contributor

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.

Co-authored-by: Joseph Musser <[email protected]>
public class AsyncHelpers
{
public static void HandleAsyncEntryPoint(System.Threading.Tasks.Task task);
public static void HandleAsyncEntryPoint(System.Threading.Tasks.Task<int> task);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public static void HandleAsyncEntryPoint(System.Threading.Tasks.Task<int> task);
public static int HandleAsyncEntryPoint(System.Threading.Tasks.Task<int> task);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants