Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OmniSharp intellisense not recognizing new class file

I have a dotnet core console app I generated from the cli via

dotnet new console -n EODG.VsCodeTester.Cli

Using the C# Extensions extension, I right click on the project folder in VSCode, and click "New C# Class".

The class/file opens just fine, but Omnisharp doesn't appear to recognize the file/class. From Program.cs, the class doesn't show up in the code completion, and the codelens in the new class doesn't show up.

The following is outputted from the OmniSharp log...

[info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
        Could not find document for file c:\Users\elrod\src\test\src\EODG.VsCodeTester.Cli\Cat.cs

Now, if I restart OmniSharp, it recognizes the new file just fine... but it's kind of a pain to restart omnisharp everytime I make a new class/interface or rename them. I've never seen this before, and I've been doing dotnet core development in vscode since v1.

I tried googling OmniSharp "Could not find document for file"... and it said No results found for OmniSharp "Could not find document for file".... so, that's nice.

Pertinent Details

  • OS: Windows 10 (fresh install... like less than 2 hours old)
  • VSCode version: 1.50.1
  • OmniSharp version: 1.23.5
  • Dotnet version: 3.1.403

I will be more than happy to provide any other details I can.

Thanks, y'all!

like image 641
J From The Sticks Avatar asked Nov 05 '20 00:11

J From The Sticks


People also ask

Why is Vscode IntelliSense not working?

If IntelliSense is not working as it should on your Windows 11/10 PC, you can try restarting VS Code and this should solve the issue. Restarting the program can be really effective and time saving in some cases. If the issue persists, you can try restarting your computer altogether.

What is OmniSharp in Vscode?

OmniSharp is a set of tooling, editor integrations and libraries that together create an ecosystem that allows you to have a great programming experience no matter what your editor and operating system of choice may be.


2 Answers

What worked for me on my mac, was that in settings, search for omnisharp, then look for the option that says Omnisharp: Use Global Mono and set it to always.

like image 128
Dreambox077 Avatar answered Oct 18 '22 14:10

Dreambox077


It looks like OmniSharp version 1.23.5 might be busted... I reverted to version 1.23.3, and things work as expected now. Possibly related to this issue on their git repo.

UPDATE: updating to v1.23.6 resolves this issue.

like image 20
J From The Sticks Avatar answered Oct 18 '22 16:10

J From The Sticks