Consider Renaming or Clarifying ReadAllAsync for Better Developer Experience (in System.Threading.Channels.ChannelReader<T>) #115289
Replies: 2 comments
-
A better name might've been |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestion. The docs are open source, and you're welcome to submit a PR clarifying the content if you think it can be improved. The relevant docs are here: |
Beta Was this translation helpful? Give feedback.
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