Skip to content

fix: honour combined FileShare.ReadWrite flags when sharing - #1091

Merged
vbreuss merged 1 commit into
Testably:mainfrom
Mpdreamz:fix/file-share-readwrite-flag
Sep 22, 2026
Merged

vbreuss merged 1 commit into
Testably:mainfrom
Mpdreamz:fix/file-share-readwrite-flag

Conversation

@Mpdreamz

@Mpdreamz Mpdreamz commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1090.

Sibling of #1084 / #1085, one method along. FileHandle.CheckAccessWithShare tests the Read and Write cases with HasFlag and the ReadWrite case with equality, so FileShare.ReadWrite | FileShare.Delete — which shares strictly more than FileShare.ReadWrite — did not grant read/write sharing.

One line, plus tests that two FileAccess.ReadWrite openers succeed for both FileShare.ReadWrite and FileShare.ReadWrite | FileShare.Delete, and that shares omitting Write still throw on Windows.

I found this while checking whether #1085 let some skipped tests in #1082 run again. It did for deletion; this was the second reason they were skipped.

Branches from main and is independent of #1082 / #1083.

Run in Release, which is what puts the real file system into the test matrix: Testably.Abstractions.Tests 12130 on net8.0 and 12639 on net10.0, and Testing.Tests 1308. All pass.

MemoryMappedFiles.Tests fails on main itself in the intermediate state between the 10.4.0-pre.1 release and the version bump in #1082, which is what BuildScope.CoreOnly skips — nothing to do with this change.

Happy to rework it however you prefer.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 20, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The implementation and tests cover the intended combined sharing behavior.

Review effort: Lite
Findings: None

What changed in this PR

Fixes combined FileShare.ReadWrite handling when used with FileShare.Delete, with accompanying tests.

Changes:

  • Corrects flag evaluation for combined sharing modes.
  • Adds coverage for accepted and rejected sharing combinations.
File Summary
Tests/​Testably.Abstractions.Tests/​FileSystem/​File/​ShareReadWriteWithDeleteTests.cs Adds sharing behavior tests.
Source/​Testably.Abstractions.Testing/​Storage/​FileHandle.cs Corrects combined FileShare handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@mergify

mergify Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

Comment thread Source/Testably.Abstractions.Testing/Storage/FileHandle.cs Outdated
`FileHandle.CheckAccessWithShare` tests the `Read` and `Write` cases with
`HasFlag`, but compared the `ReadWrite` case for equality. A file opened
with `FileShare.ReadWrite | FileShare.Delete` therefore did not share
read/write access, although it shares strictly more than
`FileShare.ReadWrite` does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Mpdreamz

Copy link
Copy Markdown
Contributor Author

No code change beyond the comment removal — correcting the verification note in the description.

It quoted Debug numbers, and Debug leaves the real file system out of the test matrix: FileSystemTestsAttribute only adds it in Release. Re-run in Release: Testably.Abstractions.Tests 12130 on net8.0 and 12639 on net10.0, Testing.Tests 1308, all passing. It also drops the mention of two macOS access-time failures I had been describing as pre-existing; they are a Debug-only artefact.

@vbreuss
vbreuss merged commit 3899e10 into Testably:main Sep 22, 2026
13 checks passed
@github-actions

Copy link
Copy Markdown

This is addressed in release v7.1.0.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MockFileSystem refuses read/write sharing when FileShare.Delete is combined with FileShare.ReadWrite

3 participants