Include full command in MTP command-line validation error messages #6201
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.
When running MTP applications with invalid command-line arguments, error messages previously only showed the problematic option without context about the complete command that was executed. This made debugging difficult in automation scenarios where users might not see the actual command being invoked.
Problem
The original error message was not helpful for debugging:
In automation scenarios like CI/CD pipelines, users often don't see the exact command being run, making it hard to understand what went wrong.
Solution
Added a new
ToCommandLine()
method toCommandLineParseResult
that reconstructs the full command from parsed options. Updated validation error messages to include the complete command that was executed.After
The error message now includes the full command for better debugging:
Changes Made
ToCommandLine()
method: Reconstructs the command line fromCommandLineParseResult
including tool name, options, and argumentsPlatformResources.resx
to include command context in validation error messagesCommandLineOptionsValidator
to use the reconstructed command in error messages.xlf
files with new source strings for proper localization supportArgumentArityTests
to reflect new error message formatImplementation Details
The
ToCommandLine()
method properly handles:This is a minimal change that only affects error message formatting without modifying parsing logic or public APIs.
Fixes #6194.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.