[release/10.0] Make case insensitive matches respect case insensitivity on the root.#123976
[release/10.0] Make case insensitive matches respect case insensitivity on the root.#123976github-actions[bot] wants to merge 5 commits intorelease/10.0from
Conversation
|
/ba-g known test errors only. |
|
Tagging subscribers to this area: @dotnet/area-system-io |
There was a problem hiding this comment.
Pull request overview
Backport fix for Microsoft.Extensions.FileSystemGlobbing.Matcher.Match (in-memory matching) so that root-directory matching respects the Matcher’s configured StringComparison, eliminating unexpected root mismatches when using case-insensitive matchers.
Changes:
- Plumb the
Matchercomparison setting intoInMemoryDirectoryInfovia an internalMatcher.ComparisonTypeproperty. - Update
InMemoryDirectoryInforoot matching to use the provided comparison rather than always usingStringComparison.Ordinal. - Add functional tests covering case-insensitive root matches and case-sensitive root misses for in-memory matching.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/Microsoft.Extensions.FileSystemGlobbing/tests/FunctionalTests.cs | Adds regression tests validating root-case behavior for in-memory matching under both case-sensitive and case-insensitive configurations. |
| src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/MatcherExtensions.cs | Passes the Matcher’s configured comparison into InMemoryDirectoryInfo when matching in-memory file lists. |
| src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/Matcher.cs | Exposes the configured StringComparison as an internal property for use by extension methods. |
| src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs | Stores the comparison type and uses it for root directory prefix matching (fixing the bug). |
|
As some expressed offline, this has the risk of being a behavior change, even though it's fixing a bug, hence not suitable for backport. Our suggestion is to setup a workaround like root normalization for in-memory files. Additionally, if possible, I suggest detailing the bug to your code review agent until the fix ships in .NET 11. Closing. |
Backport of #120159 to release/10.0
/cc @jozkee @MitchBodmer
Customer Impact
Fixes:
Matcherdoes not respect case insensitivity in root when using anInMemoryDirectoryInfo. (#119117)Matcher.Matchdoes not use the specified comparison which causes unexpected mismatches. This issue has a workaround but it's a filtering bug that can cause fewer matches to be returned than could actually exist on a filesystem, without the customer being able to detect this. This could be leading to data loss, corruption, or other behavioral bugs for customers.Before this fix, both matchers would return
falsebecauseIsRootDirectoryalways usedStringComparison.Ordinalregardless of the configured comparison type.Regression
Testing
Change included new tests and the fix was verified by the customer.
Risk
Medium
This is technically a behavior change, but we believe it is very unlikely that there are customers relying on this bug since it results in fewer matches than what actually exist.
@MitchBodmer (the customer who reported, fixed, and validated this issue) shared the following analysis that @jozkee and @jeffhandley agree with:
Fix has been sitting in .NET 11 since September 2025.