Skip to content
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

Intellisense not working at all #3286

Closed
JAMJAR64 opened this issue Sep 22, 2019 · 12 comments
Closed

Intellisense not working at all #3286

JAMJAR64 opened this issue Sep 22, 2019 · 12 comments

Comments

@JAMJAR64
Copy link

Issue Description

Intellisense does not work at all. It has not worked since I downloaded Visual Studio Code.

Steps to Reproduce

Downloaded Unity, Downloaded Visual Studio Code, Installed C# Extension and recommended .NET SDK, Intellisense not working.

Expected Behavior

Expected underlines, suggestions, etc. All features of Intellisense.

Actual Behavior

Some suggestions, no descriptions, no underlines. Visual Studio is basically unusable.

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.38.1
C# Extension: 1.21.3

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 2.2.402 Commit: c7f2f96116

Runtime Environment:
OS Name: Windows
OS Version: 10.0.18362
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\2.2.402\

Host (useful for support):
Version: 2.2.7
Commit: b1e29ae826

.NET Core SDKs installed:
2.2.402 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.2.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
csharp ms-vscode 1.21.3
@maharielrosario
Copy link

maharielrosario commented Sep 26, 2019

I am not getting Intellisense or syntax highlighting as well. I have C# extension version 1.21.3, and .NET Core SDK version 3.0.100.

VSCode Info:

Version: 1.38.1 (user setup)
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:35:15.005Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Windows_NT x64 10.0.18362

@danechambers
Copy link

danechambers commented Sep 29, 2019

@mrosari0 Since you're on windows, you can use a small workaround. You can follow the directions from here: #3289 (comment)
You can confirm its using the new ms build directory by looking at the omnisharp log (with debug on) and looking for this entry:

[dbug]: OmniSharp.MSBuild.ProjectSystem
        MSBuild environment: 
Mode: VisualStudio
RunningTests: False
RunningInVisualStudio: False
MSBuildToolsDirectory32: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
MSBuildToolsDirectory64: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\amd64
MSBuildSDKsPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Sdks
CurrentMSBuildConfigurationFile: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe.config
CurrentMSBuildExePath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe
CurrentMSBuildToolsDirectory: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
VisualStudioInstallRootDirectory: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
MSBuildExtensionsPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild

It should be using msbuild from the new build tools you just installed rather than the one shipping with omnisharp.

I think the problem is basically this #3290
Hopefully fixed for windows with OmniSharp/omnisharp-roslyn#1606
Linux and mac can try installing mono 6 or newer per this comment #3290 (comment)

Edit:
@filipw thanks for the clarification! I've updated my comment to better reflect the facts. My apologies for the initial misinformed linking.

@filipw
Copy link
Contributor

filipw commented Sep 29, 2019

The reason for this workaround is apparently this: #3287 (comment)

The linked comment is not correct. OmniSharp ships with MSBuild 16 since April (OmniSharp/omnisharp-roslyn#1444) - that's why .NET Core 3.0 previews worked with OmniSharp before. It's just MSBuild 16 has assembly version 15.x which is why it shows up in the paths in a misleading way, with 15. There are several other issues that cause certain problems though - especially with .NET Core 3.0 RTM.

If you install VS 2019 or VS 2019 Build Tools (or Mono 6+ on *nix), OmniSharp will automatically pick it up instead of the embedded MSBuild and use that for language services - there should be no need to export any additional variables. It has always worked like that (for all VS versions) and it's the safest bet to resolve any issues.

For the embedded runtime - without VS/VS Build Tools/Mono - at the moment the best workaround would be to try #3290 (comment) or #3290 (comment). The latter will always be better though as the support in the built-in MSBuild in VS2019 / Mono will be always better than in the built in instance running on embedded Mono.

Hope this clarifies this a bit.

@maharielrosario
Copy link

@mrosari0 Since you're on windows, you can use a small workaround. You can follow the directions from here: #3289 (comment)
You can confirm its using the new ms build directory by looking at the omnisharp log (with debug on) and looking for this entry:

[dbug]: OmniSharp.MSBuild.ProjectSystem
        MSBuild environment: 
Mode: VisualStudio
RunningTests: False
RunningInVisualStudio: False
MSBuildToolsDirectory32: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
MSBuildToolsDirectory64: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\amd64
MSBuildSDKsPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Sdks
CurrentMSBuildConfigurationFile: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe.config
CurrentMSBuildExePath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe
CurrentMSBuildToolsDirectory: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin
VisualStudioInstallRootDirectory: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
MSBuildExtensionsPath: C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild

It should be using msbuild from the new build tools you just installed rather than the one shipping with omnisharp.

I think the problem is basically this #3290
Hopefully fixed for windows with OmniSharp/omnisharp-roslyn#1606
Linux and mac can try installing mono 6 or newer per this comment #3290 (comment)

Edit:
@filipw thanks for the clarification! I've updated my comment to better reflect the facts. My apologies for the initial misinformed linking.

If you install VS 2019 or VS 2019 Build Tools (or Mono 6+ on *nix), OmniSharp will automatically pick it up instead of the embedded MSBuild and use that for language services - there should be no need to export any additional variables. It has always worked like that (for all VS versions) and it's the safest bet to resolve any issues.

I actually have VS Enterprise 2019 installed so it sounds like I don't need to pick up the build tools.

This is what's showing in my OmniSharp Log. I have debugging on but didn't get the output you had referenced. Would these lines work as confirmation?

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 2 MSBuild instance(s) 1: Visual Studio Enterprise 2019 16.3.29326.143 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin" 2: StandAlone 16.0 - "C:\Users\my_username\.vscode\extensions\ms-vscode.csharp-1.21.3\.omnisharp\1.34.4-beta.7\.msbuild\Current\Bin"

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: Visual Studio Enterprise 2019 16.3.29326.143 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"

@mwd1234
Copy link

mwd1234 commented Apr 9, 2020

I followed the tutorial from Microsoft for VS Code with Unity and it seemed to finally do the trick... https://code.visualstudio.com/docs/other/unity

Steps I took:

  1. Installed https://dotnet.microsoft.com/download
  2. Installed https://www.mono-project.com/download/stable/
  3. Installed C# extension in VS Code.
  4. Unity > Preferences (cmd + , on Mac) > External Tools (left toolbar) > External Script Editor > Visual Studio Code.
  5. Then this is the trick I found to work after doing all of this... I open up VS Code prior to starting my Unity Project and manually go into the Unity Project folder and open up everything in VS Code FIRST. Then, with that project already open and working in VS Code with Intellisense, I double click the script in Unity and it will open it up in the already opened VS Code editor and have Intellisense already working! Do my normal workflow for the day and close everything down... then when I start up the next time, just be sure to open the project in VS Code FIRST and then VS Code will recognize it's a C# project and initiate Intellisense and all that jazz.

Hope this helps!

@mvarga6
Copy link

mvarga6 commented Apr 25, 2020

I've run into this before. In my case, it was simply because the project was not added to the solution in the directory root. Appears that OmniSharp looks in there to determine which projects to provide intellisense for.

@JoeRobich
Copy link
Member

One thing to be aware of when working with C# scripts in Unity is that you don't want to double click the script from Unity to open it. When this happens, only the file is opened which doesn't pull in the Project references and other information needed to provide intellisense and analysis. It is better to use Assets -> Open C# Project, since that will open the full project in VS Code.

@cartermp
Copy link

@JAMJAR64 does this still reproduce for you? How did you open the C# file, as @JoeRobich describes?

@paulusuluap
Copy link

Bro, i have the answer for you. the solution is super SIMPLE you just have to make sure that you already downloaded these tools :

  • Unity Code Snippets by Kleber Silva
  • Debugger for Unity by Unity Technologies
  • Unity Tools by Tobiah Zarlez

which you can find them all on VSCode, after installing it, close the VSCode and reopen. That's all of it.

I've been strolling to any possible solutions I could find for the same problems as yours, but the answer is just as away as your right-hand to your mouse.

@derwaldgeist
Copy link

@paulusuluap Bro, I have installed these tools for ages, but still it won't work in Unity 2020.

@derwaldgeist
Copy link

Update: I found a workaround on the Unity forum that actually worked:

https://forum.unity.com/threads/intellisense-not-working-for-visual-studio-code.812040/#post-5858986

I have no idea why it helped, because I was already running a blank Unity project and Unity should have set everything up already. But it worked.

@cartermp
Copy link

Closing out as there was no repro given.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants