Custom AsyncMethodBuilder method overloads #61574
Unanswered
timcassell
asked this question in
General
Replies: 1 comment 17 replies
-
You would need an addition to the language/ compiler. But why do you need overloads rather than just dynamically type testing the TAwaiter? The latter is what the built-in builders do for special-casing the awaiters they know about, no overloads required. |
Beta Was this translation helpful? Give feedback.
17 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried adding method overloads for my custom builder to add a feature for my library in async functions, using the awaiter type.
Using the builder with those overloads directly works as I expect:
But when I tested it with an actual
async Promise
function, it printedAwaitUnsafeOnCompleted default
.So the compiler chose to use the default overload despite the existence of the better overload candidate that the direct call uses.
Is this possible to work this way? Does this need to be a new feature request to allow this?
I'm not sure if this should be in runtime or csharplang.
@stephentoub
[Edit] I understand why this is the case (the compiler always includes the
<TAwaiter, TStateMachine>
type arguments to the method call explicitly), but is it possible to override that for specific types?Beta Was this translation helpful? Give feedback.
All reactions