Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# intellisense not working in VS Code

I am using Visual Studio Code and I have already loaded C# OMNISharp plugin to my system and it works all fine in my existing project/solutions.

However, I just created a new solution and a new project in Visual Studio code and it sounds like for this particular solution, the Intellisense or any other Omnisharp features are just not working. I have tried following things:

  • Restarting Visual Studio Code
  • Disabling and enabling my OmniSharp Plug-in

Also, one thing that I noticed is that when a solution is created in Visual studio, it has a lot of code which looks like following:

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AEA16303-6991-4FF1-A3A9-72D892D7968C}"
EndProject

Basically, these are all project references. However, when a solution is created by Visual Studio Code then there is not any section like that. This solution runs and compiles fine, just that it looks fundamentally different than how a Visual Studio solution looks like.

However, nothing seems to be working. Is there anything that I can try to make it work? Any ideas ?

like image 955
Lost Avatar asked Jan 03 '18 01:01

Lost


4 Answers

It's caused by adding *.sln and *.csproj to your "files.exclude" setting.

Try this:

Code -> Preferences -> Settings -> "omnisharp.useMono": true/false

Remove from setting file.

Or, Open your project with MonoDevelop or Visual Studio 2015/2017 first, then reopen VS-Code.


Edit 1: Try setting "omnisharp.useGlobalMono": never and then restarting the omnisharp server. Credit: The_Wolf and kao peter

like image 135
stefan Avatar answered Oct 06 '22 09:10

stefan


This worked for me

"omnisharp.useGlobalMono": "never"
like image 36
Jon Martins Avatar answered Oct 06 '22 09:10

Jon Martins


In my case, after installing C# extension, I had to click the setting icon on the extension and then click "Add to workspace recormendations"

like image 35
Olawale david Avatar answered Oct 06 '22 09:10

Olawale david


How did you created the project? For the Intellisense to work properly the project needs to have a specific structure.

Assuming you have the .net core sdk for mac and the omnisharp extension installed:

Try the following:

  1. Open your integrated terminal (View => Integrated terminal)
  2. Create some new directory to host a test project say "testproj" e.g => mkdir testproj

  3. use the dotnet cli to initialize the project => dotnet new console

See if you got intellisense.
Also i'd recommend watching the .net core on Mac introduction video.

like image 21
igorc Avatar answered Oct 06 '22 09:10

igorc