Skip to content

[MTP dotnet test]: Allow specifying project, solution, directory, or test modules as positional argument#52449

Merged
Youssef1313 merged 3 commits intomainfrom
dev/ygerges/allow-positional-arg
Jan 20, 2026
Merged

[MTP dotnet test]: Allow specifying project, solution, directory, or test modules as positional argument#52449
Youssef1313 merged 3 commits intomainfrom
dev/ygerges/allow-positional-arg

Conversation

@Youssef1313
Copy link
Member

This brings back the same behavior that was with VSTest, where we don't require --project and similar options for specifying what to test.

To limit the impact of this change, we only consider the first unmatched token.

This helps AI agents that always get confused and call MTP incorrectly.

@Youssef1313 Youssef1313 requested a review from a team as a code owner January 14, 2026 08:45
Copilot AI review requested due to automatic review settings January 14, 2026 08:45
@Youssef1313 Youssef1313 force-pushed the dev/ygerges/allow-positional-arg branch from 0dddf98 to 74b4ee0 Compare January 14, 2026 08:51
@Youssef1313 Youssef1313 force-pushed the dev/ygerges/allow-positional-arg branch from 74b4ee0 to 0786567 Compare January 14, 2026 09:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR changes the dotnet test command for Microsoft Testing Platform (MTP) to allow specifying projects, solutions, directories, or test modules as positional arguments (without requiring explicit switches like --project, --solution, or --test-modules), matching the behavior that existed in VSTest. The change only considers the first unmatched token to limit impact.

Changes:

  • Moved validation logic from ValidationUtility.cs to MSBuildUtility.cs and enhanced it to handle positional arguments
  • Added positional argument parsing in GetPositionalArguments() that detects file types and treats the first matching token as a positional argument
  • Updated PathOptions record to include TestModules field and renamed UnmatchedTokens to TestApplicationArguments in BuildOptions

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
MSBuildUtility.cs Added GetPositionalArguments() and ValidatePathOptions() to parse and validate positional arguments for projects, solutions, and test modules
ValidationUtility.cs Removed ValidateSolutionOrProjectOrDirectoryOrModulesArePassedCorrectly() and simplified ValidateMutuallyExclusiveOptions() to work with parsed path options
Options.cs Added TestModules field to PathOptions and renamed UnmatchedTokens to TestApplicationArguments in BuildOptions for clarity
MicrosoftTestingPlatformTestCommand.cs Reordered operations to parse build options before validation and updated condition to check PathOptions.TestModules
TestModulesFilterHandler.cs Changed method signature to accept testModules string parameter instead of extracting it from ParseResult
TestApplication.cs Updated to use renamed TestApplicationArguments field instead of UnmatchedTokens

@Youssef1313 Youssef1313 force-pushed the dev/ygerges/allow-positional-arg branch from 0786567 to 4187d5a Compare January 14, 2026 09:06
@Youssef1313 Youssef1313 force-pushed the dev/ygerges/allow-positional-arg branch from 4187d5a to 3ccebc5 Compare January 14, 2026 09:06
@Youssef1313
Copy link
Member Author

/backport to release/10.0.2xx

@github-actions
Copy link
Contributor

Started backporting to release/10.0.2xx (link to workflow run)

@github-actions
Copy link
Contributor

@Youssef1313 backporting to release/10.0.2xx failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Using index info to reconstruct a base tree...
M	src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
M	src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
M	src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
M	src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
M	src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

@Youssef1313
Copy link
Member Author

/backport to release/10.0.3xx

@github-actions
Copy link
Contributor

Started backporting to release/10.0.3xx (link to workflow run)

@github-actions
Copy link
Contributor

@Youssef1313 backporting to release/10.0.3xx failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Using index info to reconstruct a base tree...
M	src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
M	src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
M	src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
M	src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
M	src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

Youssef1313 added a commit that referenced this pull request Feb 12, 2026
Youssef1313 added a commit that referenced this pull request Feb 12, 2026
Youssef1313 added a commit that referenced this pull request Feb 12, 2026
Youssef1313 added a commit that referenced this pull request Feb 12, 2026
Youssef1313 added a commit that referenced this pull request Feb 12, 2026
Youssef1313 added a commit that referenced this pull request Feb 12, 2026
Youssef1313 added a commit that referenced this pull request Feb 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants