question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove Legacy `--` behavior and use of UnparsedTokens

See original GitHub issue

Is your feature request related to a problem? Please describe.

As part of cleaning up the CLI, we should remove our use of the LegacyDoubleDashHandling logic in System.CommandLine, and instead be explicit about argument forwarding as described here. We are the main user of LegacyDoubleDashHandling, and System.CommandLine wants to remove that API entirely (see https://github.com/dotnet/command-line-api/issues/1653).

Describe the solution you’d like

In places where we use the double-dash behavior and UnparsedTokens to forward arguments along, we should instead create an explicit string[] Argument and forward the value of that argument along. This also leads to more useful help displays for the user.

Areas of specific interest/concern

Direct use of UnparsedTokens

These are straightforward, and in the ‘new world’ would simply be removed, as the UnmatchedTokens + a new string[] argument should cover all use cases

ParseResult.GetArguments()/ParseResult.GetSubArguments()

Definition is here. The GetArguments() extension method is commonly used to grab all of the tokens in a command and delegate them to some non-bundled command. Adding a string[] argument may make this easier/not necessary to do for some forwarding applications.

GetSubArguments() is the more concerning one to me - it actually modifies the token stream. This may not be necessary after the change to the -- handling, but the custom logic about removing the dotnet command if it is prepended, as well as the 'top-level` command, may still be required.

Direct use of -- in command processors

Specific commands/scenarios to verify

  • dotnet build
  • dotnet msbuild
  • dotnet test
  • dotnet vstest
  • dotnet run
  • dotnet publish
  • any nuget command

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Tundukcommented, Jul 24, 2022

@marcpopMSFT I think you can close this issue. PR fixed it. @baronfel I’ll create a separate issue for custom parsers, so we won’t forget about it.

1reaction
baronfelcommented, Apr 20, 2022

Yes, of course! The problem with removing UnparsedToken is that it’s currently being populated by the LegacyDoubleDashHandling setting we have configured. So if we want to remove use of UnparsedToken we have to change the value of this setting, and that means that we have to fix the semantics of all of these call-sites. It’s definitely a puzzle 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Analyze and manage events with the legacy behavioral ...
Click Behavioral Events (legacy). You'll then be brought to the Manage tab of the legacy behavioral events page. To delete events, select the...
Read more >
Legacy Behavioral Health Services - Serving South Georgia
Legacy Behavioral Health Services provides mental health, substance abuse, intellectually and developmentally disabled services to our communities.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found