InMemoryDirectoryInfo 이제 지정된 루트 디렉터리를 파일 컬렉션 앞에 추가합니다.
InMemoryDirectoryInfo는 MatcherExtensions.Match에 의해 사용되며 Matcher가 디스크에 접근하지 않고 글롭 일치 패턴을 실행할 수 있도록 합니다.
이전 동작
이전에는 files 인수의 상대 경로 앞에 CWD(현재 작업 디렉터리)가 추가되었습니다. 이로 인해 메모리 내 작동해야 하는 형식에 대한 CWD에 대한 불필요한 종속성이 발생했습니다.
새 동작
.NET 9부터 생성자 인수의 상대 경로 files 앞에 지정된 루트 디렉터리가 추가됩니다.
도입된 버전
.NET 9 미리 보기 1
파괴적 변경 유형
이 변경 사항은 행동 변화입니다.
변경 이유
현재 작업 디렉터리에서 사용하는 드라이브 문자 이외의 드라이브 문자를 사용하는 메모리 내 경로가 있는 차단된 시나리오가 있었습니다. 예를 들어 dotnet/런타임 문제 93107을 참조하세요.
권장 작업
이전 동작에 의존한 경우 현재 루트 디렉터리 앞에 추가되는 파일을 고려하도록 코드를 조정합니다. 다음은 그 예입니다.
// Since rootDir is also relative, it could've been used to filter the matching scope of `files`.
-string rootDir = "dir1";
// Now that's not possible; everything in `files` is under `root`.
+string rootDir = "root";
string[] files = ["dir1/test.0", "dir1/subdir/test.1", "dir2/test.2"];
-PatternMatchingResult result = new Matcher().AddInclude("**/*").Match(rootDir, files);
// Adjust the pattern if you want to scope down to dir1.
+PatternMatchingResult result = new Matcher().AddInclude("dir1/**/*").Match(rootDir, files);
Console.WriteLine(string.Join(", ", result.Files.Select(x => x.Path)));
// Output:
// dir1/test.0
// dir1/subdir/test.1
영향을 받는 API
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET