Skip to content

Extend FileStreamOptions with BufferSize, allow to specify 0 to disable the buffering#52928

Merged
adamsitnik merged 3 commits intodotnet:mainfrom
adamsitnik:bufferSize
May 19, 2021
Merged

Extend FileStreamOptions with BufferSize, allow to specify 0 to disable the buffering#52928
adamsitnik merged 3 commits intodotnet:mainfrom
adamsitnik:bufferSize

Conversation

@adamsitnik
Copy link
Copy Markdown
Member

@ghost
Copy link
Copy Markdown

ghost commented May 18, 2021

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link
Copy Markdown

ghost commented May 18, 2021

Tagging subscribers to this area: @carlossanlop
See info in area-owners.md if you want to be subscribed.

Issue Details

#15088 (comment)

Author: adamsitnik
Assignees: -
Labels:

area-System.IO

Milestone: 6.0.0

Copy link
Copy Markdown
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM, thanks.

Co-authored-by: David Cantú <dacantu@microsoft.com>
@adamsitnik adamsitnik merged commit 82289b2 into dotnet:main May 19, 2021
@adamsitnik adamsitnik deleted the bufferSize branch May 19, 2021 07:58
using (CreateFileStream(GetTestFilePath(), FileMode.Create, FileAccess.ReadWrite, FileShare.Read, 0))
{
}
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it'd be better to just change ValidBufferSize below to be a theory, with [InlineData(0)], [InlineData(64 * 1024)], and whatever other sizes we want to validate.

public long PreallocationSize { get; set; }
/// <summary>
/// The size of the buffer used by <see cref="FileStream" /> for buffering. The default buffer size is 4096.
/// 0 or 1 means that buffering should be disabled. Negative values are not allowed.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Negative values are not allowed.

We don't want to do such validation in the setter?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants