dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.87k stars 675 forks source link

Autocompletion, Method reference does not work after update from v1.26 to latest (v2.0.436) #6267

Closed darkcompet closed 7 months ago

darkcompet commented 1 year ago

Environment data

dotnet --info output: .NET SDK: Version: 7.0.100 Commit: e12b7af219

Runtime environment: OS Name: Mac OS X OS Version: 13.4 OS Platform: Darwin RID: osx.13-arm64 Base Path: /usr/local/share/dotnet/sdk/7.0.100/

Host: Version: 7.0.0 Architecture: arm64 Commit: d099f075e4

.NET SDKs installed: 7.0.100 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found: x64 [/usr/local/share/dotnet/x64] registered at [/etc/dotnet/install_location_x64]

Environment variables: Not set

OmniSharp log

No icon of OmniSharp server at bottom bar, so nothing is displayed.

Steps to reproduce

  1. Use vscode to open ASP.NET core webapi project.
  2. Autocompletion does not work for at most of object in class. For eg,. type this.service. does not recommend anything.
  3. Click to some method in a class also does not give any hint (includes reference of caller).

Expected behavior

Please make autocompletion and method reference work back. This is bug from v1.26.

dibarbet commented 1 year ago

@darkcompet Sounds like there was an issue loading the project - can you share the contents of the 'C#' output window? Preferrably with the dotnet.server.trace setting set to Trace. That should hopefully give us some more info on what is going wrong.

darkcompet commented 1 year ago

@dibarbet Thanks for your feeback !

After set dotnet.server.trace to Trace, it does not show anything at Output tab. This is new project that I created at this write this post, here is command to build the project.

dotnet new -o webapi test
image
amarraff commented 1 year ago

I am experiencing this on Windows 11. My method at its definition says "0 references" even though it is written in my other scripts and is functioning at runtime. I am using VS Code and the C# extension to work on a Unity Engine project with Unity version 2019.4.17f1.

dibarbet commented 1 year ago

@dibarbet Thanks for your feeback !

After set dotnet.server.trace to Trace, it does not show anything at Output tab. This is new project that I created at this write this post, here is command to build the project.

dotnet new -o webapi test

...

@darkcompet would you mind attaching the extension logs folder (as a .zip) here? You can find it from the following command: image

Seems like the extension might be failing to activate for some reason, the additional logs might give more clues.

joseeltonf commented 1 year ago

I have the same issue, I don't have method references, I don't have auto-complete, and when I build the application, it throws an error, but it's not indicated as usual.

image

dibarbet commented 1 year ago

I am experiencing this on Windows 11. My method at its definition says "0 references" even though it is written in my other scripts and is functioning at runtime. I am using VS Code and the C# extension to work on a Unity Engine project with Unity version 2019.4.17f1.

@amarraff there is a known issue with older unity projects in the new extension version. If you're able to upgrade the unity editor version and use the C# devkit extension, there is a new unity extension you can use. More details here - https://devblogs.microsoft.com/visualstudio/announcing-the-unity-extension-for-visual-studio-code/#getting-started-with-the-unity-extension

If you can't upgrade Unity and you're on Windows, you could try the prerelease version of the C# extension (2.2.10) which has limited support for the old style projects (Linux / Mac coming soon). See https://github.com/dotnet/vscode-csharp/discussions/6320

If neither of those work, you can switch back to the O# implementation by setting the dotnet.server.useOmnisharp vscode configuration.

If you're still having issues with any of those, please file a separate issue.

dibarbet commented 1 year ago

I have the same issue, I don't have method references, I don't have auto-complete, and when I build the application, it throws an error, but it's not indicated as usual.

image

@joseeltonf please attach the contents of the C# output window (preferably with dotnet.server.trace set to Trace). This problem generally means that the project failed to load for some reason. If the project fails to build that is a possible cause for the issue you are hitting.

amarraff commented 1 year ago

@dibarbet I did attempt installing the prerelease version before coming here, which didn't work. Enabling omnisharp in the C# extension settings appears to have fixed it, thank you so much!

joseeltonf commented 1 year ago

@dibarbet you're right, the failure occurred while loading the project, as shown in the output: image

as it was a program that had already been created in Visual Studio Code and then opened in Visual Studio, I believe there may have been some issues with project references. I used the 'dotnet sln add' CLI command to reestablish the references in the project.

With this, the error was fixed for me: image

If your output is returning 'found in workspace MiscellaneousFiles,' rearrange your project.

darkcompet commented 1 year ago

@dibarbet Thanks for your feeback ! After set dotnet.server.trace to Trace, it does not show anything at Output tab. This is new project that I created at this write this post, here is command to build the project.

dotnet new -o webapi test

...

@darkcompet would you mind attaching the extension logs folder (as a .zip) here? You can find it from the following command: image

Seems like the extension might be failing to activate for some reason, the additional logs might give more clues.

This is log after vscode get updated to 2.1.2. And nothing is displayed at Output tab.

image

20230913T230242.zip

ansariwn commented 1 year ago

Hello, I am facing the same issue. I am using VS Code version 1.82.2 (system setup), the C# extension version v2.1.2. Please see attached the C# trace log. vscodeErrorLog.txt

Thank you in advance.

dibarbet commented 7 months ago

Closing this issue - I believe we've since resolved the loading issues I've found in the attached logs. Please try out the latest version of the extensions - if you're still having problems file a new issue with the latest logs. Thanks!