Add support for IAsyncEnumerable
Right now, in order to return an IAsyncEnumerable you need to use EndpointBaseSync and access the request cancellationToken form HttpContext like this:
public class List : EndpointBaseSync.WithoutRequest.WithResult<IAsyncEnumerable<PropertyListResult>>
{
/// <summary>
/// List all Properties
/// </summary>
[HttpGet("api/[namespace]")]
public override async IAsyncEnumerable<PropertyListResult> Handle()
{
var cancellationToken = HttpContext.RequestAborted;
await Task.CompletedTask;
yield break;
}
}
It would be nice if we could do something like this:
public class List : EndpointBaseAsync.WithoutRequest.WithAsyncEnumerableResult<PropertyListResult>
{
/// <summary>
/// List all Properties
/// </summary>
[HttpGet("api/[namespace]")]
public override async IAsyncEnumerable<PropertyListResult> Handle(CancellationToken cancellationToken = default)
{
await Task.CompletedTask;
yield break;
}
}
See also https://github.com/jbogard/MediatR/pull/574#issue-736342983 as a reference for the needed targetframework changes.
#176 is waiting for merge. targetframework has been bumped to netcore3.1 with #180 and so no need to change targets anymore
Feature is now in main. Issue can be closed <3
is the only thing missing, a new nuget version?
I guess it has been a while...
are you sure? 4.0.1 does not include WithAsyncEnumerableResult