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

Multiple Errors Appear When Creating a C# Text File #6973

Closed
SlyCoop91 opened this issue Mar 15, 2024 · 14 comments · Fixed by dotnet/roslyn#74300
Closed

Multiple Errors Appear When Creating a C# Text File #6973

SlyCoop91 opened this issue Mar 15, 2024 · 14 comments · Fixed by dotnet/roslyn#74300
Assignees
Milestone

Comments

@SlyCoop91
Copy link

Type: Bug

Issue Description
When creating a C# text file with the extension installed on Visual Studio Code, three errors pop up:
Request textDocument/inlayHint failed.
Request textDocument/codeAction failed.
Request textDocument/diagnostic failed.

C# Log
[Error - 8:01:11 PM] Request textDocument/diagnostic failed.
Message: Unsupported extension '' and LSP language id ''
Code: -32000
[object Object]
[Error - 8:01:11 PM] Document pull failed for text document untitled:Untitled-1
Message: Unsupported extension '' and LSP language id ''
Code: -32000
[object Object]
[Error - 8:01:11 PM] Request textDocument/codeAction failed.
Message: Unsupported extension '' and LSP language id ''
Code: -32000
[object Object]
[Error - 8:01:11 PM] Request textDocument/inlayHint failed.
Message: Unsupported extension '' and LSP language id ''
Code: -32000
[object Object]

Steps

  1. Click "New Text File" in File tab.
  2. Click "Select a language".
  3. Choose the "C#" to create the file.

Expected Results
Nothing.

Actual Results
Three errors pop up.

Extension version: 2.22.3
VS Code version: Code 1.87.2 (863d2581ecda6849923a2118d93a088b0745d9d6, 2024-03-08T15:20:17.278Z)
OS version: Windows_NT x64 10.0.22631
Modes:

System Info
Item Value
CPUs AMD Ryzen 7 7840HS w/ Radeon 780M Graphics (16 x 3793)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.19GB (6.03GB free)
Process Argv --crash-reporter-id 3504a287-36f3-44f0-8bb2-9484d8cc1261
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscorecescf:30445987
vscod805cf:30301675
binariesv615:30325510
vsaa593cf:30376535
py29gd2263:30899288
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
pythongtdpath:30769146
welcomedialog:30910333
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30986171
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:30979542
d34g3935:30971562
fegfb526:30981948
bg6jg535:30979843
dsvsc020:30976470
7ghi1836:30988842

@JoeRobich
Copy link
Member

Interesting. Setting the language to C# makes the extension aware of the file but since it hasn't been saved it doesn't have an extension. Note that since it hasn't been saved it won't be associated with a particular project, meaning it may not have all the references you may want.

As a workaround you can use the file explorer to save a new empty file in your open folder.

@SlyCoop91
Copy link
Author

First of all, how do I go about doing the workaround you mentioned? I am actually just starting to use Visual Studio Code, so I am not knowledgeable of how to do it.

Secondly, do you think it is possible for the developers to fix the cause of the errors? I know it has something to do with the extension because it doesn't happen when I create a new text file using the C or the C++ extensions?

@JoeRobich
Copy link
Member

First of all, how do I go about doing the workaround you mentioned?

After you have opened a folder in VS Code, you will see buttons in the title bar of the file explorer when your mouse is hovering over it.

Image

Also, if your folder contains subfolders, then you can right click on a subfolder and there will be a "New File..." option.

Image

Secondly, do you think it is possible for the developers to fix the cause of the errors?

Yes, I think this issue is fixable but it may not be a high priority. There is still the caveat that until the file is saved it won't be associated with a particular project. This means, that if you had added references to NuGet packages to your project, they will not be available within the file until it has been saved.

@SlyCoop91
Copy link
Author

I see the "New File..." after opening a folder. Do I just click it, and if I do that, what is the next thing to do?

@SylwesterZarebski
Copy link

I mostly use VSCode to prepare some code within new and not saved tabs and no projects. Just now VSCode started showing annoying error popup on every program start with unnamed tabs. For now only permanent option is disable all notifications from C# extension/module.

@qvikuku
Copy link

qvikuku commented Apr 4, 2024

This is not limited to unsaved text files.

E.g. opening a staged file in source control bar gives the following:

[Error - 13:57:57] Request textDocument/diagnostic failed.
  Message: Unsupported extension '.cs%22,%22ref%22:%22%22%7D' and LSP language id ''
  Code: -32000 
[object Object]
[Error - 13:57:57] Document pull failed for text document git:/my_path/myfile.cs?%7B%22path%22%3A%22%2Fmy_path%2Fmyfile.cs%22%2C%22ref%22%3A%22%22%7D
  Message: Unsupported extension '.cs%22,%22ref%22:%22%22%7D' and LSP language id ''
  Code: -32000 
[object Object]

(Note that I masked the path of the opened file, including the url encoded part.)

I've been getting these for roughly "few weeks" now. Annoying popups, but otherwise harmless.

I'm not familiar with inner workings of Visual Studio Code or language servers, so the following is conjecture, but this smells like a more general problem of this extension erroring out when it's touching bunch of things that it's not supposed to be touching and then turning it into a user problem. E.g. seems to me new text files and staged C# files in some git temporary folder don't need much more language specific processing from extenstions than some basic syntax highlighting.

@chickenSandwich
Copy link

This happens every time I stage .cs files:

Request textDocument/diagnostic failed.
  Message: Unsupported extension '.cs%22,%22ref%22:%22%22%7D' and LSP language id ''
  Code: -32000 
[object Object]

@ltouro
Copy link

ltouro commented Jul 1, 2024

Same here

This happens every time I stage .cs files:

Request textDocument/diagnostic failed.
  Message: Unsupported extension '.cs%22,%22ref%22:%22%22%7D' and LSP language id ''
  Code: -32000 
[object Object]

Edit: Was able to fix that updating SDK version (8.0.302) and removing the older version (8.0.100)

@aflordelis
Copy link

Same here

This happens every time I stage .cs files:

Request textDocument/diagnostic failed.
  Message: Unsupported extension '.cs%22,%22ref%22:%22%22%7D' and LSP language id ''
  Code: -32000 
[object Object]

Edit: Was able to fix that updating SDK version (8.0.302) and removing the older version (8.0.100)

Currently using 8.0.302 but the issue still persists.
The popups are so annoying.

@ltouro
Copy link

ltouro commented Jul 9, 2024

Currently using 8.0.302 but the issue still persists.

Have you checked the installed SDKs list? Make sure you don't have more versions for 8.X available (or maybe not any other version at all, if big Visual Studio is not a thing for you). To that end, I suggest using https://learn.microsoft.com/en-us/dotnet/core/additional-tools/uninstall-tool

The popups are so annoying.

1000% agreed. And you can't even turn these off. I was also loosing IntelliSense, which is even worse

@dibarbet dibarbet added this to the July2024 milestone Jul 9, 2024
@dibarbet
Copy link
Member

dibarbet commented Jul 9, 2024

FYI a fix is in progress for this and should be available this month. In the meantime, you can check the following setting in VSCode to suppress the error messages:
image

@aflordelis
Copy link

FYI a fix is in progress for this and should be available this month. In the meantime, you can check the following setting in VSCode to suppress the error messages: image

Awesome, this worked!! Thanks.

@dibarbet
Copy link
Member

The fix for this should make it into next week's prerelease

@dibarbet
Copy link
Member

This should be fixed (at least for new C# files / diff window files) in the 2.39.28 prerelease version of the C# extension

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