Skip to content

fix: cap real-fs temp-dir prefix to stay under MAX_PATH on net48#1019

Merged
vbreuss merged 1 commit into
mainfrom
topic/avoid-too-long-paths
May 19, 2026
Merged

fix: cap real-fs temp-dir prefix to stay under MAX_PATH on net48#1019
vbreuss merged 1 commit into
mainfrom
topic/avoid-too-long-paths

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 19, 2026

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.

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.
@vbreuss vbreuss self-assigned this May 19, 2026
Copilot AI review requested due to automatic review settings May 19, 2026 12:48
@vbreuss vbreuss added the bug Something isn't working label May 19, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GetDirectoryCleaner with logic that truncates the derived test-name prefix.
  • Cap the generated test-name component to 60 characters before creating the temp directory.

@vbreuss vbreuss enabled auto-merge (squash) May 19, 2026 13:02
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss merged commit c862e9b into main May 19, 2026
17 checks passed
@vbreuss vbreuss deleted the topic/avoid-too-long-paths branch May 19, 2026 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants