Skip to content

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

@Gordory

Description

@Gordory

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions