-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Description
Description
When using a root and the InMemoryDirectoryInfo to match files, the root is always matched case sensitively instead of respecting the configuration of the Matcher.
Reproduction Steps
This example program...
using Microsoft.Extensions.FileSystemGlobbing;
Matcher matcher = new(StringComparison.OrdinalIgnoreCase);
matcher.AddInclude(@"this\casing\");
foreach (var stem in
matcher.Match(
@"C:\root\dir\casing\",
[
@"C:\root\dir\casing\this\casing\MatchingCase",
@"C:\root\dir\casing\this\CASING\PathMismatchingCase",
@"C:\root\dir\CASING\this\casing\RootMismatchingCase",
@"C:\root\dir\CASING\this\CASING\BothMismatchingCase"
]
).Files.Select(filePatternMatch => filePatternMatch.Stem))
{
Console.WriteLine(stem);
}...outputs...
MatchingCase
PathMismatchingCase
because those are the only two options where the case of the root matches. This is unexpected because the Matcher is constructed with a StringComparison.OrdinalIgnoreCase comparison.
Expected behavior
If a Matcher is configured with a specific case sensitivity, that case sensitivity should also apply to roots.
Actual behavior
No matter the case sensitivity parameter, roots are always case sensitive.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
I think the offending line is here.
The most obvious solution would be for the comparison to be passed to the InMemoryDirectoryInfo created in the Match call by adding a constructor that takes it. Then using that to match roots in the InMemoryDirectoryInfo.