Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Intellisense stopped to work on C# files

I realized that I can't use ctrl + . shortcut to import other C# classes. This shortcut works just fine for other file types like typescript.

I have uninstalled and installed back again. I also installed old version of VS code too. But nothing worked.

enter image description here As I shown above, there is no import feature shows up when I do ctrl + .. Those are only the choices I was given. It's fine using without it but it's also annoying to import those files manually typed.

like image 799
GoGo Avatar asked Jan 30 '18 17:01

GoGo


People also ask

Why C is not working in VS Code?

You have to change it so it runs in the terminal. Go to the menu Code > Preferences > Settings. In the User tab on the left panel, expand the Extensions section. Find and select Run Code Configuration.

How do I get C to work on VS Code?

1. We need to click on the extension button that displays a sidebar for downloading and installing the C/C++ extension in the visual studio code. In the sidebar, type C Extension. In this image, click on the Install button to install the C/C++ extension.

How do I restart IntelliSense Visual Studio?

For Visual Studio 2017 (and I think Visual Studio 2019 also), close Visual Studio, go into the . vs folder in your projects folder and delete all the contents apart from the . suo file, then reopen Visual Studio. This way you can rebuild the Intellisense cache without losing your preferences.


2 Answers

The C# language features in VS Code are provided by a service called OmniSharp .

A couple of things you could try:

A) Restart OmniSharp

  1. Open the Command Palette (Ctrl + Shift + P)
  2. Type Omnisharp: Restart OmniSharp

    Command Palette > OmniSharp

B) View OmniSharp Logs

  1. Open Output Panel (Ctrl + ')
  2. Select OmniSharp Log from the dropdown)

    Output Panel > OmniSharp

C) Enable OmniSharp Logging

  1. Enabling C# debugger logging in Omnisharp

    "configurations": [
        {
            "...": "...",
            "logging": {
                "engineLogging": true
            }
        },
        { "...": "..." }
    ]
    
like image 127
Stewart_R Avatar answered Oct 02 '22 05:10

Stewart_R


Something that solved it in my case was, in Unity, to set the Edit -> Project Settings -> Player -> Other Settings -> Api Compatibility Level to .NET 4.x.

Probably not appropriate in some cases, and indiciative of another issue in my Omnisharp/ VS Code setup, but just in case it helps someone.

like image 32
Philipp Lenssen Avatar answered Oct 02 '22 03:10

Philipp Lenssen