Skip to content

FileAccess parameter in File.Open() is ignored when the FileMode is Create or CreateNew. #713

Closed

Description

@willson556

Describe the bug

FileAccess parameter in File.Open() is ignored when the FileMode is Create or CreateNew. Bug can be observed by checking the CanRead property of the returned Stream with FileAccess.ReadWrite.

To Reproduce
Below code snippet compares actual behavior to the mock:

var tempFile = Path.GetTempFileName();
using var fs = File.Open(tempFile, FileMode.Create);
Console.WriteLine(fs.CanRead);

var mock = new MockFileSystem();
var mockFile = mock.Path.GetTempFileName();
using var mockFs = mock.File.Open(mockFile, FileMode.Create);
Console.WriteLine(mockFs.CanRead);

Output:

True
False

Expected behavior

Mock behavior should match the .NET type.

Activity

  1. added
    state: in workIssues that are currently worked on
    and removed on Mar 9, 2021
  2. github-actions commented on Mar 9, 2021

    @github-actions

    This is addressed in release v13.2.25.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testinghelpersIssues that address the testing helpersstate: in workIssues that are currently worked onstate: releasedIssues that are releasedtype: bugIssues that describe misbehaving functionality

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions