FileSystemGlobbing: Matcher throws ArgumentOutOfRangeException when the rootDir is the same value as the file
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu với src/libraries/Microsoft.Extensions.FileSystemGlobbing/src/InMemoryDirectoryInfo.cs, đặc biệt là mã EnumerateFileSystemInfos được liên kết trong issue. Tái hiện lỗi bằng ứng dụng dựa trên tệp được cung cấp, trong đó rootDir và file là cùng một đường dẫn, sau đó kiểm tra các bài kiểm thử FileSystemGlobbing liên quan. Hoàn tất khi Match() trả về HasMatches == false mà không ném ngoại lệ trong trường hợp này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- C#
- Star
- 18.4k
- Fork
- 5.8k
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 579
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của dotnet/runtime
-
Incorrect loop bound in SizeOptIListSelectIterator.ToListCó thể đã có người làm @equmagg đã nhận hôm nay. Đang mởarea-System.Collections untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
dotnet/runtime#137126 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
DbTransaction.SupportsSavepoints docs say Release/ReleaseAsync are expected to throw, but they are no-ops by designCó thể đã có người làm @alaricd đã nhận 1 ngày trước. Đang mởarea-System.Transactions untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
dotnet/runtime#137040 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Configuration binder source generator emits unqualified List<T> when binding arrays without implicit usingsCó thể đã có người làm @makazeu đã nhận 1 ngày trước. Đang mởarea-Extensions-Configuration bug source-generator
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/runtime#136972 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[wasi] .NET 10: WasmEnableSIMD with AOT fails because WasiApp.targets has -msimd128 commented outĐang mởarea-Build-mono untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
PropertyChangedEventArgs should have a nice DebuggerDisplayCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mởarea-System.ComponentModel untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
dotnet/runtime#136608 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của dotnet/runtime
Issue tương tự
-
needs-triage
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 76/100
Azure/azure-sdk-for-net#64658 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
dotnet/aspnetcore#70370 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
NethermindEth/nethermind#15684 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/ai-assistant squad/flyt
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Altinn/altinn-studio#21798 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
SubtitleEdit/subtitleedit#16699 ·
Maintainer thường phản hồi trong vòng 1 ngày