OmniSharp intellisense not recognizing new class file

Viewed 8355

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!

3 Answers

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.

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.

Steps to follow to make it work:

  1. Find Assembly-CSharp.csproj.
  2. Find the field under which your old script names are present for compilation.
  3. Add the new script name.
  4. Save in Unity. Restart VS Code if required.

It should get solved.

Related