FileSystemGlobbing: Matcher throws ArgumentOutOfRangeException when the rootDir is the same value as the file
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start with src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs, especially the EnumerateFileSystemInfos code linked in the issue. Reproduce the failure with the provided file based app where rootDir and file are the same path, then inspect the related FileSystemGlobbing tests. Done means Match() returns HasMatches == false without throwing for this case.
Written by the indexing model from the issue text.
Description
Description
See title and file-based app repro below.
Reproduction Steps
#:package [email protected]
using Microsoft.Extensions.FileSystemGlobbing;
var root = Path.GetPathRoot(Environment.CurrentDirectory)!;
var matcher = new Matcher();
matcher.AddInclude("MyFile.txt");
Console.WriteLine($"Match(rootDir: \"{root}\", file: \"{root}\")");
Console.WriteLine(matcher.Match(root, root).HasMatches);
Expected behavior
Match() returns a result with HasMatches == false and doesn't throw an exception.
I'm unsure whether it would/should be possible to setup a matcher which would match the path root.
Actual behavior
Match throws an exception:
Unhandled exception. System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than or equal to the size of the collection. (Parameter 'startIndex')
at System.String.IndexOfAny(Char[] anyOf, Int32 startIndex, Int32 count)
at Microsoft.Extensions.FileSystemGlobbing.InMemoryDirectoryInfo.EnumerateFileSystemInfos()+MoveNext()
at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Match(DirectoryInfoBase directory, String parentRelativePath)
at Microsoft.Extensions.FileSystemGlobbing.Internal.MatcherContext.Execute()
at Microsoft.Extensions.FileSystemGlobbing.Matcher.Execute(DirectoryInfoBase directoryInfo)
at Microsoft.Extensions.FileSystemGlobbing.MatcherExtensions.Match(Matcher matcher, String rootDir, IEnumerable`1 files)
at Microsoft.Extensions.FileSystemGlobbing.MatcherExtensions.Match(Matcher matcher, String rootDir, String file)
at Program.<Main>$(String[] args)
Regression?
No
Known Workarounds
Check that rootDir != file before calling Match().
Configuration
Using 11.0.100-rc.3.26522.148 SDK to build. Unsure which runtime that means I am running.
Library version given in the sample.
Running on Ubuntu 24.04, x64.
I doubt the problem is configuration-specific, I believe it also repros on Windows.
Other information
- Dominant language
- C#
- Stars
- 18.4k
- Forks
- 5.8k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 596
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/runtime
-
area-Extensions-Configuration bug source-generator untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dotnet/runtime#136972 · 1 comment ·
Maintainers usually reply within 1 day
-
[wasi] .NET 10: WasmEnableSIMD with AOT fails because WasiApp.targets has -msimd128 commented outOpenarea-Build-mono untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
area-System.ComponentModel untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
dotnet/runtime#136608 · 2 comments ·
Maintainers usually reply within 1 day
-
MemoryMappedFile (Windows): failed MEM_COMMIT is ignored, accessor over reserved memory crashes the processPossibly taken @RutulPatel8 claimed this 3 days ago. Openarea-System.IO bug untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
dotnet/runtime#136599 · 1 comment ·
Maintainers usually reply within 1 day
-
area-System.IO untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
dotnet/runtime#136577 · 1 comment ·
Maintainers usually reply within 1 day
Similar issues
-
.NET good first issue testing
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
HelloblueAI/HelloblueGK#311 ·
Maintainers usually reply within 1 day
-
needs-area-label
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 2 days
-
State: Needs Discussion
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
getsentry/sentry-dotnet#5876 · 1 comment ·
Maintainers usually reply within 1 day
-
library-request
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
QuantConnect/Lean#10034 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day