Skip to content

[Proposal] Support extra generic type params in custom AsyncMethodBuilders #3723

@MMJZ

Description

@MMJZ

Currently C# will fail to compile any async block using a type with one than one generic type parameter.

I believe this is so that the type T in SetResult(T result) on AsyncMethodBuilder types has an obvious type parameter.

I propose that this requirement be relaxed, so that AsyncMethodBuilders can have arbitrary type parameters and it's the first of these type parameters that is required in the argument to SetResult. This would allow me to carry extra type information in an async block that doesn't interact with the block itself.

The same issue was raised in #2273 but was framed as a bug rather than a feature request. Supporting multiple type parameters would also allow functionality proposed in issues like #1407 to be more powerful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions