dotnet / dotnet/reactive

IAsyncGrouping is inconvinient

Open
#1,211 2 comments 1 reaction 0 assignees View on GitHub
[area] Ix
Dominant language
C#
Stars
7.2k
Forks
798
PR merge metrics
No merged PRs in 30d

Description

In `System.Linq.Async`, GroupBy returns `IAsyncGrouping` but internally it is `IGrouping` and cast it.

> `(IAsyncGrouping)_enumerator.Current`

IAsyncGrouping is very inconvenient.
For example, all those who follow can't use the normal methods and have to use ***Await.

```csharp
AsyncEnumerable.Range(1, 10)
.GroupBy(x => x)
.SelectAwait(async x => await x.CountAsync()) // can not use standard .Select operator.
```

This is both an inconvenience and a poor performer.

As a suggestion, why don't you get rid of IAsyncGrouping and return IGrouping?
Since ToLookup implements the standard ILookup,IGrouping, I don't think it's strange if the paired GroupBy is IGrouping.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing System.Linq.Async's GroupBy result and the IAsyncGrouping cast described in the issue, then compare that behavior with ToLookup's IGrouping implementation. Check how standard Select and CountAsync usage would be affected. Done means the API direction is resolved and the chosen behavior is covered by tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.