Skip to content

Fix IAsyncEnumerable<object> CreateStream for Value Types#37

Merged
martinothamar merged 5 commits intomartinothamar:mainfrom
Tornhoof:FixAsyncEnumStruct
May 30, 2022
Merged

Fix IAsyncEnumerable<object> CreateStream for Value Types#37
martinothamar merged 5 commits intomartinothamar:mainfrom
Tornhoof:FixAsyncEnumStruct

Conversation

@Tornhoof
Copy link
Copy Markdown
Contributor

This adds a special case for IAsyncEnumerable CreateStream if the response type is a struct.
It then calls a wrapper method for the async object enumeration.
I chose the simple wrapper method approach, instead of writing some custom type as the automatically generated state machines for async enumerables contain quite a lot of optimization w.r.t IValueTaskSource etc. according to https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/november/csharp-iterating-with-async-enumerables-in-csharp-8
Closes #36

@Tornhoof Tornhoof changed the title Fix async enum struct Fix IAsyncEnumerable<object> CreateStream for Value Types May 30, 2022
@Tornhoof
Copy link
Copy Markdown
Contributor Author

Tornhoof commented May 30, 2022

The test failure is not related to my changes, apparently VS 17.2 Roslyn broke the test 'Mediator.SourceGenerator.Tests.CleanArchitectureSampleTests.Test_Source_Gen'. The failure happens on main too.

It worked with an older 6.0 sdk (from VS 17.1.6)

@martinothamar
Copy link
Copy Markdown
Owner

Thanks for finding and fixing 👍 I see the test failure is unrelated, will merge and look into the buggy test

@martinothamar martinothamar merged commit cd4e091 into martinothamar:main May 30, 2022
@Tornhoof Tornhoof deleted the FixAsyncEnumStruct branch May 30, 2022 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SourceGenerator generates an error for IStreamRequest with structs

2 participants