Share via


InMemoryDirectoryInfo는 파일 앞에 rootDir을 추가합니다.

InMemoryDirectoryInfo는 이제 지정된 루트 디렉터리를 해당 파일 컬렉션 앞에 추가합니다.

InMemoryDirectoryInfoMatcherExtensions.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