Refactor duplicated command-line provider boilerplate into shared base class#8546
Merged
Merged
Conversation
10 tasks
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor duplicate CommandLineProvider boilerplate structure
Refactor duplicated command-line provider boilerplate into shared base class
May 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors repeated ICommandLineOptionsProvider boilerplate across multiple Platform extensions into a shared CommandLineOptionsProviderBase abstraction within Microsoft.Testing.Platform, and adds unit tests to validate the new base defaults.
Changes:
- Introduce
CommandLineOptionsProviderBaseto centralize provider metadata, enablement default, option caching, and default validation behavior. - Migrate HangDump, CrashDump, and MSBuild command-line providers to inherit from the new base class.
- Add unit tests covering default base behavior and constructor-supplied options exposure.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/CommandLineOptionsProviderBaseTests.cs | Adds unit tests validating the new base class defaults and option passthrough. |
| src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsProviderBase.cs | Introduces the shared base class for command-line option providers. |
| src/Platform/Microsoft.Testing.Extensions.MSBuild/MSBuildCommandLineProvider.cs | Refactors MSBuild provider to use the shared base + cached options. |
| src/Platform/Microsoft.Testing.Extensions.HangDump/HangDumpCommandLineProvider.cs | Refactors HangDump provider to use the shared base and override validation. |
| src/Platform/Microsoft.Testing.Extensions.CrashDump/CrashDumpCommandLineProvider.cs | Refactors CrashDump provider to use the shared base and override validation. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 1
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Duplicate-code analysis identified repeated
ICommandLineOptionsProviderscaffolding across diagnostic/extension providers, with identical metadata, enablement, option-caching, and default validation structure. This change extracts that shared structure and keeps provider-specific validation logic local.What changed
CommandLineOptionsProviderBaseinMicrosoft.Testing.Platformto centralize:Uid,Version,DisplayName,Description)IsEnabledAsync()default behaviorGetCommandLineOptions()Provider migrations (behavior preserved)
HangDumpCommandLineProviderCrashDumpCommandLineProviderMSBuildCommandLineProviderCoverage for new abstraction
CommandLineOptionsProviderBasedefaults and constructor-supplied options surface.