Report unclosed quotes in response files#8448
Open
Copilot wants to merge 3 commits into
Open
Conversation
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix unclosed quotes in response files handling
Report unclosed quotes in response files
May 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request improves Microsoft.Testing.Platform command-line response file handling by treating malformed quoted tokens as parsing errors (rather than silently accepting and dropping unterminated arguments), and updates unit tests to cover the new behavior.
Changes:
- Detect and fail response-file parsing when a line contains an unclosed quote, including reporting the response-file line number.
- Update
SplitCommandLineto reject unterminated quoted input by throwingFormatException. - Add/adjust unit tests to validate the new failure behavior for malformed quoted input.
Show a summary per file
| File | Description |
|---|---|
| test/UnitTests/Microsoft.Testing.Platform.UnitTests/CommandLine/ResponseFileHelperTests.cs | Adds coverage for unclosed quotes in response files and updates tokenizer test expectations to require failure. |
| src/Platform/Microsoft.Testing.Platform/CommandLine/ResponseFileHelper.cs | Adds line-aware tokenization for response-file lines and throws FormatException on unclosed quotes; TryReadResponseFile converts format errors into a failed result. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Catch UnauthorizedAccessException in TryReadResponseFile and report via the standard CommandLineParserFailedToReadResponseFile error path. - Move unclosed-quote FormatException messages into PlatformResources for localization and drop trailing periods to avoid doubled punctuation when wrapped by CommandLineParserFailedToReadResponseFile. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Youssef1313
reviewed
May 21, 2026
Member
Youssef1313
left a comment
There was a problem hiding this comment.
This was a copy from System.CommandLine. I would be skeptical to making changes here without validating System.CommandLine behavior first and even then, I would fix it in S.CL first before making a change here.
Youssef1313
reviewed
May 21, 2026
Comment on lines
+26
to
+33
| catch (UnauthorizedAccessException e) | ||
| { | ||
| errors.Add(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineParserFailedToReadResponseFile, rspFilePath, e.Message)); | ||
| } | ||
| catch (FormatException e) | ||
| { | ||
| errors.Add(string.Format(CultureInfo.InvariantCulture, PlatformResources.CommandLineParserFailedToReadResponseFile, rspFilePath, e.Message)); | ||
| } |
Member
There was a problem hiding this comment.
Sounds unrelated to what the PR wants to do.
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.
Malformed quoted tokens in response files were silently accepted, causing unterminated arguments to be dropped while
TryReadResponseFilestill reported success. This can turn a response-file typo into misleading or partial command-line parsing.Response file parsing
TryReadResponseFileresult.Tokenization behavior
SplitCommandLinenow rejects unterminated quoted input instead of returning an empty or partial result.--filter "FullyQualifiedName~My.NamespaceNow reports a response-file parse error instead of silently dropping the filter argument.