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

Whither System.Linq.AsyncEnumerable? #29145

Closed
Damien-The-Unbeliever opened this issue Apr 2, 2019 · 11 comments
Closed

Whither System.Linq.AsyncEnumerable? #29145

Damien-The-Unbeliever opened this issue Apr 2, 2019 · 11 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Linq
Milestone

Comments

@Damien-The-Unbeliever
Copy link

IEnumerable has a companion class - System.Linq.Enumerable - that provides LINQ to Objects implementation.

IAsyncEnumerable doesn't seem to have such a companion. Is this a deliberate decision? I can't find any discussion on this but I may be searching wrong.

In the meantime, I've spent a couple of weekends trying to build my own. It doesn't seem undoable but perhaps there's a reason it's undesirable?

(It is, however, undoubtedly tedious to produce all of the overloads)

@jkotas
Copy link
Member

jkotas commented Apr 2, 2019

Take a look at https://github.com/dotnet/reactive and https://www.nuget.org/packages/System.Linq.Async

@jkotas
Copy link
Member

jkotas commented Apr 2, 2019

@bartdesmet @onovotny

@clairernovotny
Copy link
Member

/cc @terrajobst

@Damien-The-Unbeliever
Copy link
Author

Damien-The-Unbeliever commented Apr 3, 2019

I'm looking for the pull model of enumerable, not the push model of reactive. My own attempt is https://github.com/Damien-The-Unbeliever/Linq.AsyncEnumerable

@svick
Copy link
Contributor

svick commented Apr 3, 2019

@Damien-The-Unbeliever

I'm looking for the pull model of enumerable, not the push model of reactive.

That's exactly what the System.Linq.Async package offers, since it uses IAsyncEnumerable<T>, even though its source is in the reactive repo.

@bartdesmet
Copy link
Contributor

System.Linq.Async is indeed what you're looking for. See https://github.com/dotnet/reactive/tree/master/Ix.NET/Source/System.Linq.Async for the source. It's 100% isomorphic to System.Linq and has all the operators, including support for cancellation and support for deep asynchrony of predicates, selectors, etc.

@Damien-The-Unbeliever
Copy link
Author

Yeah, I see it now. Thanks

@CodingOctocat
Copy link

System.Linq.Async is indeed what you're looking for. See https://github.com/dotnet/reactive/tree/master/Ix.NET/Source/System.Linq.Async for the source. It's 100% isomorphic to System.Linq and has all the operators, including support for cancellation and support for deep asynchrony of predicates, selectors, etc.

If I have a IAsyncEnumerable that contains 20 elements, each element takes 1 seconds to get, and if I just want to get the last element, then it takes 20 seconds for me to use Last()?

This is crazy!

I wish I could use IEnumerable so that I could quickly enumerate the elements and then manually await it, but the asynchronous data source forced me to use The IAsyncEnumerable.

@svick
Copy link
Contributor

svick commented May 25, 2019

@CodingNinjaOctocat That sounds like you want IEnumerable<Task<T>>, instead of IAsyncEnumerable<T>. What's preventing you from using that?

@CodingOctocat
Copy link

@CodingNinjaOctocat That sounds like you want IEnumerable<Task<T>>, instead of IAsyncEnumerable<T>. What's preventing you from using that?

You're right, I test it over and over again, IEnumerable<Task> is the best choice.

@msftgits msftgits transferred this issue from dotnet/corefx Feb 1, 2020
@msftgits msftgits added this to the 3.0 milestone Feb 1, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 13, 2020
@stephentoub
Copy link
Member

#111685 has added System.Linq.AsyncEnumerable.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Linq
Projects
None yet
Development

No branches or pull requests

8 participants