Repository navigation
feat: pass the requested access to access control strategies - #1160
Merged
Merged
Conversation
vbreuss
enabled auto-merge (squash)
October 28, 2026 20:09
Test Results 62 files 62 suites 1h 18m 0s ⏱️ Results for commit 58dc265. ♻️ This comment has been updated with latest results. |
vbreuss
marked this pull request as draft
October 29, 2026 05:13
auto-merge was automatically disabled
October 29, 2026 05:13
Pull request was converted to draft
…ted `FileAccess` The new abstract `AccessControlStrategy` implements `IAccessControlStrategy` and adds an `IsAccessGranted` overload with the requested `FileAccess`, so tests can simulate files and directories that can be read but not written. Enumerating a directory requests `FileAccess.Read`. As a base class, it can be extended with virtual members in the future without breaking derived strategies. `DefaultAccessControlStrategy` and `NullAccessControlStrategy` now derive from it, and `DefaultAccessControlStrategy` gets a constructor overload for a callback with the requested access. Existing `IAccessControlStrategy` implementations keep working unchanged.
Users could not discover the new overload without docs, and the test now shows the recommended HasFlag check. Also restores the original BOM state of the test file.
A plain FileAccess cannot tell a delete from a write, so strategies could not simulate files that may be written but not deleted. A request object can carry more information later without breaking derived strategies, and the API is not released yet, so this is the cheapest moment to change it. The test strategy now implements the interface explicitly to avoid a false-positive unused-parameter warning.
Only the mock creates access requests, so an internal constructor lets the type gain properties later without breaking callers or accumulating constructor overloads.
vbreuss
force-pushed
the
feat/access-control-requested-access
branch
from
October 29, 2026 23:28
269a05c to
58dc265
Compare
vbreuss
marked this pull request as ready for review
October 29, 2026 23:28
|
|
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. |
|
This is addressed in release v7.2.0. |
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



An
IAccessControlStrategyonly receives the path and theIFileSystemExtensibility, so it can only grant or deny all access to a file or directory. Tests cannot simulate the common cases in between: a file that can be read but not written, or a directory whose files can be written but not deleted.This adds an
AccessRequestthat the mock passes to the strategy:Accessis the requestedFileAccess. Enumerating a directory requestsFileAccess.Read.IsDeleteistruewhen the file or directory is deleted, because a plainFileAccesscannot tell a delete from a write. A delete also requestsFileAccess.Write.API changes
AccessControlStrategythat implementsIAccessControlStrategyand addsIsAccessGranted(string, IFileSystemExtensibility, AccessRequest). A base class, rather than a second interface, can gain virtual members later without breaking derived strategies.AccessRequestwith an internal constructor: only the mock creates requests, so the type can gain properties later without breaking callers or piling up constructor overloads.DefaultAccessControlStrategyandNullAccessControlStrategynow derive fromAccessControlStrategy.DefaultAccessControlStrategygets a constructor overload for a callback that receives theAccessRequest.Tests/Api/are updated for every target framework.Compatibility
IAccessControlStrategyimplementations keep working:WithAccessControlStrategywraps them, and they still receive only path and extensibility.IsAccessGrantedonAccessControlStrategyrequestsFileAccess.ReadWrite, so calling it never grants access by accident.DefaultAccessControlStrategy((path, extensibility) => ...)calls still compile; the lambda's parameter count selects the overload.