Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Syntax highlighting for file scoped namespace #4884

Closed
bihe opened this issue Nov 10, 2021 · 3 comments
Closed

Incorrect Syntax highlighting for file scoped namespace #4884

bihe opened this issue Nov 10, 2021 · 3 comments

Comments

@bihe
Copy link

bihe commented Nov 10, 2021

Environment data

❯ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff

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

Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa

.NET SDKs installed:
3.1.301 [C:\Program Files\dotnet\sdk]
5.0.100 [C:\Program Files\dotnet\sdk]
5.0.102 [C:\Program Files\dotnet\sdk]
6.0.100 [C:\Program Files\dotnet\sdk]

VS Code version: 1.62.1
C# Extension version: 1.23.16

OmniSharp log

Starting OmniSharp server at 10.11.2021, 08:21:28
    Target: c:\Development\temp\webapi

OmniSharp server started.
    Path: c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\OmniSharp.exe
    PID: 6520

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
        Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
        Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Because 'UseBundledOnly' is enabled in the configuration, OmniSharp will only use the bundled MSBuild.
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 1 MSBuild instance(s)
            1: StandAlone 17.0.0 - "c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        MSBUILD_EXE_PATH environment variable set to 'c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\MSBuild.exe'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: StandAlone 17.0.0 - "c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin"
            CscToolExe = csc.exe
            CscToolPath = c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin\Roslyn
            MSBuildExtensionsPath = c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild
            MSBuildToolsPath = c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.16\.omnisharp\1.37.16\.msbuild\Current\Bin
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
[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.Cake.CakeProjectSystem
        Detecting Cake files in 'c:\Development\temp\webapi'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
        No solution files found in 'c:\Development\temp\webapi'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for 'c:\Development\temp\webapi\webapi.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in 'c:\Development\temp\webapi'.
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location 'c:\Development\temp\webapi' on host 18976.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: c:\Development\temp\webapi\webapi.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file 'c:\Development\temp\webapi\webapi.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project 'c:\Development\temp\webapi\webapi.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: webapi
Received response for /v2/blockstructure but could not find request.
Received response for /v2/codestructure but could not find request.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
        No symbol found. File: c:\Development\temp\webapi\Controllers\WeatherForecastController.cs, Line: 15, Column: 11.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
        No symbol found. File: c:\Development\temp\webapi\Controllers\WeatherForecastController.cs, Line: 21, Column: 40.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
        No symbol found. File: c:\Development\temp\webapi\Controllers\WeatherForecastController.cs, Line: 6, Column: 13.
Received response for /v2/getcodeactions but could not find request.
[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
        No symbol found. File: c:\Development\temp\webapi\Controllers\WeatherForecastController.cs, Line: 0, Column: 0.

Steps to reproduce

  1. Create a new webapi project via dotnet cli
  2. Open the WeatherForecastController.cs
  3. Syntax highlighting displayed in a wrong way.

image

  1. Use "old" namespace nesting

image

  1. Syntax is correctly highlighted
@filipw
Copy link
Contributor

filipw commented Nov 10, 2021

This works correctly with semantic highlighting:

    "editor.semanticHighlighting.enabled": true,
    "csharp.semanticHighlighting.enabled": true

The issue is with the built-in textmate grammar (not maintained in this repo but, in https://github.com/dotnet/csharp-tmLanguage). Semantic highlighting will generally speaking what you want to use anyway, because it is much better especially with modern language features.

@bihe
Copy link
Author

bihe commented Nov 11, 2021

@filipw very nice - thx!
Using the setting regarding semanticHighlighting it is correctly highlighted.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants