Add artifact naming service with template support for consistent naming across extensions #6587
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.
This PR introduces a comprehensive artifact naming service that provides consistent naming and placement for test artifacts across all extensions, with particular focus on the hang dump extension.
Overview
The new
IArtifactNamingService
allows users to define template-based patterns for artifact naming using placeholders like<process-name>
,<pid>
,<id>
,<os>
,<assembly>
,<tfm>
,<time>
, and<root>
.Key Features
Template-Based Naming
Users can now specify patterns like:
Which resolves to:
Complex Path Templates
Support for structured directory layouts:
Resolves to:
Available Placeholders
<process-name>
- Name of the target process<pid>
- Process ID<id>
- Short random identifier (8 characters)<os>
- Operating system (windows/linux/macos)<assembly>
- Assembly name<tfm>
- Target framework moniker (net9.0, etc.)<time>
- UTC timestamp with 1-second precision<root>
- Project root directory (solution/git/working directory)Backward Compatibility
Legacy patterns continue to work seamlessly through
ResolveTemplateWithLegacySupport()
:Implementation Details
Core Components
IArtifactNamingService
- Service interface with template resolution methodsArtifactNamingService
- Implementation with regex-based placeholder replacementTestHostBuilder
with proper dependency injectionGetArtifactNamingService()
for easy accessHang Dump Integration
The hang dump extension now uses the artifact naming service with:
%p
→<pid>
mappingError Handling
Testing
Unit Tests
Comprehensive test coverage in
ArtifactNamingServiceTests.cs
including:Integration Tests
New test
HangDump_TemplateFileName_CreateDump()
validates:Usage Example
This implementation provides the foundation for consistent artifact naming across all testing platform extensions while maintaining full backward compatibility.
Fixes #6586.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
37cvsblobprodcus359.vsblob.vsassets.io
dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj --no-restore
(dns block)5dkvsblobprodcus355.vsblob.vsassets.io
dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj --no-restore
(dns block)c50vsblobprodcus330.vsblob.vsassets.io
dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj --no-restore
(dns block)fdpvsblobprodcus345.vsblob.vsassets.io
/home/REDACTED/work/testfx/testfx/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/testfx/testfx/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/testfx/testfx/artifacts/toolset/11.0.0-beta.25469.3.txt
(dns block)dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj --no-restore
(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js
(dns block)l49vsblobprodcus358.vsblob.vsassets.io
dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj --no-restore
(dns block)pkvvsblobprodcus321.vsblob.vsassets.io
dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj --no-restore
(dns block)yttvsblobprodcus357.vsblob.vsassets.io
dotnet build src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj --no-restore
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.