Skip to content

MockFileSystem.File.Create(string) returns a stream with CanRead false #801

Closed

Description

@pianomanjh

MockFileStream, when returned as a result of a MockFileSystem.File.Create(string path) call, incorrectly has CanRead set to false.
This is different than System.IO.File.Create(string path), which correctly sets CanRead to true.

CanRead being false, can result in problems when used with code that expects true, for example, new BinaryReader(Stream stream), which checks the CanRead property in it's ctor, and throws when not true.

Activity

  1. pianomanjh commented on Feb 1, 2022

    @pianomanjh
    ContributorAuthor

    this was regressed by #714

  2. pianomanjh commented on Feb 1, 2022

    @pianomanjh
    ContributorAuthor

    workaround until fix is merged is to use File.Open, i.e.:
    _fileSystem.File.Open(filePath, FileMode.Create, FileAccess.ReadWrite)

  3. added a commit that references this issue on Feb 2, 2022
    405b6ec
  4. added
    type: bugIssues that describe misbehaving functionality
    on Feb 2, 2022
  5. github-actions commented on Feb 2, 2022

    @github-actions

    This is addressed in release v16.1.8.

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: 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