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.
This makes the
TempCollection
s persist until theGroupBy
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
.