timcassell / ProtoPromise

Robust and efficient library for management of asynchronous operations in C#/.Net.
MIT License
145 stars 13 forks source link

Don't dispose `AsyncEnumerable.GroupBy` groups immediately #330

Closed timcassell closed 7 months ago

timcassell commented 7 months ago

This makes the TempCollections persist until the GroupBy enumerator is disposed or completed unsuccessfully (exception or canceled). This will help when chaining extensions (like .GroupBy(...).OrderBy(group => group.Elements.Count)) so they won't be surprisingly invalid during iteration.

Also optimized the extensions to use a direct struct instead of using AsyncEnumerable.Create.