AsyncEnumerable
AsyncEnumerable copied to clipboard
Using of GetAwaiter().GetResult() from ValueTask<T> in EnumeratorAdapter
Hi there!
For some reason I used ToEnumerable() extension to iterate IAsyncEnumerable synchronously.
And for sure I got the exception from this line of code.
Documentation tells us that this is not valid call for ValueTask: "The following operations should never be performed on a ValueTask<TResult> instance: ... Using .Result or .GetAwaiter().GetResult() when the operation hasn't yet completed, or using them multiple times".
I know, that I shouldn't use this extension, but I think this still should work correctly.
Also found some more usages of GetAwaiter().GetResult() from ValueTask in your code: