Closed ar0311 closed 4 years ago
That initial lookup for Newtonsoft.Json
is just to warm up the NuGet client. Can you post the csproj file contents you’re using? And the version of VS Code, too.
Version of VS code is 1.42.1
The csproj is just what one would get off a dotnet new console as below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft." Version="" />
</ItemGroup>
</Project>
Hmm, I just tried the latest version of the extension with v1.42.1 of VS Code, and that project file. This is what I'm seeing:
BTW, the language service is built against netcoreapp3.0
(i.e. requires 3.0.x runtime) but I see you only have the 3.1 SDK installed. Could you try installing the 3.0.x runtime and see if the problem persists? It's a side-by-side install so shouldn't affect your existing 3.1.x install.
I believe it's meant to automatically roll forward to the next version of the runtime but 3.0->3.1 is a pretty big jump.
No joy there either.
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
I'm almost certain its something with my environment, how else would firing up a VM and performing a from scratch install still not work?
I even tethered my Mac to the phone to remove the possibility of something in the network causing it.
Anything else I can log to try to get to the bottom of this?
Do you get relevant tool tips when you hover over elements in the XML?
Any ideas what else I can try?
Sorry, work has been absolutely crazy today! I'll try to figure something out tonight :-)
Can you try this version?
Just tried that version, still no autocomplete. I've run Wireshark today and cant see any https going to nuget.org either
Ok so you are getting tooltips. That means the language service is correctly connected to VS code and has successfully loaded the project.
Do you have a nuget.config
(in the solution directory or under your home directory)?
And if you remove the existing PackageReference element and try to type the opening angle bracket what do you see then?
I have a NuGet.config in ~/.nuget/NuGet/NuGet.config (standard place on MacOS)
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
Ok so you get element completions too. Very odd. Just the package Ids that you get no suggestions for. What if you insert the PackageReference element and in the Include attribute type “Newt” then hit ctrl-space? Would be interesting to see the logs after that as well...
Okay we are getting somewhere....
And the tail of the log:
Finding descriptor for "textDocument/completion"
Found attributes 1, ["msbuild::file:///Users/adam/Repos/console31/console31.csproj"]
Looking for handler for method ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]
Checking handler ["OmniSharp.Extensions.LanguageServer.Server.HandlerDescriptor"]:"MSBuildProjectTools.LanguageServer.Handlers.CompletionHandler"
Registration options "OmniSharp.Extensions.LanguageServer.Protocol.Models.CompletionRegistrationOptions"
Document Selector "[msbuild, file, **/*.*], [xml, file, **/*.*proj], [xml, file, **/*.props], [xml, file, **/*.targets]"
Starting: Routing Request (29) "textDocument/completion"
Converting params for Request (29) "textDocument/completion" to "OmniSharp.Extensions.LanguageServer.Protocol.Models.TextDocumentPositionParams"
Completion requested for 9,36
Completion will target 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Not offering any completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (cannot insert or replace an element here).
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Not offering any completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (not a direct child of a 'ItemGroup' element).
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Evaluate attribute completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Not offering any attribute completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (not a location where we can offer attribute completion.
Evaluate element completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Not offering any element completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (not a location where an item metadata element can be created or replaced by completion).
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Offering completions for value of attribute "Include" of "PackageReference" element @ 9,36
Requesting suggestions for NuGet package Ids matching prefix "Newt" (include pre-release: True)...
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Not offering any completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (not a direct child of a 'PropertyGroup' element).
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Not offering any completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (not the value of a supported attribute on a 'Target' element).
Not offering task element completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (task completions not enabled in extension settings).
Not offering task attribute completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (task completions not enabled in extension settings).
Evaluate completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Not offering any completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (not a direct child of the 'Project' element).
Found 12 suggestions for NuGet package Ids matching prefix "Newt" (include pre-release: True).
Offering 12 completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37))
Offering a total of 12 completions for 9,36 -> [Attribute, Value]:/Project/ItemGroup/PackageReference/Include ([9,23..9,37)) (Exhaustive: False).
Result was "System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1+AsyncStateMachineBox`1[[OmniSharp.Extensions.LanguageServer.Protocol.Models.CompletionList, OmniSharp.Extensions.LanguageProtocol, Version=0.7.9.0, Culture=neutral, PublicKeyToken=null],[MSBuildProjectTools.LanguageServer.Handlers.CompletionHandler+<OmniSharp-Extensions-JsonRpc-IRequestHandler<OmniSharp-Extensions-LanguageServer-Protocol-Models-TextDocumentPositionParams\,OmniSharp-Extensions-LanguageServer-Protocol-Models-CompletionList>-Handle>d__28, MSBuildProjectTools.LanguageServer.Engine, Version=0.3.5.0, Culture=neutral, PublicKeyToken=null]]"
Response value was "OmniSharp.Extensions.LanguageServer.Protocol.Models.CompletionList"
Finished: Routing Request (29) "textDocument/completion" in 233ms
Interesting! Ok, so what’s different this time?
No idea. Seems to work fine with Ctrl-Space but just wont show them in an Intellisense fashion (pop up automatically).
Ah! That’s interesting, I didn’t realise that’s what you meant (sorry hard to read on mobile sometimes).
That’s because when we register with LSP we have to tell it which characters trigger completion and in a language where you frequently have to type “.” as part of filenames, it becomes super annoying quite quickly! So we only automatically trigger on “<“ at present.
All good. I'm happy with using Ctrl-Space, can live without Intellisense for package names/versions.
I've also noticed that packages with only pre-release versions available are not brought up in suggestions. Can you try Microsoft.AspNetCore.Components.Web (Ctrl-Space) and see if you get a suggestion for WebAssembly? If you type the package name manually then Ctrl-Space for versions available then they do come up. (I have pre-release on in settings)
Hmm, no - I get no suggestions for that either.
I suspect it may be this bug in the NuGet client library. I'll try upgrading to the latest version sometime tomorrow and see if that fixes the problem :)
Haha, did some digging and it turns out that it was me who found and reported this bug this a while back:
Yes I seem to remember that. Thanks for the awesome help. I have another issue but will search closed issues first, otherwise will open new one. Cheers again.
I have same problem and Ctrl-Space not working either
opening angle bracket autocomplete working relevant tool tips working
Ctrl-Space will switch input method in macOS, so disable this shortcut in system preferences, but nothing happened when press Ctrl-Space in vscode 😖
help please.
MSBuild project tools v0.4.1
Version: 1.63.0
Commit: 7db1a2b88f7557e0a43fec75b6ba7e50b3e9f77e
Date: 2021-12-07T05:15:48.091Z
Electron: 13.5.2
Chromium: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Darwin x64 21.1.0
dotnet --info
.NET SDK (反映任何 global.json):
Version: 6.0.100
Commit: 9e8b04bbff
运行时环境:
OS Name: Mac OS X
OS Version: 12.0
OS Platform: Darwin
RID: osx-x64
Base Path: /usr/local/share/dotnet/sdk/6.0.100/
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
.NET SDKs installed:
3.1.415 [/usr/local/share/dotnet/sdk]
5.0.401 [/usr/local/share/dotnet/sdk]
6.0.100 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.21 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.21 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Hi. I don't have a Mac (so I cannot verify this), but these steps might help?
https://github.com/microsoft/vscode/issues/103855#issuecomment-671062294
@tintoy thanks for so quick help.
In vscode, option + esc also trigger suggest, I tried it in 'Include' and 'Version'
Did I miss something ?
[Error - 11:36:49 AM] Failed to provide completions.
System.ArgumentNullException: Value cannot be null. (Parameter 'cacheContext')
at HttpSourceCacheContext NuGet.Protocol.Core.Types.HttpSourceCacheContext.Create(SourceCacheContext cacheContext, bool isFirstAttempt)
at async Task<IEnumerable<JObject>> NuGet.Protocol.RegistrationUtility.LoadRanges(HttpSource httpSource, Uri registrationUri, string packageId, VersionRange range, SourceCacheContext cacheContext, ILogger log, CancellationToken token)
at async Task<IEnumerable<JObject>> NuGet.Protocol.RegistrationResourceV3.GetPackageMetadata(string packageId, VersionRange range, bool includePrerelease, bool includeUnlisted, SourceCacheContext cacheContext, ILogger log, CancellationToken token)
at async Task<IEnumerable<JObject>> NuGet.Protocol.RegistrationResourceV3.GetPackageMetadata(string packageId, bool includePrerelease, bool includeUnlisted, SourceCacheContext cacheContext, ILogger log, CancellationToken token)
at async Task<IEnumerable<NuGetVersion>> NuGet.Protocol.AutoCompleteResourceV3.VersionStartsWith(string packageId, string versionPrefix, bool includePrerelease, SourceCacheContext sourceCacheContext, ILogger log, CancellationToken token)
at async Task<SortedSet<NuGetVersion>> MSBuildProjectTools.LanguageServer.Utilities.NuGetHelper.SuggestPackageVersions(IEnumerable<AutoCompleteResource> autoCompleteResources, string packageId, bool includePrerelease, string versionPrefix, ILogger logger, CancellationToken cancellationToken) in /Users/brook/projects/clean-architecture-dotnet/D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\NuGetHelper.cs:line 252
at async Task<SortedSet<NuGetVersion>> MSBuildProjectTools.LanguageServer.Documents.ProjectDocument.SuggestPackageVersions(string packageId, bool includePrerelease, CancellationToken cancellationToken) in /Users/brook/projects/clean-architecture-dotnet/D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Documents\ProjectDocument.cs:line 603
at async Task<List<CompletionItem>> MSBuildProjectTools.LanguageServer.CompletionProviders.PackageReferenceCompletion.HandlePackageReferenceAttributeCompletion(ProjectDocument projectDocument, XSAttribute attribute, CancellationToken cancellationToken) in /Users/brook/projects/clean-architecture-dotnet/D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\PackageReferenceCompletion.cs:line 194
at async Task<CompletionList> MSBuildProjectTools.LanguageServer.CompletionProviders.PackageReferenceCompletion.ProvideCompletions(XmlLocation location, ProjectDocument projectDocument, string triggerCharacters, CancellationToken cancellationToken) in /Users/brook/projects/clean-architecture-dotnet/D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\CompletionProviders\PackageReferenceCompletion.cs:line 95
at async Task<CompletionList> MSBuildProjectTools.LanguageServer.Handlers.CompletionHandler.OnCompletion(CompletionParams parameters, CancellationToken cancellationToken) in /Users/brook/projects/clean-architecture-dotnet/D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Engine\Handlers\CompletionHandler.cs:line 202
Hmm, that was fixed in v0.4.3 (https://github.com/tintoy/msbuild-project-tools-vscode/issues/91), but for some reason the publish to the VS gallery did not succeed.
I've just re-published it, but it usually takes 10-15 minutes to become available for installation.
Ok, it's published - can you try updating the extension and trying again?
It works ! Thank you so much, I spent many days trying to figure this out 👍
Good to hear - sorry for the trouble :)
I'm obviously missing something obvious but I cannot get Nuget package autocomplete to work at all. I've tried on Windows, Mac and Linux all seem to give the same output in debug mode.
(even tried fresh install inside VM's with just this extension and C# extension same thing)
Debug output: (note it seems to be looking for suggestions for Newtonsoft.Json but that's not even in the csproj package list.