Improve unknown command-line option guidance - #10798
Conversation
Suggest uniquely matching registered or known extension options and identify the package that auto-registers missing extension options. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f53849d1-b75f-4292-8452-9279531cc9ca
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Note
🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.
✅ 22/22 dimensions clean — no findings.
Summary: This PR adds "did you mean" suggestions and known-extension package hints for unknown CLI options. The implementation is well-scoped:
KnownExtensionOptionsByPackageis astatic readonly Dictionaryinitialized once — safe for concurrent reads.- The Damerau-Levenshtein edit distance and LINQ enumeration are only invoked on the error path (unknown options), so the allocations are acceptable.
- All new code is
private static/internal— no public API surface changes. - Resource strings are properly added to
.resxwith correct{0}/{1}placeholders and no{Locked}concerns;.xlffiles are regenerated. - Tests cover: close-match suggestion, ambiguous-match suppression, exact known-extension match, misspelled extension option (both with and without the extension registered), and all 11 extension packages.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Improves unknown CLI option errors with typo suggestions and missing-extension package guidance.
Changes:
- Adds edit-distance matching while excluding hidden and ambiguous candidates.
- Maps known extension options to their NuGet packages.
- Adds localized resources and unit tests.
Show a summary per file
| File | Description |
|---|---|
CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs |
Implements option and package suggestions. |
PlatformResources.resx |
Adds guidance messages. |
PlatformResources.cs.xlf |
Updates Czech localization resources. |
PlatformResources.de.xlf |
Updates German localization resources. |
PlatformResources.es.xlf |
Updates Spanish localization resources. |
PlatformResources.fr.xlf |
Updates French localization resources. |
PlatformResources.it.xlf |
Updates Italian localization resources. |
PlatformResources.ja.xlf |
Updates Japanese localization resources. |
PlatformResources.ko.xlf |
Updates Korean localization resources. |
PlatformResources.pl.xlf |
Updates Polish localization resources. |
PlatformResources.pt-BR.xlf |
Updates Portuguese localization resources. |
PlatformResources.ru.xlf |
Updates Russian localization resources. |
PlatformResources.tr.xlf |
Updates Turkish localization resources. |
PlatformResources.zh-Hans.xlf |
Updates Simplified Chinese resources. |
PlatformResources.zh-Hant.xlf |
Updates Traditional Chinese resources. |
CommandLineHandlerTests.cs |
Tests typo and extension guidance behavior. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 16/16 changed files
- Comments generated: 1
- Review effort level: Balanced
Cover the user-visible rule that hidden registered options are excluded from typo suggestions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f53849d1-b75f-4292-8452-9279531cc9ca
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs:193
- When a tool is selected,
ValidateAsyncfirst filters out every non-tool provider (CommandLineOptionsValidator.cs:55-59). Therefore a command such astool --report-trxreaches this branch and says to addMicrosoft.Testing.Extensions.TrxReport, even if that package/provider is already registered—and adding it cannot make a normal extension option valid in tool mode. Please suppress package-reference guidance for tool invocations, or retain the unfiltered provider set so this path can distinguish a missing package from an option that is unavailable in the selected command scope.
string? packageName = GetKnownExtensionPackage(unknownOptionName);
if (packageName is not null)
{
AppendMissingExtensionSuggestion(stringBuilder, unknownOptionName, packageName);
- Files reviewed: 16/16 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🤖 Automated content by GitHub Copilot. Generated by the Test Reviewer on PR (on open / sync) workflow. · auto · 100.6 AIC · ⌖ 1.14 AIC · ⊞ 16.9K · ◷
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
…ve/cli-extension-suggestions
This comment has been minimized.
This comment has been minimized.
Restore known option-to-package metadata and diagnostics for automatically registered first-party extensions, including Microsoft code coverage. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f53849d1-b75f-4292-8452-9279531cc9ca
There was a problem hiding this comment.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs:104
- The
<= 12 => 2and_ => 3thresholds are not exercised by the added tests: every positive case is only one edit away, so changing both branches to return1would leave all 50 tests passing. Add cases where a 5–12 character option requires exactly two edits and a >12 character option requires exactly three edits (plus just-over-threshold negatives) so these user-visible boundaries cannot regress.
],
["Microsoft.Testing.Extensions.VideoRecorder"] =
[
"capture-video",
"capture-video-args",
- Files reviewed: 16/16 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…gestions' into pr/10798/dev/amauryleve/cli-extension-suggestions
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Review details
Suppressed comments (1)
src/Platform/Microsoft.Testing.Platform/CommandLine/CommandLineOptionsValidator.UnknownAndBootstrapValidation.cs:204
- This adds every catalogued extension option to the suggestion candidates even when its provider is not registered, while the PR description says suggestions only consider visible options registered for the current invocation and avoid unregistered options. The new package-guidance tests confirm that the implementation intentionally does the opposite. Please update either the implementation or the PR description so the documented behavior matches what ships.
string? suggestedOptionName = FindSuggestedOption(
unknownOptionName,
visibleOptionNames.Concat(KnownExtensionOptionsByPackage.Values.SelectMany(static optionNames => optionNames)));
- Files reviewed: 16/16 changed files
- Comments generated: 1
- Review effort level: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🧵 Parallel-safety audit — PR #10798Parallelization — one row per test assembly audited:
Findings: A (global-state) 0 · B (paths) 0 · C (declaration) 0 · D (over-serialization) 0 — no severities to report. The only changed test file is
Nothing in this diff introduces a parallel-safety hazard, and the pre-existing test class (already at Advisory only — heuristic, non-blocking. Re-run with
|
🧪 Expert test review — PR #10798
Summary: The nine new/modified tests in This advisory comment was generated automatically. Grades are heuristic
|
main (via #10798 "Improve unknown command-line option guidance", merged before this branch's main sync) added two new PlatformResources.resx entries without a corresponding OneLocBuild pass, which fails CI's `--report-trx`-unrelated Build Linux/Windows checks with an "xlf is out-of-date" error from Microsoft.DotNet.XliffTasks. Regenerated via `dotnet msbuild src/Platform/Microsoft.Testing.Platform/Microsoft.Testing.Platform.csproj /t:UpdateXlf` per this repo's localization guidelines; no manual xlf edits. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Summary
Validation
mainCommandLineHandlerTestsonnet8.0