Skip to content

FileSystemGlobbingMatcher produces wrong stems #97333

Open
@StefanBertels

Description

@StefanBertels

Description

When using patterns like a*\b*\c*.ext the results contain stems with increasing length, containing parts of previous results.

Reproduction Steps

var matcher = new Microsoft.Extensions.FileSystemGlobbing.Matcher(StringComparison.OrdinalIgnoreCase);
matcher.AddInclude(@"sys*\1*\*.dll");
matcher.AddExclude(@"systemtemp");
matcher.AddExclude(@"systemtemp\*");
var result = matcher.Execute(new Microsoft.Extensions.FileSystemGlobbing.Abstractions.DirectoryInfoWrapper(new DirectoryInfo(@"c:\windows")));
foreach (var element in result.Files.Take(7)) // just output first 7 lines
{
    Console.WriteLine(element.Stem + " => " + element.Path);
}

My hard disk contains these files:

C:\Windows\System32\1028\VsGraphicsResources.dll
C:\Windows\System32\1028\vsjitdebuggerui.dll
C:\Windows\System32\1029\VsGraphicsResources.dll
C:\Windows\System32\1029\vsjitdebuggerui.dll
C:\Windows\System32\1031\VsGraphicsResources.dll
C:\Windows\System32\1031\vsjitdebuggerui.dll
C:\Windows\System32\1033\VsGraphicsResources.dll
C:\Windows\System32\1033\vsjitdebuggerui.dll
...

Expected behavior

Output should look like

System32/1028/VsGraphicsResources.dll => System32/1028/VsGraphicsResources.dll
System32/1028/vsjitdebuggerui.dll => System32/1028/vsjitdebuggerui.dll                                                               
System32/1029/VsGraphicsResources.dll => System32/1029/VsGraphicsResources.dll                                                  
System32/1029/vsjitdebuggerui.dll => System32/1029/vsjitdebuggerui.dll                                                          
System32/1031/VsGraphicsResources.dll => System32/1031/VsGraphicsResources.dll                                             
System32/1031/vsjitdebuggerui.dll => System32/1031/vsjitdebuggerui.dll                                                     
System32/1033/VsGraphicsResources.dll => System32/1033/VsGraphicsResources.dll     

Actual behavior

Output looks like

System32/1028/VsGraphicsResources.dll => System32/1028/VsGraphicsResources.dll
System32/1028/vsjitdebuggerui.dll => System32/1028/vsjitdebuggerui.dll                                                               
System32/1028/1029/VsGraphicsResources.dll => System32/1029/VsGraphicsResources.dll                                                  
System32/1028/1029/vsjitdebuggerui.dll => System32/1029/vsjitdebuggerui.dll                                                          
System32/1028/1029/1031/VsGraphicsResources.dll => System32/1031/VsGraphicsResources.dll                                             
System32/1028/1029/1031/vsjitdebuggerui.dll => System32/1031/vsjitdebuggerui.dll                                                     
System32/1028/1029/1031/1033/VsGraphicsResources.dll => System32/1033/VsGraphicsResources.dll     

Regression?

No response

Known Workarounds

No response

Configuration

.NET 8.0.101
Win 10 22H2 (OS Build 19045.3930)
x64
FilesystemGlobbing v8.0.0

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions