Deduplicate command-line provider boilerplate via CommandLineOptionsProviderBase#8712
Deduplicate command-line provider boilerplate via CommandLineOptionsProviderBase#8712Copilot wants to merge 6 commits into
CommandLineOptionsProviderBase#8712Conversation
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
CommandLineOptionsProviderBase
There was a problem hiding this comment.
Pull request overview
This PR consolidates repeated command-line provider boilerplate by moving migrated providers onto CommandLineOptionsProviderBase and adding an overload that initializes provider metadata from an IExtension.
Changes:
- Adds an
IExtension-backed constructor overload toCommandLineOptionsProviderBase. - Migrates Platform, VSTestBridge, Retry, Azure DevOps, HTML, TRX, and terminal command-line providers to inherit from the shared base.
- Adds unit tests for extension metadata propagation and null extension validation.
Show a summary per file
| File | Description |
|---|---|
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsProviderBase.cs |
Adds the extension-backed base constructor. |
src/Platform/Microsoft.Testing.Platform/CommandLine/PlatformCommandLineProvider.cs |
Moves platform CLI provider metadata/options to the base class. |
src/Platform/Microsoft.Testing.Platform/CommandLine/MaxFailedTestsCommandLineOptionsProvider.cs |
Uses the new extension-backed base path while keeping validation. |
src/Platform/Microsoft.Testing.Platform/CommandLine/TreeNodeFilterCommandLineOptionsProvider.cs |
Simplifies tree-node filter provider via the base class. |
src/Platform/Microsoft.Testing.Platform/OutputDevice/Terminal/TerminalTestReporterCommandLineOptionsProvider.cs |
Moves terminal reporter metadata/options to the base class. |
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/CommandLine/TestCaseFilterCommandLineOptionsProvider.cs |
Uses the base class for VSTest filter option metadata. |
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/CommandLine/TestRunParametersCommandLineOptionsProvider.cs |
Uses the base class while preserving argument validation. |
src/Platform/Microsoft.Testing.Extensions.VSTestBridge/CommandLine/RunSettingsCommandLineOptionsProvider.cs |
Uses the base class while preserving runsettings validation. |
src/Platform/Microsoft.Testing.Extensions.Retry/RetryCommandLineOptionsProvider.cs |
Moves retry provider metadata/options to the base class. |
src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsCommandLineProvider.cs |
Moves Azure DevOps provider metadata/options to the base class. |
src/Platform/Microsoft.Testing.Extensions.HtmlReport/HtmlReportGeneratorCommandLine.cs |
Moves HTML report provider metadata/options to the base class. |
src/Platform/Microsoft.Testing.Extensions.TrxReport/TrxCommandLine.cs |
Moves TRX report provider metadata/options to the base class. |
test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineOptionsProviderBaseTests.cs |
Adds tests for the new extension-backed constructor path. |
Copilot's findings
- Files reviewed: 13/13 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Addresses PR review comments and CI build failures: - Add missing 'override' keyword on ValidateCommandLineOptionsAsync in PlatformCommandLineProvider, HtmlReportGeneratorCommandLine, TrxCommandLine, AzureDevOpsCommandLineProvider - Fix SA1116 by placing first argument on new line in : base(...) / : this(...) constructor initializers across all migrated providers and the base class itself - Fix SA1508 by removing extra blank line before closing brace in TerminalTestReporterCommandLineOptionsProvider Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The original individual providers (e.g. TreeNodeFilterCommandLineOptionsProvider, MaxFailedTestsCommandLineOptionsProvider, RunSettingsCommandLineOptionsProvider) did no validation on Uid/Version and simply assigned extension.Uid / extension.Version directly. The new base class introduced Ensure.NotNullOrWhiteSpace on both, which broke acceptance tests whose test asset (DummyTestFramework) intentionally returns string.Empty for IExtension.Version, DisplayName, and Description. Relax the validation to null-only (matching how displayName and description are already handled in the same constructor) to preserve pre-refactor behavior. Update unit tests so the whitespace cases now assert no-throw. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Fixed the failing acceptance tests ( Root cause: the new Fix: Relaxed the base ctor to null-check only (matching how Validated locally with the |
Multiple
ICommandLineOptionsProviderimplementations were repeating the same extension metadata and default validation/enablement boilerplate despite an existing shared base type. This change consolidates those providers onCommandLineOptionsProviderBaseand adds a base constructor path for extension-delegated metadata.Problem addressed
Uid/Version/DisplayName/Description/default validation boilerplate across Platform and extension command-line providers.Base abstraction updates
CommandLineOptionsProviderBase:CommandLineOptionsProviderBase(IExtension extension, IReadOnlyCollection<CommandLineOption> commandLineOptions)Provider migrations
CommandLineOptionsProviderBase:TestCaseFilter*,TestRunParameters*,RunSettings*PlatformCommandLineProvider,MaxFailedTests*,TreeNodeFilter*,TerminalTestReporter*Unit test coverage
CommandLineOptionsProviderBasetests for:IExtensionconstructor overload