dotnet / dotnet/command-line-api

dotnet-suggest broken for multiple tools

Open
#1,850 13 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
3.7k
Forks
428
PR merge metrics
No merged PRs in 30d

Description

dotnet-suggest is broken for a lot of standard tools.

My current installed list (according to dotnet-suggest list):
```
dotnet-ef
dotnet ef
security-scan
dotnet-grpc-cli
dotnet grpc-cli
dotnet-suggest
dotnet suggest
dotnet-grpc
dotnet grpc
reportgenerator
```

For most of these, except dotnet-suggest and dotnet-grpc, there are any valid suggestions returned. Usually an exception happens.

It seems to me as if dotnet-suggest should catch any exceptions and all output from a tool and only report suggestions _if_ there are any.

Printing the output from the tool completely breaks autocompletion functions for the existing shell shims, at least on zsh.

In general I don't think _executing_ those tools to get completions is a good idea either. It seems that if a tool is not built using System.CommandLine it will inevitably try to make sense of the [suggest] command which doesn't exist.

Running ```dotnet-suggest get -e``` on those executables yields:

dotnet-ef
```
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at System.String.get_Chars(Int32 index)
at Microsoft.EntityFrameworkCore.Tools.RootCommand.<>c.b__12_0(String a)
at System.Linq.Enumerable.TakeWhileIterator[TSource](IEnumerable`1 source, Func`2 predicate)+MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute(String[] _)
at Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.<>c__DisplayClass0_0.b__0(String[] args)
at Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
Index was outside the bounds of the array.
```

dotnet-grpc-cli
```
Error: Unknown command '[suggest:32767]'.

[suggest:32767]
^^^^^^^^^^^^^^^ No such command
```

security-scan
```
Unhandled exception. System.InvalidOperationException: Invalid solution file path: ''
at Microsoft.CodeAnalysis.MSBuild.DiagnosticReporter.Report(DiagnosticReportingMode mode, String message, Func`2 createException)
at Microsoft.CodeAnalysis.MSBuild.PathResolver.TryGetAbsoluteSolutionPath(String path, String baseDirectory, DiagnosticReportingMode reportingMode, String& absolutePath)
at Microsoft.CodeAnalysis.MSBuild.MSBuildProjectLoader.LoadSolutionInfoAsync(String solutionFilePath, IProgress`1 progress, ILogger msbuildLogger, CancellationToken cancellationToken)
at Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.OpenSolutionAsync(String solutionFilePath, ILogger msbuildLogger, IProgress`1 progress, CancellationToken cancellationToken)
at SecurityCodeScan.Tool.Program.Main(String[] args) in D:\a\security-code-scan\security-code-scan\SecurityCodeScan.Tool\Program.cs:line 296
at SecurityCodeScan.Tool.Program.(String[] args)
╔═╗┌─┐┌─┐┬ ┬┬─┐┬┌┬┐┬ ┬ ╔═╗┌─┐┌┬┐┌─┐ ╔═╗┌─┐┌─┐┌┐┌
╚═╗├┤ │ │ │├┬┘│ │ └┬┘ ║ │ │ ││├┤ ╚═╗│ ├─┤│││
╚═╝└─┘└─┘└─┘┴└─┴ ┴ ┴ ╚═╝└─┘─┴┘└─┘ ╚═╝└─┘┴ ┴┘└┘

.NET tool by Jaroslav Lobačevski v5.6.3

Loading solution ''%
```

reportgenerator
```
2022-09-13T12:34:50: Arguments
2022-09-13T12:34:50: [suggest:32767]
2022-09-13T12:34:50:
2022-09-13T12:34:50: No report files specified.
2022-09-13T12:34:50: No target directory specified.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.