Summary
On Windows, HangDump quotes dump paths that contain spaces before calling DiagnosticsClient.WriteDump, but then stores the quoted path in _dumpFiles and later publishes it as a FileArtifact. The artifact path therefore includes literal " characters and no longer points to the real dump file.
Evidence
Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:377-380
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && finalDumpFileName.Contains(' '))
finalDumpFileName = $"\"{finalDumpFileName}\"";
Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:385-388
if (dumpType.HasValue)
diagnosticsClient.WriteDump(dumpType.Value, finalDumpFileName, logDumpGeneration: false);
_dumpFiles.Add(finalDumpFileName);
Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:216-218
foreach (string dumpFile in _dumpFiles)
new FileArtifact(new FileInfo(dumpFile), ExtensionResources.HangDumpArtifactDisplayName, ...)
Q:\src\testfx\src\Platform\Microsoft.Testing.Platform\Messages\FileArtifacts.cs:19-25
public FileArtifact(FileInfo fileInfo, string displayName, string? description = null)
public FileInfo FileInfo { get; }
Why this is a real issue
This is not just cosmetic: the stored artifact path is different from the file path on disk. Windows result directories frequently contain spaces (for example under C:\Users\...), so the workaround path is likely to be hit in normal usage. Downstream artifact handling gets a FileInfo for "C:\...\dump.dmp" instead of C:\...\dump.dmp.
Suggested resolution
Keep an unquoted path for bookkeeping/artifact publication and use a separate quoted variable only for the WriteDump workaround. Add a regression test that exercises a results directory with spaces.
Related issues
- External runtime workaround referenced in code:
dotnet/diagnostics#5020
Summary
On Windows,
HangDumpquotes dump paths that contain spaces before callingDiagnosticsClient.WriteDump, but then stores the quoted path in_dumpFilesand later publishes it as aFileArtifact. The artifact path therefore includes literal"characters and no longer points to the real dump file.Evidence
Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:377-380if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && finalDumpFileName.Contains(' '))finalDumpFileName = $"\"{finalDumpFileName}\"";Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:385-388if (dumpType.HasValue)diagnosticsClient.WriteDump(dumpType.Value, finalDumpFileName, logDumpGeneration: false);_dumpFiles.Add(finalDumpFileName);Q:\src\testfx\src\Platform\Microsoft.Testing.Extensions.HangDump\HangDumpProcessLifetimeHandler.cs:216-218foreach (string dumpFile in _dumpFiles)new FileArtifact(new FileInfo(dumpFile), ExtensionResources.HangDumpArtifactDisplayName, ...)Q:\src\testfx\src\Platform\Microsoft.Testing.Platform\Messages\FileArtifacts.cs:19-25public FileArtifact(FileInfo fileInfo, string displayName, string? description = null)public FileInfo FileInfo { get; }Why this is a real issue
This is not just cosmetic: the stored artifact path is different from the file path on disk. Windows result directories frequently contain spaces (for example under
C:\Users\...), so the workaround path is likely to be hit in normal usage. Downstream artifact handling gets aFileInfofor"C:\...\dump.dmp"instead ofC:\...\dump.dmp.Suggested resolution
Keep an unquoted path for bookkeeping/artifact publication and use a separate quoted variable only for the
WriteDumpworkaround. Add a regression test that exercises a results directory with spaces.Related issues
dotnet/diagnostics#5020