Correct FileStream(FileOptions) docs for bufferSize = 0 behavior - #13062
Correct FileStream(FileOptions) docs for bufferSize = 0 behavior#13062adamsitnik with Copilot wants to merge 5 commits into
bufferSize = 0 behavior#13062Conversation
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
bufferSize = 0 behavior
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot Passing 1 as bufferSize works on every .NET version, but 0 only in .NET 6 and above. Please do capture that in the doc.
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Updated in cc63e7a. The constructor docs now state that |
adamsitnik
left a comment
There was a problem hiding this comment.
@copilot please address my feedback
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The updated bufferSize parameter text is potentially misleading for pre-.NET 6 readers because it opens with “non-negative” while the exception contract still disallows 0 in those versions.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Updates the API reference documentation for FileStream(string, FileMode, FileAccess, FileShare, int bufferSize, FileOptions options) so the bufferSize parameter and related ArgumentOutOfRangeException text better match runtime behavior (notably for bufferSize == 0).
Changes:
- Updates the
bufferSizeparameter description to reflect non-negative values and document buffering behavior for0/1. - Refines the
ArgumentOutOfRangeExceptioncontract to distinguish negative values from the pre-.NET 6 behavior forbufferSize == 0.
File summaries
| File | Description |
|---|---|
| xml/System.IO/FileStream.xml | Adjusts constructor parameter and exception documentation for bufferSize to align with runtime semantics and version differences. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| <param name="access">A bitwise combination of the enumeration values that determines how the file can be accessed by the <see langword="FileStream" /> object. This also determines the values returned by the <see cref="P:System.IO.FileStream.CanRead" /> and <see cref="P:System.IO.FileStream.CanWrite" /> properties of the <see langword="FileStream" /> object. <see cref="P:System.IO.FileStream.CanSeek" /> is <see langword="true" /> if <paramref name="path" /> specifies a disk file.</param> | ||
| <param name="share">A bitwise combination of the enumeration values that determines how the file will be shared by processes.</param> | ||
| <param name="bufferSize">A positive <see cref="T:System.Int32" /> value greater than 0 indicating the buffer size. The default buffer size is 4096.</param> | ||
| <param name="bufferSize">A non-negative <see cref="T:System.Int32" /> value indicating the buffer size. The default buffer size is 4096. In versions earlier than .NET 6, this value must be greater than 0. In .NET 6 and later versions, a value of 0 disables buffering (a value of 1 disables buffering in every version).</param> |
There was a problem hiding this comment.
We actually removed all comments for out of support versions. When you say versions earlier than .NET 6, does that apply to .NET Framework as well? If so, let's put that info in the dotnetfw-api-docs repo instead and just state the [.NET 6+] behavior here without a version.
The docs for
FileStream(string, FileMode, FileAccess, FileShare, int, FileOptions)currently state thatbufferSizemust be> 0and that0throws. Runtime behavior allows0and only rejects negative values.Scope: targeted constructor docs
bufferSizeparameter text for the(..., int bufferSize, FileOptions options)overload to allow non-negative values.bufferSize: 0disables internal buffering.Exception contract alignment
ArgumentOutOfRangeExceptiontext for the same overload from “negative or zero” to “negative”.Result
Internal previews
Build report