dotnet / dotnet/dotnet-api-docs

FileStream constructor documentation incorrectly states that bufferSize: 0 throws

Open
#13,060 1 comment 1 reaction 2 assignees Claimed by @adamsitnik View on GitHub
area-System.IO untriaged
Dominant language
C#
Stars
949
Forks
1.7k
Avg merge
3d 27m
Merged PRs (30d)
49

Description

### Describe the issue or suggestion

For FileStream(string, FileMode, FileAccess, FileShare, int, FileOptions),
the .NET 10 documentation says that bufferSize must be greater than zero
and that zero throws ArgumentOutOfRangeException.

The .NET 10 runtime source disagrees:
- FileStreamHelpers.ValidateArguments rejects only bufferSize < 0:
https://github.com/dotnet/runtime/blob/release/10.0/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.cs#L79-L82
- buffering is enabled only when bufferSize > 1:
https://github.com/dotnet/runtime/blob/release/10.0/src/libraries/System.Private.CoreLib/src/System/IO/Strategies/FileStreamHelpers.cs#L30-L31

Therefore bufferSize: 0 is valid and disables the internal buffering strategy.
Please correct the parameter description and ArgumentOutOfRangeException documentation.

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.