Completion for dotnet add package doesn't work well
See original GitHub issueSteps to reproduce
Try to use tab completion in PS (after setting it up) or dotnet complete
with partial package name.
If the NuGet API is not suitable for this right now, then I think it should be improved.
For example, when trying to add the package Microsoft.CodeAnalysis.CSharp
, I might invoke tab completion at one of the following points:
dotnet add package Mic<Tab>
dotnet add package Micr<Tab>
dotnet add package Microsoft.Cod<Tab>
dotnet add package Microsoft.Code<Tab>
dotnet add package Microsoft.CodeA<Tab>
dotnet add package Microsoft.CodeAnalysis.C<Tab>
dotnet add package Microsoft.CodeAnalysis.CS<Tab>
Expected behavior
Since package names are hierarchical by convention, tab completion should guide me to the package I’m looking for, word by word, based on the prefix I’ve already typed. In cases when there’s ambiguity, the output should not unnecessarily overwhelm with full package names. At the very least, it should not harm me by completing the wrong package.
Note that I’m using Set-PSReadlineKeyHandler -Key Tab -Function Complete
, which overrides the default PS behavior of completing to the first matching value, with bash-like partial completion.
Specifically, what I would ideally expect:
Mic
> dotnet add package Mic<Tab>
Display all 100 possibilities? (y or n) y
MicCodes
MicDrop
MickRoper
miCoach
MIConvexHull
MIConvexHullEx
Micosoft
MicosoftReportViewerWebForms_v11
Micro_MVVM
MicroApis
MicroApiService
MicroArgChecker
MicroAssistantDLL
Microbe
MicroBuild
Microbus
MicroCms
MicroComponents
MicroCQRS
Microcrumbs
…
Notice that those are not full package names, just the “segment” before the first .
(or possibly also other separators, like -
?).
Micr
> dotnet add package Micr<Tab>
Display all 100 possibilities? (y or n) y
Micro_MVVM
MicroApis
MicroApiService
MicroArgChecker
MicroAssistantDLL
Microbe
MicroBuild
Microbus
MicroCms
MicroComponents
MicroCQRS
Microcrumbs
MicroDal
MicroDBHelper
MicroDDD
MicroDI
MicroDocum
MicroDot
MicroEdge
MicroElements
…
Microsoft.Cod
dotnet add package Microsoft.Cod<Tab>
→ dotnet add package Microsoft.Code
Microsoft.Code
> dotnet add package Microsoft.Code<Tab>
Microsoft.CodeAnalysis
Microsoft.CodeContracts
Microsoft.CodeCoverage
Microsoft.CodeDom
Microsoft.CodedUI
Microsoft.CodeQuality
Microsoft.CodeA
dotnet add package Microsoft.CodeA<Tab>
→ dotnet add package Microsoft.CodeAnalysis
Microsoft.CodeAnalysis.C
> dotnet add package Microsoft.CodeAnalysis.C<Tab>
Microsoft.CodeAnalysis.CodeActions
Microsoft.CodeAnalysis.Common
Microsoft.CodeAnalysis.Compilers
Microsoft.CodeAnalysis.Core
Microsoft.CodeAnalysis.CSharp
Microsoft.CodeAnalysis.CS
dotnet add package Microsoft.CodeAnalysis.CS<Tab>
→ dotnet add package Microsoft.CodeAnalysis.CSharp
Actual behavior
Mic
> dotnet add package Mic<Tab>
csmic MicCodes.Logger.DebugLogger MicCodes.MvcPager MicCodes.Storage MicCodes.WebApi.ExceptionFilter
MicCodes.Data.Multitenant MicCodes.Logger.NLog MicCodes.Notify MicCodes.Storage.Core MicCodes.WeChat.SDK.Core
MicCodes.ECharts MicCodes.Mvc.AccessFilter MicCodes.Notify.SignalR MicCodes.Storage.Local MicCodes.WeiChat.Storage.Azure.Core
MicCodes.ECharts.Mvc MicCodes.Mvc.AuditFilter MicCodes.Sms MicCodes.Storage.Local.Core MicDrop
MicCodes.Logger MicCodes.Mvc.RoleMenuFilter MicCodes.Sms.Core MicCodes.Tasks
Micr
dotnet add package Micr<Tab>
→ dotnet add package MicrOrm
(!!!)
Microsoft.Cod
dotnet add package Microsoft.Cod<Tab>
: nothing
Microsoft.Code
> dotnet add package Microsoft.Code<Tab>
Display all 100 possibilities? (y or n) _
Microsoft.CodeA
> dotnet add package Microsoft.CodeA<Tab>
Microsoft.CodeAnalysis Microsoft.CodeAnalysis.CSharp.Workspaces Microsoft.CodeAnalysis.VisualBasic.es
Microsoft.CodeAnalysis.Analyzers Microsoft.CodeAnalysis.CSharp.Workspaces.de Microsoft.CodeAnalysis.VisualBasic.Features
Microsoft.CodeAnalysis.CodeActions Microsoft.CodeAnalysis.CSharp.Workspaces.es Microsoft.CodeAnalysis.VisualBasic.fr
Microsoft.CodeAnalysis.Common Microsoft.CodeAnalysis.CSharp.Workspaces.fr Microsoft.CodeAnalysis.VisualBasic.FxCopAnalyzers
Microsoft.CodeAnalysis.Common.de Microsoft.CodeAnalysis.CSharp.Workspaces.it Microsoft.CodeAnalysis.VisualBasic.it
Microsoft.CodeAnalysis.Common.es Microsoft.CodeAnalysis.CSharp.Workspaces.ja Microsoft.CodeAnalysis.VisualBasic.ja
Microsoft.CodeAnalysis.Common.fr Microsoft.CodeAnalysis.CSharp.Workspaces.ko Microsoft.CodeAnalysis.VisualBasic.ko
Microsoft.CodeAnalysis.Common.it Microsoft.CodeAnalysis.CSharp.Workspaces.ru Microsoft.CodeAnalysis.VisualBasic.ru
Microsoft.CodeAnalysis.Common.ja Microsoft.CodeAnalysis.CSharp.Workspaces.zh-Hans Microsoft.CodeAnalysis.VisualBasic.Workspaces
Microsoft.CodeAnalysis.Common.ko Microsoft.CodeAnalysis.CSharp.Workspaces.zh-Hant Microsoft.CodeAnalysis.VisualBasic.Workspaces.de
Microsoft.CodeAnalysis.Common.ru Microsoft.CodeAnalysis.CSharp.zh-Hans Microsoft.CodeAnalysis.VisualBasic.Workspaces.es
Microsoft.CodeAnalysis.Common.zh-Hans Microsoft.CodeAnalysis.CSharp.zh-Hant Microsoft.CodeAnalysis.VisualBasic.Workspaces.fr
Microsoft.CodeAnalysis.Common.zh-Hant Microsoft.CodeAnalysis.EditorFeatures Microsoft.CodeAnalysis.VisualBasic.Workspaces.it
Microsoft.CodeAnalysis.Compilers Microsoft.CodeAnalysis.EditorFeatures.Text Microsoft.CodeAnalysis.VisualBasic.Workspaces.ja
Microsoft.CodeAnalysis.Compilers.de Microsoft.CodeAnalysis.EditorFeatures.Text.de Microsoft.CodeAnalysis.VisualBasic.Workspaces.ko
Microsoft.CodeAnalysis.Compilers.es Microsoft.CodeAnalysis.EditorFeatures.Text.es Microsoft.CodeAnalysis.VisualBasic.Workspaces.ru
Microsoft.CodeAnalysis.Compilers.fr Microsoft.CodeAnalysis.EditorFeatures.Text.fr Microsoft.CodeAnalysis.VisualBasic.Workspaces.zh-Hans
Microsoft.CodeAnalysis.Compilers.it Microsoft.CodeAnalysis.EditorFeatures.Text.it Microsoft.CodeAnalysis.VisualBasic.Workspaces.zh-Hant
Microsoft.CodeAnalysis.Compilers.ja Microsoft.CodeAnalysis.EditorFeatures.Text.ja Microsoft.CodeAnalysis.VisualBasic.zh-Hans
Microsoft.CodeAnalysis.Compilers.ko Microsoft.CodeAnalysis.EditorFeatures.Text.ko Microsoft.CodeAnalysis.VisualBasic.zh-Hant
Microsoft.CodeAnalysis.CSharp Microsoft.CodeAnalysis.EditorFeatures.Text.ru Microsoft.CodeAnalysis.Workspaces.Common
Microsoft.CodeAnalysis.CSharp.de Microsoft.CodeAnalysis.EditorFeatures.Text.zh-Hans Microsoft.CodeAnalysis.Workspaces.Common.de
Microsoft.CodeAnalysis.CSharp.es Microsoft.CodeAnalysis.EditorFeatures.Text.zh-Hant Microsoft.CodeAnalysis.Workspaces.Common.es
Microsoft.CodeAnalysis.CSharp.Extensions Microsoft.CodeAnalysis.Features Microsoft.CodeAnalysis.Workspaces.Common.fr
Microsoft.CodeAnalysis.CSharp.Features Microsoft.CodeAnalysis.FxCopAnalyzers Microsoft.CodeAnalysis.Workspaces.Common.it
Microsoft.CodeAnalysis.CSharp.fr Microsoft.CodeAnalysis.FxCopAnalyzers.Common Microsoft.CodeAnalysis.Workspaces.Common.ja
Microsoft.CodeAnalysis.CSharp.FxCopAnalyzers Microsoft.CodeAnalysis.Razor Microsoft.CodeAnalysis.Workspaces.Common.ko
Microsoft.CodeAnalysis.CSharp.it Microsoft.CodeAnalysis.Scripting Microsoft.CodeAnalysis.Workspaces.Common.ru
Microsoft.CodeAnalysis.CSharp.ja Microsoft.CodeAnalysis.Scripting.Common Microsoft.CodeAnalysis.Workspaces.Common.zh-Hans
Microsoft.CodeAnalysis.CSharp.ko Microsoft.CodeAnalysis.Test.Resources.Proprietary Microsoft.CodeAnalysis.Workspaces.Common.zh-Hant
Microsoft.CodeAnalysis.CSharp.ru Microsoft.CodeAnalysis.VisualBasic Peachpie.Microsoft.CodeAnalysis
Microsoft.CodeAnalysis.CSharp.Scripting Microsoft.CodeAnalysis.VisualBasic.de
Microsoft.CodeAnalysis.C
dotnet add package Microsoft.CodeAnalysis.C<Tab>
: nothing
Microsoft.CodeAnalysis.CS
dotnet add package Microsoft.CodeAnalysis.CS<Tab>
: nothing
Environment data
dotnet --info
output:
.NET Core SDK (reflecting any global.json):
Version: 2.1.300-preview2-008533
Commit: 996eb6c92c
Runtime Environment:
OS Name: Windows
OS Version: 10.0.16299
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.1.300-preview2-008533\
Host (useful for support):
Version: 2.1.0-preview2-26406-04
Commit: 6833f3026b
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
You should use the autocomplete API and not the search API: https://api-v2v3search-0.nuget.org/autocomplete?q=Microsoft.Cod
That is nice, and there is no start char limit