14

I'm not sure what happened but all of a sudden OmniSharp has become very slow in VSCode.

Sometimes the autocomplete works immediately sometimes it takes minutes, same for jumping to definitions and the like.

If I disable OmniSharp autocomplete speeds up again for local variables, on occasion OmniSharp gives me a list of functions which will complete what I'm typing but doesn't autoselect the one I've half written.

Is there a way to debug this and identify the cause?

meds
  • 21,699
  • 37
  • 163
  • 314

2 Answers2

3

If your question is about identifying the reason, try to check the "Omnisharp Logs" in the Outuput window:

enter image description here

It's normal to see some warnings and even errors in there, but there shouldn't be too many.

You can also try to increase the log level to see more info.


If you want some temporary relieves, you can also try the following settings:

    "omnisharp.analyzeOpenDocumentsOnly": true,
    // Flip this on/off and feel the difference
    "omnisharp.enableAsyncCompletion": false,
    // Flip this on/off and feel the difference
    "omnisharp.enableMsBuildLoadProjectsOnDemand": false,
    // Maybe more cost up front helps later
    "omnisharp.projectLoadTimeout": 300,
    // Only if using .NET6+, 
    // If not, read about the setting, or make sure you set it to false
    "omnisharp.useModernNet": true,
    // This slows down start normally, 
    // but see if it makes a difference after that
    "omnisharp.path": "latest",
    // Only set this to false to experiment
    // If it improves things, then some analyzer NuGet is the cause
    "omnisharp.enableRoslynAnalyzers": false,
    // Also check "omnisharp." and "csharp." settings for any
    // setting that has the word "suppress" and remove them
    // so you can see all errors and warnings from omnisharp
Meligy
  • 35,654
  • 11
  • 85
  • 109
1

I think i have found the root of all problems. after disabling and enabling extensions, that i did not use, and notice that none of them were the problem... the problem it self is omnisharp when you enable auto imports... so

Disable auto import in c# extension

  • bottom left gear icon -> Settings -> Extensions-> right click c# extension -> extension settings

  • in the settings search bar you will get something like this

@ext:ms-dotnettools.csharp

next add @ext:ms-dotnettools.csharp import to the search bar

disable "Omnisharp: Enable Import Completion" option check box.

  • 1
    https://meta.stackoverflow.com/a/285557/11107541, https://code.visualstudio.com/docs/getstarted/settings#_settingsjson – starball May 10 '23 at 08:26