dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.84k stars 661 forks source link

C# XML documentation domments don't get highlighted when semantic highlighter is enabled #3816

Open cschierig opened 4 years ago

cschierig commented 4 years ago

Issue Description

When the new semantic highlighter for C# is enabled, XML documentation comments aren't highlighted anymore. When semantic highlighting is turned off, it works just fine.

Steps to Reproduce

  1. Open up a C# file with XML documentation comments
  2. enable the semantic highlighter and restart the editor
  3. the XML documentation comments aren't highlighted anymore

Expected Behavior

XML tags in documentation comments should be highlighted

Actual Behavior

XML tags aren't highlighted when semantic highlighter is used.

Logs

OmniSharp log

Starting OmniSharp server at 30.5.2020, 16:38:43 Target: d:\Carl\source\repos\Penguor\PenguorCS\PenguorCS.sln OmniSharp server started. Path: c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.22.0\.omnisharp\1.35.2\OmniSharp.exe PID: 18592 [info]: OmniSharp.Stdio.Host Starting OmniSharp on Windows 6.2.9200.0 (x64) [info]: OmniSharp.Services.DotNetCliService DotNetPath set to dotnet [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Located 1 MSBuild instance(s) 1: StandAlone 16.4 - "c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.22.0\.omnisharp\1.35.2\.msbuild\Current\Bin" [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator MSBUILD_EXE_PATH environment variable set to 'c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.22.0\.omnisharp\1.35.2\.msbuild\Current\Bin\MSBuild.exe' [info]: OmniSharp.MSBuild.Discovery.MSBuildLocator Registered MSBuild instance: StandAlone 16.4 - "c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.22.0\.omnisharp\1.35.2\.msbuild\Current\Bin" CscToolExe = csc.exe CscToolPath = c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.22.0\.omnisharp\1.35.2\.msbuild\Current\Bin\Roslyn MSBuildExtensionsPath = c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.22.0\.omnisharp\1.35.2\.msbuild MSBuildToolsPath = c:\Users\\.vscode\extensions\ms-dotnettools.csharp-1.22.0\.omnisharp\1.35.2\.msbuild\Current\Bin [info]: OmniSharp.Cake.CakeProjectSystem Detecting Cake files in 'd:\Carl\source\repos\Penguor\PenguorCS'. [info]: OmniSharp.Cake.CakeProjectSystem Could not find any Cake files [info]: OmniSharp.MSBuild.ProjectSystem Detecting projects in 'd:\Carl\source\repos\Penguor\PenguorCS\PenguorCS.sln'. [info]: OmniSharp.MSBuild.ProjectManager Queue project update for 'd:\Carl\source\repos\Penguor\PenguorCS\Penguor\Penguor.csproj' [info]: OmniSharp.Script.ScriptProjectSystem Detecting CSX files in 'd:\Carl\source\repos\Penguor\PenguorCS'. [info]: OmniSharp.Script.ScriptProjectSystem Could not find any CSX files [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0 [info]: OmniSharp.MSBuild.ProjectManager Loading project: d:\Carl\source\repos\Penguor\PenguorCS\Penguor\Penguor.csproj [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110 [info]: OmniSharp.WorkspaceInitializer Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140 [info]: OmniSharp.WorkspaceInitializer Configuration finished. [info]: OmniSharp.Stdio.Host Omnisharp server running using Stdio at location 'd:\Carl\source\repos\Penguor\PenguorCS' on host 19604. [info]: OmniSharp.MSBuild.ProjectManager Successfully loaded project file 'd:\Carl\source\repos\Penguor\PenguorCS\Penguor\Penguor.csproj'. [info]: OmniSharp.MSBuild.ProjectManager Adding project 'd:\Carl\source\repos\Penguor\PenguorCS\Penguor\Penguor.csproj' [info]: OmniSharp.MSBuild.ProjectManager Update project: Penguor

C# log

empty

Environment information

VSCode version: 1.45.1 C# Extension: 1.22.0

Dotnet Information .NET Core SDK (gem�� "global.json"): Version: 3.1.300 Commit: b2475c1295 Laufzeitumgebung: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.300\ Host (useful for support): Version: 3.1.4 Commit: 0c2e69caa6 .NET Core SDKs installed: 3.1.100 [C:\Program Files\dotnet\sdk] 3.1.300 [C:\Program Files\dotnet\sdk] .NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |abnf|forivall|1.0.0| |auto-rename-tag|formulahendry|0.1.3| |bash-ide-vscode|mads-hartmann|1.10.2| |beautify|HookyQR|1.5.0| |better-comments|aaron-bond|2.0.5| |Bookmarks|alefragnani|11.2.0| |bracket-pair-colorizer-2|CoenraadS|0.1.4| |code-settings-sync|Shan|3.4.3| |code-spell-checker|streetsidesoftware|1.9.0| |colonize|vmsynkov|2.2.2| |csharp|ms-dotnettools|1.22.0| |csharpextensions|jchannon|1.3.1| |csharpfixformat|Leopotam|0.0.84| |docomment|k--kato|0.1.11| |dotnet-test-explorer|formulahendry|0.7.2| |EditorConfig|EditorConfig|0.15.1| |errorlens|usernamehw|3.1.1| |gc-excelviewer|GrapeCity|2.1.35| |git-graph|mhutchie|1.23.0| |gitignore|codezombiech|0.6.0| |gitlens|eamodio|10.2.1| |js-debug-nightly|ms-vscode|2020.5.2917| |language-haskell|justusadam|3.2.1| |language-x86-64-assembly|13xforever|2.3.0| |markdown-all-in-one|yzhang|3.0.0| |material-icon-theme|PKief|4.1.0| |msbuild-project-tools|tintoy|0.3.6| |npm-intellisense|christian-kohler|1.3.0| |open-in-browser|techer|2.0.0| |output-colorizer|IBM|0.1.2| |path-autocomplete|ionutvmi|1.13.6| |project-manager|alefragnani|11.0.1| |python|ms-python|2020.5.80290| |restructuredtext|lextudio|128.0.0| |rewrap|stkb|1.11.0| |search-node-modules|jasonnutter|1.3.0| |sort-lines|Tyriar|1.9.0| |TabOut|albert|0.1.6| |tinypng|andi1984|0.3.3| |todo-tree|Gruntfuggly|0.0.176| |turbo-console-log|ChakrounAnas|1.4.0| |vsc-material-theme|Equinusocio|32.6.0| |vscode-colorize|kamikillerto|0.8.17| |vscode-counter|uctakeoff|1.3.5| |vscode-csharp-snippets|jorgeserrano|0.3.1| |vscode-eslint|dbaeumer|2.1.5| |vscode-html-css|ecmel|0.2.3| |vscode-jumpy|wmaurer|0.3.1| |vscode-markdownlint|DavidAnson|0.36.0| |vscode-npm-script|eg2|0.3.12| |vscode-nuget-package-manager|jmrog|1.1.6| |vscode-solution-explorer|fernandoescolar|0.3.10| |vscode-wakatime|WakaTime|4.0.0| |vscode-xml|redhat|0.11.0| |vscode-yaml|redhat|0.8.0|;
JoeRobich commented 4 years ago

Ah, I see what you mean. Thanks for trying out Semantic Highlighting.

image

The problem is the scope we define for the semantic token is resolving to the themes comment colors, since a comment.documentation.name colors isn't defined. Until we work out a suitable fix, you can try the newly included Visual Studio 2019 Light or Dark themes.

image

cschierig commented 4 years ago

I don't have much experience with VS Code extension development, would it be possible to simply include the scope in a theme to fix this?

JoeRobich commented 4 years ago

@CozyPenguin Since I'm not sure which theme you are currently using, if you are using Dark+ or Light+ VSCode themes, you can copy the following tweaks into your settings.json.

   "editor.tokenColorCustomizations": {
        "[Default Dark+]": {
            "textMateRules": [
                {
                    "scope": "comment.documentation",
                    "settings": {
                        "foreground": "#608B4E",
                    }
                },
                {
                    "scope": "comment.documentation.attribute",
                    "settings": {
                        "foreground": "#C8C8C8",
                    }
                },
                {
                    "scope": "comment.documentation.cdata",
                    "settings": {
                        "foreground": "#E9D585",
                    }
                },
                {
                    "scope": "comment.documentation.delimiter",
                    "settings": {
                        "foreground": "#808080",
                    }
                },
                {
                    "scope": "comment.documentation.name",
                    "settings": {
                        "foreground": "#569CD6",
                    }
                },
            ]
        },
        "[Default Light+]": {
            "textMateRules": [
                {
                    "scope": "comment.documentation",
                    "settings": {
                        "foreground": "#008000",
                    }
                },
                {
                    "scope": "comment.documentation.attribute",
                    "settings": {
                        "foreground": "#282828",
                    }
                },
                {
                    "scope": "comment.documentation.cdata",
                    "settings": {
                        "foreground": "#808080",
                    }
                },
                {
                    "scope": "comment.documentation.delimiter",
                    "settings": {
                        "foreground": "#808080",
                    }
                },
                {
                    "scope": "comment.documentation.name",
                    "settings": {
                        "foreground": "#808080",
                    }
                }
            ]
        }
    },

Also note that the C# extension now includes Visual Studio 2019 Light and Dark themes which closely match the themes used in VS.

bestknighter commented 2 years ago

For those who get here facing the same issue but doesn't use either Visual Studios 2019's themes nor VSCode's Dark+/Light+ themes, Joe's workaround is still perfectly fine. You just need to do two things: