dotnet / dotnet/runtime

Ragged pattern stem excludes wildcard segments in StartsWith group

Open
#126,195 1 comment 0 reactions 1 assignee Claimed by @cincuranet View on GitHub
area-Extensions-FileSystem
Dominant language
C#
Stars
18.3k
Forks
5.6k
PR merge metrics
PR metrics pending

Description

When using a glob pattern with a wildcard segment before `**` (e.g., `sys*/**/*.dll`), the Stem of matched files
does not include the portion matched by the wildcard prefix. This is inconsistent with how linear patterns
(without `**`) handle the same wildcard segments.

```csharp
using Microsoft.Extensions.FileSystemGlobbing;

var matcher = new Matcher();
matcher.AddInclude("sys*/**/*.dll");
var files = new[]
{
"system32/drivers/acpi.dll",
"system32/drivers/usb.dll",
"system32/config/sam.dll",
"system32/config/security.dll",
};
var results = matcher.Match("./", files);
var actual = results.Files.Select(f => f.Stem);
foreach (var item in actual)
{
Console.WriteLine(item);
}
```

`sys*` is a wildcard segment that matched `system32`, so `system32` should be part of the stem, based on the [docs](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.filesystemglobbing.filepatternmatch.stem?view=net-10.0-pp).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.