dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 670 forks source link

code analysis hints appearing in two different languages #6912

Open PyrateAkananto opened 7 months ago

PyrateAkananto commented 7 months ago

Code analysis hints (sometimes even called IntelliSense) in Visual Studio Code appear in two different languages, English and German, based on the category of the hint.

For example csharp(IDE0051) is in English: Private member 'TestDotnetConsole._value' is unused ...and csharp(CA1822) is in German: Der Member "Main" greift nicht auf Instanzdaten zu und kann als "static" markiert werden.

mixed-languages

My Windows 10 is set to German, my Visual Studio Code is set to English and I want all my code analysis hints in English (because German hints sound weird and searching for them online brings up far less results than searching for the English ones).

I followed every recommendation I was able to find online to change the language to English - but some, not all, hints are still in German.

https://github.com/OmniSharp/omnisharp-vscode/issues/2513 is similar but labeled as "reature request". I intentionally opened this new issue because mixing languages in output should be an obvious bug.

Steps to reproduce

Have .NET 8 installed and create a new project with dotnet new console. Add the following files to it.

TestDotnetConsole.cs.txt TestDotnetConsole.csproj.txt TestDotnetConsole.code-workspace.txt omnisharp.json

Use Visual Studio Code and extension "C#" to edit the project after having followed all the recommendations mentioned fellow (setting environment variable and deleting all localized DLLs).

Expected behavior

All code analysis hints are in in English.

Actual behavior

Some code analysis hints are in German, some others are in English.

Additional context

Windows 10 Pro, Version 22H2, 19045.4046 Windows language is German (I cannot change that because it is a company PC)

Visual Studio Code version 1.86.2 Visual Studio Code display language "English (en)" (no other language is installed)

Visual Studio Code extension "C#" version 2.15.30 Setting Omnisharp: Use Modern Net set to true (but I have even seen the issue happen while set to false)

Visual Studio Code extension "C# DevKit" not installed!

According to dotnet sdk check I have installed: .NET SDKs: 6.0.412 8.0.101 .NET Runtimes: Microsoft.AspNetCore.App 6.0.20 Microsoft.NETCore.App 6.0.20 Microsoft.WindowsDesktop.App 6.0.20 Microsoft.AspNetCore.App 8.0.1 Microsoft.NETCore.App 8.0.1 Microsoft.WindowsDesktop.App 8.0.1

The environment variable DOTNET_CLI_UI_LANGUAGE is set to en-us (when I open cmd.exe and run the command set the output includes the line DOTNET_CLI_UI_LANGUAGE=en-us). (source for that recommendation: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_cli_ui_language )

In the folder C:\Users\myname\.vscode\extensions\ms-dotnettools.csharp-2.15.30-win32-x64\.omnisharp\1.39.11 I deleted all sub-folders, including de. In the folder C:\Users\myname\.vscode\extensions\ms-dotnettools.csharp-2.15.30-win32-x64\.omnisharp\1.39.11-net6.0 I deleted all sub-folders, including de. (source for that recommendation: https://github.com/OmniSharp/omnisharp-vscode/issues/2513 )

In the folder C:\Users\myname\.vscode\extensions\ms-dotnettools.csharp-2.15.30-win32-x64\.debugger\x86_64 I deleted all sub-folders, including de and 1031 (which stands for "German - Germany"). (source for that recommendation: https://github.com/dotnet/vscode-csharp/issues/2513#issuecomment-981134545 )

settings-reduced.json omnisharp-output.txt

dibarbet commented 7 months ago

I know you're using O#, but I would be curious if you hit the same issue with 'useOmnisharp' set to false (and on the latest version of the C# extension, 2.18.16).

I believe in either case we should be respecting the language configured by VSCode, but there might be weirdness in the analyzers causing issues (I notice that the CA analyzers are reporting in german)

PyrateAkananto commented 7 months ago

@dibarbet Thank you for your attention.

C# v2.15.30 Omnisharp: Use Modern Net = true Dotnet > Server: Use Omnisharp = true omnisharp.json file present ==> mixed languages in PROBLEMS

C# v2.18.16 Omnisharp: Use Modern Net = true Dotnet > Server: Use Omnisharp = true omnisharp.json file present ==> mixed languages in PROBLEMS

C# v2.18.16 Omnisharp: Use Modern Net = true Dotnet > Server: Use Omnisharp = false omnisharp.json file present ==> no information at all in PROBLEMS

OUTPUT:

Using dotnet configured on PATH
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# standalone...
waiting for named pipe information from server...
[stdout] {"pipeName":"\\\\.\\pipe\\1bc5bd68"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 12:17:42 PM] [Program] Language server initialized
[Info  - 12:17:44 PM] [LanguageServerProjectSystem] Successfully completed load of c:\Projects\TestDotnetConsole\TestDotnetConsole.csproj
[Info  - 12:17:44 PM] [LanguageServerProjectSystem] Completed (re)load of all projects in 00:00:01.2270993

Same test again but with... omnisharp.json file not present ...has same result (no information at all in PROBLEMS).

Same test again but with... Dotnet > Background Analysis: Analyzer Diagnosics Scope = fullSolution (default is openFiles) ...has same result.

Same test again but with... Omnisharp: Use Modern Net = false ...has same result.

I assume (and please correct me if I am wrong) when Use Omnisharp is set to false then there is no information at all in PROBLEMS because "C# DevKit" is not installed.

Unfortunately I cannot install "C# DevKit" because I work for an "enterprise" according to that extension's license terms. Technically I could installed it but then I would break its license terms. Except if my example project would be considered "open source" because I made all its sources public here in this issue. If you actually want me to install it and try it out, just for testing this specific issue here, and uninstall it afterwards again, I might be willing to do that.