Skip to content

Unify placeholder support across MTP --*-filename CLI options#8574

Merged
Evangelink merged 5 commits into
mainfrom
dev/amauryleve/mtp-filename-placeholders
May 25, 2026
Merged

Unify placeholder support across MTP --*-filename CLI options#8574
Evangelink merged 5 commits into
mainfrom
dev/amauryleve/mtp-filename-placeholders

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Summary

Audits all four MTP *-filename CLI options so they consistently resolve placeholders through the existing ArtifactNamingHelper service and advertise it in their option description.

Option Before After
--report-trx-filename Resolved {pname}/{pid}/{asm}/{tfm}/{time}, documented Unchanged
--hangdump-filename Resolved (+ legacy %p), undocumented Description now advertises the placeholders and the legacy %p token
--report-html-filename Not resolved, undocumented Now resolves via ArtifactNamingHelper.ResolveTemplate and documents the placeholders
--crashdump-filename Forwarded verbatim to the .NET runtime via DbgMiniDumpName Intentionally unchanged: the runtime owns expansion (%p/%e/%t/%h); doing it client-side would be either a no-op or misleading ({pid} would be the controller PID, not the test host)

Implementation notes

  • HtmlReportEngine.cs: new ResolveUserFileName mirrors the TRX pattern - resolve the template, then sanitize the file-name leaf via Path.GetInvalidFileNameChars(), then Path.Combine with the output directory.
  • Microsoft.Testing.Extensions.HtmlReport.csproj: links ArtifactNamingHelper.cs (TargetFrameworkParser.cs was already linked).
  • HtmlReport + HangDump ExtensionResources.resx updated; localized XLF files regenerated via dotnet msbuild .../Microsoft.Testing.Extensions.HtmlReport.csproj /t:UpdateXlf (and the equivalent for HangDump).
  • HelpInfoAllExtensionsTests.cs --help and --info expectation blocks updated for both affected options.

Tests

  • New unit test GenerateReportAsync_WithUserSuppliedFileName_ResolvesPlaceholders in HtmlReportEngineTests.cs.
  • dotnet test Microsoft.Testing.Extensions.UnitTests --filter ~HtmlReport (net9.0): 55/55 passed.
  • dotnet test Microsoft.Testing.Platform.Acceptance.IntegrationTests --filter ~HelpInfoAllExtensionsTests (net11.0, after -pack): 9/9 passed.

Copilot AI and others added 4 commits May 25, 2026 05:53
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…-hangdump-filename

All four MTP *-filename CLI options that route through user code are now consistent:

- --report-trx-filename (already used ArtifactNamingHelper)

- --hangdump-filename (already used ArtifactNamingHelper + legacy %p)

- --report-html-filename: now resolves {pname}/{pid}/{asm}/{tfm}/{time} via ArtifactNamingHelper before combining with the output directory and sanitizing any invalid filename chars introduced by substitution.

- --crashdump-filename: intentionally left unchanged - the value is forwarded verbatim to the .NET runtime via DbgMiniDumpName and is expanded by createdump's own placeholders (%p/%e/%t/%h).

Option descriptions for --report-html-filename and --hangdump-filename now advertise the supported placeholders. Localized XLF files regenerated and the HelpInfoAllExtensionsTests --help/--info expectations updated accordingly. Added a unit test for HtmlReportEngine covering placeholder resolution.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 25, 2026 16:01
Copy link
Copy Markdown
Contributor

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 makes MTP *-filename CLI options behave more consistently by routing placeholder expansion through the existing ArtifactNamingHelper (where applicable) and updating help/option descriptions to document the supported placeholders (while keeping crash dump filename handling runtime-owned).

Changes:

  • Added placeholder resolution support for --report-html-filename (including sanitization of the resolved filename leaf).
  • Documented placeholder support for --hangdump-filename (including the legacy %p token) and updated acceptance help/info expectations accordingly.
  • Introduced a shared CommandLineOptionsProviderBase and refactored several providers to use it, with new unit tests covering default behaviors.
Show a summary per file
File Description
test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineOptionsProviderBaseTests.cs Adds unit coverage for new shared command line provider base defaults/validation behavior.
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/HtmlReportEngineTests.cs Adds a unit test verifying placeholder resolution for user-supplied HTML report filenames.
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.cs Updates --help/--info expectations to include new/expanded filename placeholder documentation.
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsProviderBase.cs Introduces a shared base implementation for ICommandLineOptionsProvider.
src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildCommandLineProvider.cs Refactors provider to inherit from the new base class.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.zh-Hant.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.zh-Hans.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.tr.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.ru.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.pt-BR.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.pl.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.ko.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.ja.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.it.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.fr.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.es.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.de.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/xlf/ExtensionResources.cs.xlf Regenerated localization file reflecting updated HTML filename option description source.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Resources/ExtensionResources.resx Updates the HTML filename option description to document placeholders and provide an example.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/Microsoft.Testing.Extensions.HtmlReport.csproj Links ArtifactNamingHelper.cs into the HtmlReport extension for placeholder resolution.
src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlReportEngine.cs Implements user filename template resolution + sanitization for HTML reports.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hant.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.zh-Hans.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.tr.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ru.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pt-BR.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.pl.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ko.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.ja.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.it.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.fr.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.es.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.de.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/xlf/ExtensionResources.cs.xlf Regenerated localization file reflecting updated hang dump filename option description source.
src/Platform/Microsoft.Testing.Extensions.HangDump/Resources/ExtensionResources.resx Updates hang dump filename option description to document placeholders and legacy %p.
src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.cs Refactors provider to inherit from the new base class and override validation methods.
src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.cs Refactors provider to inherit from the new base class and override validation methods.

Copilot's findings

  • Files reviewed: 37/37 changed files
  • Comments generated: 0

Resolve conflicts:
- CrashDumpCommandLineProvider.cs: keep main's single primary-constructor body.
- HtmlReportEngine.cs: adopt main's ResolveHtmlFileName / GetProvidedFileName
  helpers (functionally equivalent to our ResolveUserFileName); main also
  uses _clock.UtcNow directly.
- HtmlReport ExtensionResources.resx: keep main's longer description that
  documents relative/absolute path support; placeholder list and example
  remain.
- HtmlReport xlf files: regenerate from clean main baseline so the
  trans-units carry a single <source>/<target>.
- HelpInfoAllExtensionsTests.cs: adopt main's longer description for the
  --report-html-filename --help and --info expectation blocks.
- HtmlReportEngineTests.cs: drop the placeholder unit test we added, since
  main introduced a more thorough GenerateReportAsync_ExplicitFileName_
  ResolvesPlaceholdersAndSanitizesLeafName test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment on lines +121 to +128
foreach (AttributeData attribute in attributes)
{
AttributeApplicationModel? model = BuildAttribute(attribute);
if (model is not null)
{
builder.Add(model);
}
}
@Evangelink Evangelink merged commit 0bfeeec into main May 25, 2026
30 of 32 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/mtp-filename-placeholders branch May 25, 2026 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants