Skip to content

Conversation

@MichalStrehovsky
Copy link
Member

  1. When compiling a library, compile all methods including async variants.
  2. When enumerating methods on types, generate variants for every task returning method, not just virtuals.

The 2 is a bit surprising but it matches what we now do in

if (pResolvedToken.tokenType == CorInfoTokenKind.CORINFO_TOKENKIND_Await)
{
// in rare cases a method that returns Task is not actually TaskReturning (i.e. returns T).
// we cannot resolve to an Async variant in such case.
// return NULL, so that caller would re-resolve as a regular method call
method = method.GetTypicalMethodDefinition().Signature.ReturnsTaskOrValueTask()
? _compilation.TypeSystemContext.GetAsyncVariantMethod(method)
: null;
}
. We originally restricted this to methods being runtimeasync but changed it in https://github.com/dotnet/runtime/pull/121622/files#diff-132a77bcd3f74cf0e0b04fbccda246c97c91e40562d78cb01fff61cf69403573L1860.

Cc @dotnet/ilc-contrib

1. When compiling a library, compile all methods including async variants.
2. When enumerating methods on types, generate variants for every task returning method, not just virtuals.

The 2 is a bit surprising but it matches what we now do in https://github.com/dotnet/runtime/blob/d31e5990b896447bfc3dbe98cfe6ec3b169a4896/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs#L1849-L1857. We originally restricted this to methods being runtimeasync but changed it in https://github.com/dotnet/runtime/pull/121622/files#diff-132a77bcd3f74cf0e0b04fbccda246c97c91e40562d78cb01fff61cf69403573L1860.
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a 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 fixes async method handling in multifile compilation by ensuring async variants are generated for all Task-returning methods during library compilation.

Key Changes:

  • Modified library compilation to include async variants of methods
  • Expanded async variant generation from only virtual/async methods to all Task-returning ECMA methods
  • Added proper type checking to ensure only ECMA methods get async variants

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
LibraryRootProvider.cs Updated to enumerate methods with async variants during library compilation
CompilerTypeSystemContext.Async.cs Broadened async variant generation logic from virtual/async-only to all Task-returning ECMA methods, with updated comments explaining the rationale

@MichalStrehovsky MichalStrehovsky merged commit 2bb5fc6 into dotnet:main Dec 11, 2025
102 of 108 checks passed
@MichalStrehovsky MichalStrehovsky deleted the allmethods branch December 11, 2025 20:55
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants