Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenWrite doesn't prevent writing #1156

Open
Benjamin-Berry opened this issue Oct 9, 2024 · 2 comments
Open

OpenWrite doesn't prevent writing #1156

Benjamin-Berry opened this issue Oct 9, 2024 · 2 comments
Labels
state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality

Comments

@Benjamin-Berry
Copy link

Benjamin-Berry commented Oct 9, 2024

Describe the bug
Stream.CopyTpAsync still works with a write only stream.

To Reproduce
var fs = new MockFileSystem();

...

using var estream = entry.Open();
using var fstream = file.OpenWrite();
var temp = fstream.CanRead; // false
await fstream.CopyToAsync(estream);

Expected behavior
MockFileSystem and FileSystem would behave the same.

Additional context
I'm writing into a ZipArchive but that shouldn't matter.
Swapping to use FileSystem in the Unit test does throw a permissions exception.

@Benjamin-Berry Benjamin-Berry added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Oct 9, 2024
@vbreuss
Copy link
Member

vbreuss commented Oct 10, 2024

@Benjamin-Berry :
Could you please provide a complete repro example as it is unclear from your description what entry and file should be or what settings you applied.

@Benjamin-Berry
Copy link
Author

I can't give you any proprietary code.

var fs = new MockFileSystem();
var directory = fs.DirectoryInfo.New("somepath");
foreach (var file in directory.GetFiles(".", SearchOption.AllDirectories))
{
using var estream = new MemoryStream();
using var fstream = file.OpenWrite();
var temp = fstream.CanRead; // false
await fstream.CopyToAsync(estream);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

No branches or pull requests

2 participants