Skip to content

Compiler-Async and Runtime-Async difference for async Task methods #122235

@jkoritzinsky

Description

@jkoritzinsky

For a System.Threading.Tasks.Task-returning async method (the Task-returning variant in a runtime-async world), there's a slight difference in the actual type of the return value that has observable semantics.

In compiler-async, the return value's type is Task<VoidTaskResult>. In runtime-async, the return value's type is a non-generic type.

Built-in COM does not support marshalling non-blittable generic types. As a result, after #122195, it is possible to implement a Task-returning method on an interface that is [ComVisible(true)] with an async Task method and have it successfully return a COM object representing the Task. With compiler-async, the marshalling logic throws an exception because Task<VoidTaskResult> is generic and non-blittable.

I don't know if this is something we care about, but I wanted to raise it as an observable compiler-async/runtime-async difference.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

No status

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions