Make case insensitive matches respect case insensitivity on the root.#120159
Merged
jozkee merged 5 commits intodotnet:mainfrom Oct 1, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes case sensitivity handling in the Matcher class so that root directory matching respects the configured case sensitivity settings. Previously, the matcher would handle case sensitivity inconsistently between root directories and subdirectories.
Key Changes:
- Exposes the
StringComparisontype fromMatcheras an internal property to allow extension methods access - Updates
InMemoryDirectoryInfoto accept and use aStringComparisonparameter for root directory comparisons - Adds comprehensive test coverage for both case-sensitive and case-insensitive matching scenarios
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs |
Adds test methods to verify case-sensitive and case-insensitive root directory matching behavior |
src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/MatcherExtensions.cs |
Updates extension method to pass matcher's comparison type to InMemoryDirectoryInfo |
src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/Matcher.cs |
Exposes StringComparison as internal property and updates references |
src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs |
Adds constructor overload for StringComparison and updates root directory comparison logic |
src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs
Outdated
Show resolved
Hide resolved
Contributor
|
Tagging subscribers to this area: @dotnet/area-extensions-filesystem |
jozkee
reviewed
Sep 26, 2025
src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs
Outdated
Show resolved
Hide resolved
jozkee
reviewed
Sep 26, 2025
src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs
Show resolved
Hide resolved
Member
|
/backport to release/10.0 |
Contributor
|
Started backporting to |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This change addresses #119117 by making the
Matchermatch root directories case-insensitively when the Matcher is configured to be case-insensitive.I'm not exactly sure this is the right way to go about this so I'm very open to feedback. The tack I took was to try to limit breaking changes while also fixing the bug.
One problem I hit was that the offending method on the
Matcheris actually an extension method. That means it does not have access to the privateStringComparisontype on the matcher it is extending. I chose to make it a get-only internal property instead of moving the extension method into the matcher type in order to avoid changing the interface.Another potential issue is that the
InMemoryDirectoryInfois still case-sensitive by default where the typical pattern in this repository has been to make things case-insensitive. Again this was just to avoid any breaking changes.