Skip to content
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

Using of GetAwaiter().GetResult() from ValueTask<T> in EnumeratorAdapter #66

Open
Gordory opened this issue Jan 19, 2021 · 0 comments
Open

Comments

@Gordory
Copy link

Gordory commented Jan 19, 2021

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:

  • This Dispose code in AsyncEnumerator, which can be a bigger problem than I found.
  • This extension method AsyncEnumerableAdapterExtensions.MoveNext leaved for backward compatibility.
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

No branches or pull requests

1 participant