fix: cap real-fs temp-dir prefix to stay under MAX_PATH on net48#1019
Merged
Conversation
The Real test data passed `{ClassName}-{MethodName}-` as the directory-cleaner
prefix. For tests with long names — e.g. EnumerateFileSystemInfosTests's
EnumerateFileSystemEntries_SearchOptionAllDirectories_FullPath_ShouldReturnAllFileSystemEntriesWithFullPath
— this becomes a 130-char prefix. Combined with a longer CI user temp root
(`runneradmin` vs typical short usernames) and AutoFixture-generated path
components that include the literal `With whitespace` token from
RandomSystemExtensions.FileNames, the working path tips over the 260-char
MAX_PATH limit that .NET Framework still enforces (the Switch.System.IO
opt-outs aren't enabled here on purpose — `New_PathTooLong_Should…OnNetFramework`
documents that limit as a deliberate behavior).
Cap the prefix at 60 chars. Uniqueness still comes from the random
suffix that `DirectoryCleaner.GetPathCandidate` appends.
There was a problem hiding this comment.
Pull request overview
This PR reduces the likelihood of PathTooLongException in RealFileSystem tests on .NET Framework (net48) by limiting the length of the temporary-directory prefix derived from long test names, helping keep generated working paths under MAX_PATH.
Changes:
- Replace the expression-bodied
GetDirectoryCleanerwith logic that truncates the derived test-name prefix. - Cap the generated test-name component to 60 characters before creating the temp directory.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The Real test data passed
{ClassName}-{MethodName}-as the directory-cleaner prefix. For tests with long names — e.g. EnumerateFileSystemInfosTests's EnumerateFileSystemEntries_SearchOptionAllDirectories_FullPath_ShouldReturnAllFileSystemEntriesWithFullPath — this becomes a 130-char prefix. Combined with a longer CI user temp root (runneradminvs typical short usernames) and AutoFixture-generated path components that include the literalWith whitespacetoken from RandomSystemExtensions.FileNames, the working path tips over the 260-char MAX_PATH limit that .NET Framework still enforces (the Switch.System.IO opt-outs aren't enabled here on purpose —New_PathTooLong_Should…OnNetFrameworkdocuments that limit as a deliberate behavior).Cap the prefix at 60 chars. Uniqueness still comes from the random suffix that
DirectoryCleaner.GetPathCandidateappends.