dotnet / dotnet/dotnet-api-docs

System.IO.BufferedStream.ReadAsync() cancel response (exception documentation)

Open
#2,970 6 comments 0 reactions 1 assignee Claimed by @carlossanlop View on GitHub
area-System.IO Pri3 untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

# Issue Title

System.IO.BufferedStream.ReadAsync() is responding to a cancellationToken cancel signal with System.AggregateException and not System.OperationCanceledException.

# General

The AggregateException does contain a single exception of TaskCanceledException.

docs.microsoft.com for Core, Standard, and Framework doesn't actually say any exception will be thrown on a cancel for BufferedStream or Stream. It just says the returned Task will indicate it was cancelled.

Seeing as how throwing OperationCanceledException seems like more the "convention" with most async methods, is it confirmed that Stream/BufferedStream throwing AggregateException is correct for consistency/historical reasons across Core/Standard/Framework?

If AggregateException is correct even though it goes against what seems like the "convention", I can write-up an issue for docs.microsoft.com to get this better documented.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.