From b3d649ec77808d2be2d91db42069e55a17ead5ef Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Fri, 13 Feb 2026 21:14:50 +0000 Subject: [PATCH] fix: reduce source generator hint name limit to 150 chars for Windows net472 The previous limit of 200 chars (from #4757) still caused PathTooLongException on Windows CI because .NET Framework 4.7.2's Path.GetFullPathInternal prepends the CWD (~69 chars) to the hint name, exceeding the hardcoded 260-char MAX_PATH limit. Reducing to 150 leaves ~110 chars of headroom for the working directory. Co-Authored-By: Claude Opus 4.6 --- TUnit.Core.SourceGenerator/Helpers/FileNameHelper.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TUnit.Core.SourceGenerator/Helpers/FileNameHelper.cs b/TUnit.Core.SourceGenerator/Helpers/FileNameHelper.cs index ff619469fd..6b74464eb8 100644 --- a/TUnit.Core.SourceGenerator/Helpers/FileNameHelper.cs +++ b/TUnit.Core.SourceGenerator/Helpers/FileNameHelper.cs @@ -17,7 +17,9 @@ internal static class FileNameHelper /// A deterministic filename like "MyNamespace_MyClass_MyMethod__Int32_String.g.cs" // Conservative limit to avoid PathTooLongException on Windows with net472, // which enforces the legacy 260-character MAX_PATH limit in Roslyn's AddSource. - private const int MaxHintNameLength = 200; + // Roslyn prepends the CWD to the hint name when calling Path.GetFullPathInternal, + // so we must leave ~110 chars of headroom for the working directory path. + private const int MaxHintNameLength = 150; public static string GetDeterministicFileNameForMethod(INamedTypeSymbol typeSymbol, IMethodSymbol methodSymbol) {