OpenWrite doesn't prevent writing
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 :
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.
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); }
This is addressed in release v21.1.2.