-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Make case insensitive matches respect case insensitivity on the root. #120159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make case insensitive matches respect case insensitivity on the root. #120159
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
StringComparison
type fromMatcher
as an internal property to allow extension methods access - Updates
InMemoryDirectoryInfo
to accept and use aStringComparison
parameter 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
Tagging subscribers to this area: @dotnet/area-extensions-filesystem |
src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
This change addresses #119117 by making the
Matcher
match 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
Matcher
is actually an extension method. That means it does not have access to the privateStringComparison
type 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
InMemoryDirectoryInfo
is 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.