You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR simplifies code recently added in PR #10798 ("Improve unknown command-line option guidance") to remove duplicated logic while preserving all functionality.
Files Simplified
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs - Extracted duplicated logic into a shared helper
Improvements Made
Reduced Duplication
ValidateNoUnknownOptions contained two nearly identical foreach loops — one iterating extensionOptionsByProvider and one iterating systemOptionsByProvider — both populating validOptionNames and visibleOptionNames in exactly the same way.
Extracted this shared logic into a new private static helper, CollectOptionNames(optionsByProvider, validOptionNames, visibleOptionNames), and call it twice instead of duplicating the loop body.
Enhanced Clarity
ValidateNoUnknownOptions is now shorter and its intent (aggregate valid/visible option names from two provider sources) is clearer at a glance.
🤖 Automated content by GitHub Copilot. Generated by the Code Simplifier workflow. · auto · 99.4 AIC · ⌖ 3.97 AIC · ⊞ 14.1K · [◷]( · ◷)
Add this agentic workflow to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/code-simplifier.md@main
expires on Aug 28, 2026, 5:00 PM UTC
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch code-simplifier/dedup-collect-option-names-ee5b9e3c009573bf.
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (81 of 81 lines)
From 55be8d1f46c44dd075e0c5a4eea324df3c20299b Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 7361f3d0eceb63eef61cec52b090612080ce87c7
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 27 Aug 2026 16:58:30 +0000
Subject: [PATCH] Deduplicate option-name collection in
CommandLineOptionsValidator
Extract the two identical foreach loops in ValidateNoUnknownOptions
(over extensionOptionsByProvider and systemOptionsByProvider) into a
shared CollectOptionNames helper to remove duplicated logic.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
...Validator.UnknownAndBootstrapValidation.cs | 43 +++++++++----------
1 file changed, 20 insertions(+), 23 deletions(-)
diff --git a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs
index 51a6f9e..722482f 100644
--- a/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs+++ b/src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs@@ -122,29 +122,8 @@ private static ValidationResult ValidateNoUnknownOptions(
var validOptionNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
var visibleOptionNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
bool includeKnownExtensionOptions = !parseResult.HasTool;
- foreach (KeyValuePair<ICommandLineOptionsProvider, IReadOnlyCollection<CommandLineOption>> provider in extensionOptionsByProvider)- {- foreach (CommandLineOption option in provider.Value)- {- validOptionNames.Add(option.Name);- if (!option.IsHidden)- {- visibleOptionNames.Add(option.Name);- }- }-
... (truncated)
This PR simplifies code recently added in PR #10798 ("Improve unknown command-line option guidance") to remove duplicated logic while preserving all functionality.
Files Simplified
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs- Extracted duplicated logic into a shared helperImprovements Made
Reduced Duplication
ValidateNoUnknownOptionscontained two nearly identicalforeachloops — one iteratingextensionOptionsByProviderand one iteratingsystemOptionsByProvider— both populatingvalidOptionNamesandvisibleOptionNamesin exactly the same way.CollectOptionNames(optionsByProvider, validOptionNames, visibleOptionNames), and call it twice instead of duplicating the loop body.Enhanced Clarity
ValidateNoUnknownOptionsis now shorter and its intent (aggregate valid/visible option names from two provider sources) is clearer at a glance.Changes Based On
Recent changes from:
Testing
./build.sh -c Debugsucceeded with 0 warnings / 0 errorsdotnet test test/UnitTests/Microsoft.Testing.Platform.UnitTests -f net8.0 --filter "FullyQualifiedName~CommandLineHandlerTests"— 69/69 passedReview Focus
Please verify:
Warning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
southcentralus0.in.applicationinsights.azure.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.
Add this agentic workflow to your repo
To install this agentic workflow, run
Note
This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch
code-simplifier/dedup-collect-option-names-ee5b9e3c009573bf.Click here to create the pull request
To fix the permissions issue, go to Settings → Actions → General and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ
Show patch preview (81 of 81 lines)