Skip to content

Fix OnlyTake token redistribution order#2817

Closed
marko1olo wants to merge 1 commit into
dotnet:mainfrom
marko1olo:fix-onlytake-token-order
Closed

Fix OnlyTake token redistribution order#2817
marko1olo wants to merge 1 commit into
dotnet:mainfrom
marko1olo:fix-onlytake-token-order

Conversation

@marko1olo

Copy link
Copy Markdown

Summary

  • preserve command-line token order when ArgumentResult.OnlyTake passes tokens through multiple positional arguments
  • redistribute passed-on tokens before each later argument's existing tokens, while respecting each argument's max arity
  • add regression coverage for issue ArgumentResult.OnlyTake distribute not consumed tokens in unexpected way #2734 with six positional arguments and repeated OnlyTake(2) custom parsers

Fixes #2734.

Tests

  • ./build.cmd -projects src\System.CommandLine.Tests\System.CommandLine.Tests.csproj
  • .\.dotnet\dotnet.exe test src\System.CommandLine.Tests\System.CommandLine.Tests.csproj --framework net10.0 --filter "FullyQualifiedName~OnlyTake_preserves_token_order_when_multiple_arguments_pass_on_tokens"
  • .\.dotnet\dotnet.exe test src\System.CommandLine.Tests\System.CommandLine.Tests.csproj --framework net10.0 --no-build --filter "FullyQualifiedName~OnlyTake"
  • .\.dotnet\dotnet.exe test src\System.CommandLine.Tests\System.CommandLine.Tests.csproj --framework net10.0 --filter "FullyQualifiedName~CustomParsingTests"
  • .\.dotnet\dotnet.exe test src\System.CommandLine.Tests\System.CommandLine.Tests.csproj --framework net10.0
  • .\.dotnet\dotnet.exe test src\System.CommandLine.Tests\System.CommandLine.Tests.csproj --framework net472 --filter "FullyQualifiedName~OnlyTake"
  • .\.dotnet\dotnet.exe test src\System.CommandLine.Tests\System.CommandLine.Tests.csproj --framework net472
  • git diff --check

Written by an agent (OpenAI Codex, GPT-5).

@marko1olo marko1olo closed this by deleting the head repository Jul 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArgumentResult.OnlyTake distribute not consumed tokens in unexpected way

2 participants