Skip to content

dotnet-suggest: Completion when launching global tool via "dotnet" #2302

@ralish

Description

@ralish

Tools that have a dotnet- prefix (e.g. dotnet-monitor) can be invoked via the main dotnet executable. I.e. you can launch a tool named dotnet-monitor by running dotnet-monitor or dotnet monitor (note the space). The latter simply results in dotnet launching the dotnet-monitor tool indirectly (so it's clearly less efficient), but from the user's perspective you get the same result.

The dotnet-suggest tool however only appears to successfully provide suggestions for tools that are directly invoked, even though such tools register both their potential entrypoints in .dotnet-suggest-registration.txt. I took a look at the code and the relevant part seems to be the FormatSuggestionArguments method in the SuggestionDispatcher class.

If the executable is dotnet it uses a different code path that strips the second token before passing it through to the target executable for suggestions. Some examples to help illustrate:

  • dotnet monitor -> invokes dotnet [suggest:0] ""
  • dotnet monitor config -> invokes dotnet [suggest:6] "config"
  • dotnet monitor config show -> invokes dotnet [suggest:11] "config show"

I don't understand what this logic is trying to do. Is there some subtlety I'm missing here? Even if I manually send what I think should be the "correct" args to dotnet I still don't get back correct completions, e.g. dotnet [suggest:13] "monitor config", so it's unclear if this is meant to work at all, or ever did. But in that case, why do tools using System.CommandLine register their dotnet aliases?

I am very confused ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions