question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Setting `csharp.semanticHighlighting.enabled` to true breaks syntax highlighting for base classes and attributes

See original GitHub issue

Issue Description

Setting csharp.semanticHighlighting.enabled to true breaks syntax highlighting for base classes and attributes. This causes it to show up as a class definition, when in many themes it should have its own distinct color. Issue was tested on both the stable and insiders versions of vscode, log submitted is from insiders build.

Setting csharp.semanticHighlighting.enabled to false fixes the issue regarding base classes and attributes, but it also removes functionality such as highlighting for parameters which I prefer to be on.

Issue does not occur instantly when starting VSCode, I can’t get an exact timeframe but it seems to be linked to the analyzers loading.

Steps to Reproduce

  • Launch VSCode
  • Open .cs file
  • Wait for analyzers to start
  • Observe colour change for baseclasses and attribute to styling of regular classes.

See screenshots below

Expected Behavior

Screenshots retrieved by setting csharp.semanticHighlighting.enabled to false

Monokai theme image

Github dark theme image

Actual Behavior

csharp.semanticHighlighting.enabled to true

Monokai theme image

Github dark theme image

Logs

OmniSharp log

Starting OmniSharp server at 21/01/2022, 15:33:32 Target: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.sln

OmniSharp server started. Path: c:\Users\wrlxs.vscode-insiders\extensions\ms-dotnettools.csharp-1.24.0.omnisharp\1.38.0\OmniSharp.exe PID: 1788

    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    Using the 'dotnet' on the PATH.
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 17.0.0 - "c:\Users\wrlxs\.vscode-insiders\extensions\ms-dotnettools.csharp-1.24.0\.omnisharp\1.38.0\.msbuild\Current\Bin"
    MSBUILD_EXE_PATH environment variable set to 'c:\Users\wrlxs\.vscode-insiders\extensions\ms-dotnettools.csharp-1.24.0\.omnisharp\1.38.0\.msbuild\Current\Bin\MSBuild.exe'
    Registered MSBuild instance: StandAlone 17.0.0 - "c:\Users\wrlxs\.vscode-insiders\extensions\ms-dotnettools.csharp-1.24.0\.omnisharp\1.38.0\.msbuild\Current\Bin"
        CscToolExe = csc.exe
        CscToolPath = c:\Users\wrlxs\.vscode-insiders\extensions\ms-dotnettools.csharp-1.24.0\.omnisharp\1.38.0\.msbuild\Current\Bin\Roslyn
        MSBuildExtensionsPath = c:\Users\wrlxs\.vscode-insiders\extensions\ms-dotnettools.csharp-1.24.0\.omnisharp\1.38.0\.msbuild
        MSBuildToolsPath = c:\Users\wrlxs\.vscode-insiders\extensions\ms-dotnettools.csharp-1.24.0\.omnisharp\1.38.0\.msbuild\Current\Bin
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
    Detecting Cake files in 'c:\Users\wrlxs\source\repos\sero-quattuor'.
    Did not find any Cake files
    Detecting projects in 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.sln'.
    Queue project update for 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.api\sero-quattuor.api.csproj'
    Queue project update for 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.business\sero-quattuor.business.csproj'
    Queue project update for 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.sockets\sero-quattuor.sockets.csproj'
    Detecting CSX files in 'c:\Users\wrlxs\source\repos\sero-quattuor'.
    Did not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'c:\Users\wrlxs\source\repos\sero-quattuor' on host 10112.
    Loading project: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.api\sero-quattuor.api.csproj
    Successfully loaded project file 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.api\sero-quattuor.api.csproj'.
    Adding project 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.api\sero-quattuor.api.csproj'
    Loading project: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.business\sero-quattuor.business.csproj
    Successfully loaded project file 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.business\sero-quattuor.business.csproj'.
    Adding project 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.business\sero-quattuor.business.csproj'
    Loading project: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.sockets\sero-quattuor.sockets.csproj
    Successfully loaded project file 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.sockets\sero-quattuor.sockets.csproj'.
    Adding project 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.sockets\sero-quattuor.sockets.csproj'
    Update project: sero-quattuor.api
    Found referenced project outside root directory: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.core\sero-quattuor.core.csproj
    Adding project 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.core\sero-quattuor.core.csproj'
    Queue project update for 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.core\sero-quattuor.core.csproj'
    Found referenced project outside root directory: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.data\sero-quattuor.data.csproj
    Adding project 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.data\sero-quattuor.data.csproj'
    Queue project update for 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.data\sero-quattuor.data.csproj'
    Update project: sero-quattuor.business
    Update project: sero-quattuor.sockets
    Loading project: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.core\sero-quattuor.core.csproj
    Successfully loaded project file 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.core\sero-quattuor.core.csproj'.
    Loading project: c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.data\sero-quattuor.data.csproj
    Successfully loaded project file 'c:\Users\wrlxs\source\repos\sero-quattuor\sero-quattuor.data\sero-quattuor.data.csproj'.
    Update project: sero-quattuor.core
    Adding analyzer reference: C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\analyzers\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll
    Adding analyzer reference: C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll
    Adding analyzer reference: C:\Users\wrlxs\.nuget\packages\microsoft.entityframeworkcore.analyzers\5.0.11\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll
    Adding analyzer reference: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.1\analyzers\dotnet\cs\System.Text.Json.SourceGeneration.dll
    Update project: sero-quattuor.data
    Adding analyzer reference: C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\analyzers\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll
    Adding analyzer reference: C:\Program Files\dotnet\sdk\6.0.101\Sdks\Microsoft.NET.Sdk\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll
    Adding analyzer reference: C:\Users\wrlxs\.nuget\packages\microsoft.entityframeworkcore.analyzers\6.0.1\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll
    Adding analyzer reference: C:\Users\wrlxs\.nuget\packages\microsoft.extensions.logging.abstractions\6.0.0\analyzers\dotnet\roslyn4.0\cs\Microsoft.Extensions.Logging.Generators.dll
    Adding analyzer reference: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\6.0.1\analyzers\dotnet\cs\System.Text.Json.SourceGeneration.dll

Received response for /v2/getcodeactions but could not find request. Received response for /completion but could not find request.

C# log

Installing C# dependencies... Platform: win32, x86_64

Finished

Environment information

VSCode version: 1.64.0-insider C# Extension: 1.24.0

Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.101 Commit: ef49f6213a

Runtime Environment: OS Name: Windows OS Version: 10.0.22000 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\6.0.101\

Host (useful for support): Version: 6.0.1 Commit: 3a25a7f1cc

.NET SDKs installed: 6.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
csharp ms-dotnettools 1.24.0
github-vscode-theme GitHub 5.1.0

Code

using Microsoft.AspNetCore.Mvc;

namespace sero_quattuor.api.Controllers;

[ApiController]
[Route("token")]
public class TokenController : ControllerBase
{

}

Csproj

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <IsPackable>false</IsPackable>
    <RootNamespace>sero_quattuor.api</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="6.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="3.1.4" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1" />
  </ItemGroup>
</Project>

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
greghardingcommented, Mar 6, 2022

I just hit this issue when updating to 1.24 - nearly every word in C# files is either underlined or a different colour.

Like others above, I disabled “csharp.enableSemanticHighlighting” in both workspace and user to clean things up again. Also, the settings in VSCode say “Defaults to false” but both of these settings seem to default to true, and setting them to false highlights blue as a changed setting. I had to set both workspace and user settings to false to return to sanity.

Update: Omnisharp 1.24.1 is back to underlining classes, attributes, etc. that is really cluttering things up when using the Monokai theme. Is there any way to disable the constant underlining everywhere or is this entirely theme related?

I have edited my settings.json to include “editor.tokenColorCustomizations” scoped to the [Monokai] theme to declutter things. If anyone else is interested here’s a snippet to remove underlines for types (classes, attributes);

"editor.tokenColorCustomizations": { "[Monokai]": { "textMateRules": [ { "name": "Remove type underline", "scope": "entity.name.type", "settings": { "fontStyle": "" } } ] }, }

2reactions
snax4acommented, Feb 2, 2022

Im having same issue, it was working in previous versions. I would prefer not to disable semantic highlighting

Read more comments on GitHub >

github_iconTop Results From Across the Web

Semantic highlighting in OmniSharp and C# extension for VS ...
semanticHighlighting.enabled controls enabling the semantic highlighting API in VS Code altogether, and defaults to true, however I wanted ...
Read more >
Semantic Highlight Guide | Visual Studio Code Extension API
Semantic highlighting is an addition to syntax highlighting as described in the Syntax Highlight guide. Visual Studio Code uses TextMate grammars as the ......
Read more >
Syntax Highlighting isn't working correctly for c# 10.0 in vscode
To fix the issue, add these settings to the Settings JSON: "editor.semanticHighlighting.enabled": true, "csharp.
Read more >
Syntax - Neovim docs
Syntax highlighting enables Vim to show parts of the text in another font or ... break text alignment and indentation in the HTML,...
Read more >
A case against syntax highlighting - Linus Åkesson
This means that you read mainly black, non-highlighted code, and occasionally your eyes fixates on a variable or class name. In this case...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found