Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I am trying to map a minimal API endpoint as follows:
ArgApp.MapPost("/api/create-account", CreateAccount.HandleHttpAsync);
...the endpoint itself is defined with this signature:
public static async AwaitOnceTask<Response> HandleHttpAsync(HttpRequest ArgRequest, IServiceProvider ArgServices) { }
When I try to run my app, I get the following exception message and stack trace:
System.NotSupportedException: Unsupported return type: AwaitOnceTask<CreateAccount.Response>
at Microsoft.AspNetCore.Http.RequestDelegateFactory.PopulateBuiltInResponseTypeMetadata(Type returnType, EndpointBuilder builder)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.CreateArgumentsAndInferMetadata(MethodInfo methodInfo, RequestDelegateFactoryContext factoryContext)
at Microsoft.AspNetCore.Http.RequestDelegateFactory.InferMetadata(MethodInfo methodInfo, RequestDelegateFactoryOptions options)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.CreateRouteEndpointBuilder(RouteEntry entry, RoutePattern groupPrefix, IReadOnlyList`1 groupConventions, IReadOnlyList`1 groupFinallyConventions)
at Microsoft.AspNetCore.Routing.RouteEndpointDataSource.get_Endpoints()
The problem seems to be the return type AwaitOnceTask<CreateAccount.Response> which uses a custom task type I have created called AwaitOnceTask<T>.
Describe the solution you'd like
The docs currently say that:
Minimal endpoints support the following types of return values:
- string - This includes
Task<string> and ValueTask<string>.
- T (Any other type) - This includes
Task<T> and ValueTask<T>.
- IResult based - This includes
Task<IResult> and ValueTask<IResult>.
...this means support for async endpoints is already included but seems to be hardcoded to just Task<T> or ValueTask<T> . It would be great if the logic in Microsoft.AspNetCore.Http.RequestDelegateFactory was written to support any task type that can be defined in C#, not just the native Task<T> or ValueTask<T>.
Additional context
No response
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
I am trying to map a minimal API endpoint as follows:
...the endpoint itself is defined with this signature:
When I try to run my app, I get the following exception message and stack trace:
The problem seems to be the return type
AwaitOnceTask<CreateAccount.Response>which uses a custom task type I have created calledAwaitOnceTask<T>.Describe the solution you'd like
The docs currently say that:
...this means support for async endpoints is already included but seems to be hardcoded to just
Task<T>orValueTask<T>. It would be great if the logic inMicrosoft.AspNetCore.Http.RequestDelegateFactorywas written to support any task type that can be defined in C#, not just the nativeTask<T>orValueTask<T>.Additional context
No response