How to remove or turn off Roslyn Analyzer in VS Code? – Roslyn

by
Ali Hasan
roslyn roslyn-code-analysis visual-studio-code

Quick Fix: Utilize the ‘omnisharp.enableRoslynAnalyzers’ setting. Alternatively, revert to OmniSharp for IntelliSense by setting ‘dotnet.server.useOmnisharp’ to ‘true’. For disabling specific warnings, modify the editorconfig file with severity preferences or try hiding squiggly underlines.

The Problem:

How do I disable or remove the Roslyn Analyzer in Visual Studio Code? The Roslyn Analyzer is highlighting non-error codes in blue lines and sometimes translucent some variables unnecessarily. This recent update in VS Code is bothering me, and I’ve tried searching for solutions online, but most of the results are for Visual Studio, not VS Code.

The Solutions:

Solution 1: Disable Roslyn Analyzer using `omnisharp.enableRoslynAnalyzers` setting

If you want to turn off the Roslyn Analyzer in VS Code, you can use the `omnisharp.enableRoslynAnalyzers` setting. To do this:

  1. Open your VS Code settings (Ctrl+,)
  2. Search for omnisharp.enableRoslynAnalyzers
  3. Set the value to false

This will disable the Roslyn Analyzer and remove the blue lines and translucent variables from your code.


Solution 2: Switch back to OmniSharp for IntelliSense

If you want to switch back to using OmniSharp for IntelliSense, you can set the `dotnet.server.useOmnisharp` setting to `true`. To do this:

  1. Open your VS Code settings (Ctrl+,)
  2. Search for dotnet.server.useOmnisharp
  3. Set the value to true

This will disable the Roslyn Analyzer and switch back to using OmniSharp for IntelliSense.


Solution 3: Disable warning/hint diagnostics using editorconfig (if supported)

If you want to disable warning/hint diagnostics, you can use an editorconfig file to do so. To do this, create a `.editorconfig` file in your project directory and add the following lines:

[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-Style.severity = none
dotnet_analyzer_diagnostic.category-CodeQuality.severity = none

This will disable the warning/hint diagnostics for style and code quality.


Solution 4: Hide squiggly underlines

If you just want to hide the squiggly underlines, you can use the following CSS snippet in your user settings:

{
  "workbench.colorCustomizations": {
    "editorError.foreground": "#00000000"
  }
}

This will hide the squiggly underlines without disabling the Roslyn Analyzer.

Solution 2: Update VS Code Extension

If you are facing unexpected blue squiggles or translucent variables in VS Code, it may be due to a bug in the VS Code extension. To resolve this issue, make sure you are using the latest version of the extension.

  1. Open VS Code.
  2. Click on the Extensions icon in the Activity Bar (or press Ctrl+Shift+X).
  3. Search for the Roslyn Analyzer extension.
  4. Click on the "Update" button if an update is available.
  5. Restart VS Code.

By updating the extension, you will get the latest bug fixes and improvements, which should resolve the issue of unexpected blue squiggles and translucent variables.

Solution 3: Disable Roslyn Analyzers, Reactivate Omnisharp, and Remove/Disable Extension

  1. Disable Roslyn Analyzers:

    • In Visual Studio Code, navigate to the settings.
    • Use the search bar to find the setting "Enable Roslyn analyzers."
    • Disable this setting.
  2. Reactivate Omnisharp Language Server:

    • In the settings, search for "dotnet.server.Use Omnisharp."
    • Enable this setting.
  3. Remove or Disable Extension:

    • Remove or disable the extension "C# Dev Kit." This extension is known to cause issues with Roslyn Analyzers.
  4. Restart Visual Studio Code:

    • Restart Visual Studio Code to apply the changes.

Note: If Omnisharp is removed, it will be automatically re-downloaded and installed when you reactivate it in the settings.

By following these steps, you can disable Roslyn Analyzers, reactivate the Omnisharp language server, and remove or disable the conflicting extension. This should resolve the highlighting and translucency issues caused by Roslyn Analyzers.

Q&A

How to turn off blue line analyzer in VS Code?

Set omnisharp.enableRoslynAnalyzers or dotnet.server.useOmnisharp to true.

How to disable warning/hint diagnostics?

Add dotnet_analyzer_diagnostic.category-[warning].severity = none to an editorconfig.

How to hide squiggly lines in VS Code?

Disable Roslyn and re-enable Omnisharp in settings.

Video Explanation:

The following video, titled "How to remove or turn off Roslyn Analyzer in VS Code? - YouTube", provides additional insights and in-depth exploration related to the topics discussed in this post.

Play video

How to remove or turn off Roslyn Analyzer in VS Code? I hope you found a solution that worked for you 🙂 The Content (except music & images) ...