-
Notifications
You must be signed in to change notification settings - Fork 392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dotnet-suggest assumes that dotnet global tools support the [suggest] directive #1777
Comments
I don't know how you do it, but the broad strokes of what you outline is directly in line with what @jonsequitur, @KathleenDollard, and I had been brainstorming for the 'next wave' of suggestions-related features. Kudos! |
There is a security aspect. Using an AssemblyMetadataAttribute or a custom PE section to indicate support for |
A new XML element in an assembly manifest as a Win32 resource might be another possibility. However, if it were possible to refer to a separate executable for retrieving the suggestions, then the relative path of that executable would have to be in the manifest, and this relative path would have to be kept valid when files are copied around. Having the suggestion-support information in DotnetToolSettings.xml seems easier because that file is easier to update at install time if paths change. |
The format of DotnetToolSettings.xml doesn't seem to be documented at https://docs.microsoft.com/. The .NET SDK repository has some documentation for it in Tool NuGet package format (not updated for dotnet/sdk#9179), and the code that validates it is in ToolConfigurationDeserializer.cs. In the NuGet wiki, Global Tools NuGet Implementation also links to some specifications, but those links lead to a repository that is private or has been deleted.
Possible approaches for global tools:
Similar features for local tools seem more difficult. AFAIK, to find the local tool that |
It is not security issue since the application is already accessible in the user session. This is rather an undesirable action. And meta information is the best thing that can solve this problem.
What about non dotnet tools? The solution must be for all custom applications. This XML file could have been generated and distributed with custom application. Even better if it were inside as meta information. |
I think it would be desirable to solve this in a general way of indicating that an executable supports specific features, rather than solving it specifically for .NET Tools, although .NET Tools is a key scenario. |
Perhaps so, if the directory of the executable file is in PATH. But if the file is in an untrusted directory, then it should not be executed to get completions, unless the user has registered it to allow this. Users won't expect such execution. Imagine a user is typing a command line Alternatively, imagine a user is editing a shell script that is intended to run by a different user "samuel". This shell script contains a command |
Do you mean the XML would describe all the options and subcommands supported by the application? Rather than just state that the application supports the If so, I think it would be a good feature but out of scope for this issue. |
Yes. |
GlobalToolsSuggestionRegistration returns suggestion registrations for all executables in ~/.dotnet/tools/, and
dotnet-suggest
can then run such executables with the[suggest]
directive even if they have not been explicitly registered. However, supporting this directive is not a requirement for creating a .NET tool. For example, dotnet-runtimeinfo 1.0.4, dotnet-script 1.1.0, and microsoft.visualstudio.slngen.tool 8.5.0 do not support it. There is a risk that the tool does something unexpected when given '[suggest]' which it does not recognize as a directive. For example, it could create a file with that name, or spend time trying to connect to a computer with that name.I think the best solution would be:
[suggest]
. If it becomes possible to have multiple commands in the same tool package, this information should be specific to each command. The GenerateToolsSettingsFile task in .NET SDK generates DotnetToolSettings.xml and could read some property that the System.CommandLine package would set by default.dotnet tool install
copy this information to some place from whichdotnet-suggest
can find it, regardless of whetherdotnet-suggest
has been installed. For example, place it in ~/.dotnet/tools-suggest.json, or copy the whole XML file to tools/.meta/command/DotnetToolSettings.xml.dotnet-suggest
consult the information from step 2 to ascertain whether the command supports[suggest]
.If a tool supports
[suggest]
but is too old to include this information in its DotnetToolSettings.xml file, then the user candotnet-suggest register
it manually.I also considered adding some AssemblyMetadataAttribute to the entry point assembly of the command, but that doesn't really seem any easier because the executables in ~/.dotnet/tools/ are shims that don't contain CLR metadata. Also it would not be so easily extensible to wholly unmanaged tools.
The text was updated successfully, but these errors were encountered: