VSCode 中的 OmniSharp 非常慢

twe*_*ypi 8 c# omnisharp visual-studio-code

我不确定发生了什么,但突然之间 OmniSharp 在 VSCode 中变得非常慢。

有时自动完成会立即生效,有时需要几分钟,跳转到定义等也是如此。

如果我为局部变量禁用 OmniSharp 自动完成再次加速,有时 OmniSharp 会给我一个函数列表,这些函数将完成我正在输入的内容,但不会自动选择我写了一半的那个。

有没有办法调试这个并确定原因?

Mel*_*igy 3

如果您的问题是关于确定原因,请尝试检查输出窗口中的“Omnisharp Logs”:

在此输入图像描述

在那里看到一些警告甚至错误是正常的,但不应该太多。

您还可以尝试提高日志级别以查看更多信息。


如果您想暂时缓解一下,还可以尝试以下设置:

    "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
Run Code Online (Sandbox Code Playgroud)