Skip to content

Conversation

MitchBodmer
Copy link
Contributor

@MitchBodmer MitchBodmer commented Sep 26, 2025

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 private StringComparison 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.

@Copilot Copilot AI review requested due to automatic review settings September 26, 2025 21:08
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Sep 26, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 from Matcher as an internal property to allow extension methods access
  • Updates InMemoryDirectoryInfo to accept and use a StringComparison 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

@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Sep 26, 2025
@jkotas jkotas added area-Extensions-FileSystem and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Sep 26, 2025
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-extensions-filesystem
See info in area-owners.md if you want to be subscribed.

Copy link
Member

@jozkee jozkee left a comment

Choose a reason for hiding this comment

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

Thanks.

@jozkee jozkee merged commit 5164c79 into dotnet:main Oct 1, 2025
86 of 88 checks passed
@jozkee jozkee added this to the 11.0.0 milestone Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Extensions-FileSystem community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants