Skip to content

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

Merged
merged 3 commits into from
Jan 16, 2020

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Dec 3, 2019

  • Add support for IAsyncEnumerable where T is value type

#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 output

Regression?

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.

@pranavkm pranavkm added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Dec 3, 2019
@pranavkm pranavkm added this to the 3.1.x milestone Dec 3, 2019
@mkArtakMSFT mkArtakMSFT added the Servicing-consider Shiproom approval is required for the issue label Dec 3, 2019
@leecow leecow added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Dec 5, 2019
@leecow leecow modified the milestones: 3.1.x, 3.1.2 Dec 5, 2019
@vivmishra vivmishra modified the milestones: 3.1.2, 3.1.3 Jan 9, 2020
@vivmishra
Copy link

Moved to Mar as per Tactics. Will need to be explicitly approved for Feb, if required.

@vivmishra vivmishra closed this Jan 9, 2020
@vivmishra vivmishra reopened this Jan 9, 2020
@Pilchie
Copy link
Member

Pilchie commented Jan 15, 2020

I believe this should be back to 3.1.2 now. @pranavkm / @mkArtakMSFT can we get this merged by EOD today?

@Pilchie
Copy link
Member

Pilchie commented Jan 15, 2020

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@Pilchie Pilchie modified the milestones: 3.1.3, 3.1.2 Jan 15, 2020
@pranavkm
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

* Add support for IAsyncEnumerable<T> where T is value type

Fixes #17139
Copy link
Member

@SteveSandersonMS SteveSandersonMS left a 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.

Copy link
Member

@SteveSandersonMS SteveSandersonMS left a 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!

@mkArtakMSFT mkArtakMSFT merged commit 6a8ce3a into release/3.1 Jan 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates Servicing-approved Shiproom has approved the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants