visual-studio-code.net-coreomnisharp

VS Code Omnisharp intellisense does not work


I have the following setup:

Recently, I started a new .NET Core 6 api project. The problem I am having is that VS Code does not offer any intellisense nor it recognizes any classes when I try to go to their definition. If I press F12 I get "No definition found for..." even though the class is defined in the same .CS file.

The only big change to my environment I introduced recently is that I added Docker for Windows to my machine and added the Docker VS Code extension. I tried removing the extension, but that did not help.

Any ideas on how to resolve this issue?

EDIT: I am also having the same issue in Visual Studio 2022 Enterprise. So, I am wondering if this is a .NET Core 6 issue, not specific to VS or VS Code.

EDIT 2: As it turns out VS 2022 works, but only if I open the project as part of the solution, not by just opening the folder.


Solution

  • So, in VS Code, I was opening a folder that had a lot of legacy projects. When I opened the folder with the .NET Core 6 solution directly, I got the intellisense and Go To Definition working. I guess OmniSharp was getting confused because of the multiple legacy projects.

    Not sure what the exact reason is, but if you are facing the same situation, just open the new project's folder directly and everything should work.