Consider Renaming or Clarifying ReadAllAsync for Better Developer Experience (in System.Threading.Channels.ChannelReader<T>) #115289
Unanswered
muratbaseren
asked this question in
Ideas
Replies: 1 comment
-
A better name might've been |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Context:
The method name ReadAllAsync in System.Threading.Channels.ChannelReader can be misleading to developers at first glance. It suggests that it will read all currently available items from the channel at once, similar to a buffered batch read.
Observation:
In reality, ReadAllAsync() returns an IAsyncEnumerable and yields one item at a time until the channel is completed. It is functionally equivalent to an infinite loop consuming ReadAsync() internally. This can be confusing for those expecting a bulk or snapshot read behavior.
Suggestion:
Why it matters:
Clear naming improves developer onboarding, reduces misuse, and aligns expectation with behavior — especially for concurrency primitives where behavior clarity is critical.
Thanks for your great work on System.Threading.Channels — it's a powerful tool in building concurrent and producer/consumer systems.
Beta Was this translation helpful? Give feedback.
All reactions