-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Add support for IAsyncEnumerable<T> where T is value type (#17154) #17563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Moved to Mar as per Tactics. Will need to be explicitly approved for Feb, if required. |
I believe this should be back to 3.1.2 now. @pranavkm / @mkArtakMSFT can we get this merged by EOD today? |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 2 pipeline(s). |
* Add support for IAsyncEnumerable<T> where T is value type Fixes #17139
584c9c5
to
072741c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the change to blazor.server.js
is accidental and should be reverted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for removing the unwanted change!
#17155
Description
In 3.0, we added support for IAsyncEnumerable in MVC. Essentially you are allowed to return an IAsyncEnumerable and MVC will serialize the contents for you without a blocking wait. Here’s some of the docs for it in action: https://docs.microsoft.com/en-us/aspnet/core/web-api/action-return-types?view=aspnetcore-3.0#return-ienumerablet-or-iasyncenumerablet. In the current implementation, MVC will asynchronously read IAsyncEnumerable types, buffer it until the stream is exhausted (or we hit some user configured limit), and then serialize the contents.
However, currently this feature only works when the type T is a reference type. When T is a value type, we pass the IAsyncEnumerable instance directly to the serializer. IAsyncEnumerable doesn’t implement IEnumerable or any other collection contracts, so serializers end up returning an empty object. We got our first report of the issue today - #17139 where the user was surprised returning an IAsyncEnumerable produced an empty object.
Customer Impact
Returning an
IAsyncEnumerable<T>
where T is a value type results in no JSON outputRegression?
No, the feature hasn't worked correctly since it was introduced.
Risk
Low. The feature does not currently work correctly, so we do not expect users to be broken by this when it starts working. The code change is fairly minimal and well tested.