Skip to content

Refactor TrxReportGeneratorCommandLine to extend ReportGeneratorCommandLineBase - #9185

Merged
Amaury Levé (Evangelink) merged 3 commits into
mainfrom
dev/amauryleve/issue-9169-trx-extend-base-class
Jun 17, 2026
Merged

Amaury Levé (Evangelink) merged 3 commits into
mainfrom
dev/amauryleve/issue-9169-trx-extend-base-class

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Summary

Refactors \TrxReportGeneratorCommandLine\ to extend \ReportGeneratorCommandLineBase\ instead of \CommandLineOptionsProviderBase, aligning it with the three other report generators (CTRF, HTML, JUnit) that already use this pattern.

Changes

  • *\TrxCommandLine.cs* — Changed base class, removed duplicated \ValidateOptionArgumentsAsync\ and \ValidateCommandLineOptionsAsync\ overrides (17 lines of inline logic replaced by constructor parameters).
  • *\Microsoft.Testing.Extensions.TrxReport.csproj* — Added linked \ReportGeneratorCommandLineBase.cs\ from \SharedExtensionHelpers.

Validation

  • Build: 0 warnings, 0 errors
  • All 97 TRX-related unit tests pass

Fixes #9169

Move the TESTINGPLATFORM_CONSOLEOUTPUTDEVICE_SKIP_BANNER constant and the
banner text construction (StringBuilder-based platform info formatting) into
a new shared static helper class OutputDeviceBannerHelper.

Both SimplifiedConsoleOutputDeviceBase and TerminalOutputDevice now delegate
to OutputDeviceBannerHelper.BuildBannerText() and reference the shared
constant, eliminating ~30 lines of duplicated code.

Fixes #9170

Co-authored-by: Copilot <[email protected]>
…ndLineBase

Remove duplicated validation logic from TrxReportGeneratorCommandLine by having
it extend ReportGeneratorCommandLineBase (like CTRF, HTML, and JUnit already do).
This ensures future validation improvements automatically apply to TRX reports.

Fixes #9169

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 16, 2026 13:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors the TRX report generator’s command-line provider to reuse the shared ReportGeneratorCommandLineBase validation pattern used by the other report generators, reducing duplicated option/argument validation logic. The PR also includes an (unrelated) refactor that centralizes console banner text construction and the “skip banner” env-var name into a new helper.

Changes:

  • Update TrxReportGeneratorCommandLine to inherit from ReportGeneratorCommandLineBase and remove local validation overrides.
  • Link ReportGeneratorCommandLineBase.cs into the TRX report extension project to align with CTRF/HTML/JUnit extensions.
  • Extract banner construction / skip-banner env-var constant into OutputDeviceBannerHelper and update output-device call sites to use it.
Show a summary per file
File Description
src/Platform/Microsoft.Testing.Platform/OutputDevice/TerminalOutputDevice.cs Switches banner skip env-var usage and banner text building to OutputDeviceBannerHelper.
src/Platform/Microsoft.Testing.Platform/OutputDevice/SimplifiedConsoleOutputDeviceBase.cs Same banner/env-var refactor as TerminalOutputDevice.
src/Platform/Microsoft.Testing.Platform/OutputDevice/OutputDeviceBannerHelper.cs New helper centralizing banner text construction and env-var constant.
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxCommandLine.cs Moves TRX CLI provider to ReportGeneratorCommandLineBase and supplies its parameters/resources.
src/Platform/Microsoft.Testing.Extensions.TrxReport/Microsoft.Testing.Extensions.TrxReport.csproj Links ReportGeneratorCommandLineBase.cs from SharedExtensionHelpers.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jun 17, 2026

@0101 Petr Pokorny (0101) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Automated safety check passed: no dangerous changes detected (no secrets, exfiltration, destructive ops, or suspicious dependencies). Approving as requested. Note: this is a quick safety sanity check, not a full code review.

…9169-trx-extend-base-class

# Conflicts:
#	src/Platform/Microsoft.Testing.Platform/OutputDevice/OutputDeviceBannerHelper.cs
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) June 17, 2026 09:41
@Evangelink
Amaury Levé (Evangelink) merged commit 0934100 into main Jun 17, 2026
26 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/issue-9169-trx-extend-base-class branch June 17, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[duplicate-code] TrxReportGeneratorCommandLine should extend ReportGeneratorCommandLineBase

3 participants