[RuntimeAsync] Treat calls to async helpers in non-async callers as invalid IL

Open
#118,186 1 comment 1 reaction 2 assignees View on GitHub

@jakobbotsch is already working on this.

Since Apr 17, 2026.

  • #130397 by @copilot-swe-agent — open

Assessment

This issue has not been assessed yet.

Description

area-CodeGen-coreclr runtime-async

Re: https://github.com/dotnet/runtime/pull/118045/files#r2233249240

It is possible to construct IL where calls to non-task-returning async methods like AsyncHelpers.Await happen in nonasync callers. It is unlikely that this can work correctly in some random method. It is better if JIT refuses to compile calls to non-task returning async methods if the calee is not async.

One caveat - we may have a few places in the implementation of async itself (like in async thunks) where this practice is legal because the code explicitly arranges handling for suspension/continuations. That would need to be allowed.

Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/runtime

All issues in dotnet/runtime

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.