vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Format code returns: Sorry, but there is no formatter for 'csharp'-files installed.

Open savpek opened this issue 8 years ago • 30 comments

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.2)

Product Information:
 Version:            2.1.2
 Commit SHA-1 hash:  5695315371

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

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.3
  Build    : a9190d4a75f4a982ae4b4fa8d1a24526566c69df

VS Code version: Version 1.19.2 Commit 490ef761b76b3f3b3832eff7a588aac891e5fe80 Date 2018-01-10T16:16:25.767Z Shell 1.7.9 Renderer 58.0.3029.110 Node 7.9.0 Architecture ia32 C# Extension version: 1.13.1

Steps to reproduce

I did got extension C# FixFormat installed. I uninstalled it and after that i constantly just receive "Sorry, but there is no formatter for 'csharp'-files installed". Feels like omnisharp doesn't install that part any more, i tried to reinstall omnisharp without success.

I didn't find any errors or messages from omnisharp log or vscode developer console. Didn't try debugmodes though.

Expected behavior

Format is invoked.

Actual behavior

Format is not invoked and error "Sorry, but there is no formatter for 'csharp'-files installed." appear in vscode.

savpek avatar Jan 20 '18 08:01 savpek

@savpek Have you tried installing and uninstalling the C# extension?

rchande avatar Jan 22 '18 16:01 rchande

Yes i tried that, i will test this case more later this week. With another computer etc if this is reproducible in other environments.

savpek avatar Jan 22 '18 18:01 savpek

I don't use the FixFormat extension. Perhaps it hijacks the formatting command in some way? Does the issue still repro with that extension disabled?

DustinCampbell avatar Jan 23 '18 18:01 DustinCampbell

I have the same issue right now and i have never had FixFormat installed.

There other features of omnisharp seem to work correctly (i.e. autocompletion). It started out of nowhere - i was working on a project and at some point autoformatting stopped working. Tried to reinstall OmniSharp but with no luck.

pushist1y avatar Jan 24 '18 16:01 pushist1y

Thanks @pushist1y. @rchande : It sounds like we'll need to take a look here. If it happened recently, maybe something happening in our formatting code?

DustinCampbell avatar Jan 24 '18 20:01 DustinCampbell

It happened after the latest VSCode upgrade for me. Version 1.19.3

RobCannon avatar Jan 27 '18 22:01 RobCannon

I just updated to 1.19.3 and couldn't reproduce the issue. @rchande: Have you seen this?

DustinCampbell avatar Jan 29 '18 15:01 DustinCampbell

Tested on work and home, repro in both. I also tested so that i cleared vscode, omnisharp etc folders from my user and installed just C# extension to vscode and issue occurred again. I could test with clean machine later

savpek avatar Jan 30 '18 18:01 savpek

Ah got it, there was line "csharp.format.enable": false, in my user config, after cleared that it started working again. C# fixformat extensions seems to set it, tested to install it after cleared user settings ... image

However other issues mentioned here may not be releated to this. Should this issue be closed or?

savpek avatar Jan 30 '18 18:01 savpek

ah ha! Thanks @savpek!

@RobCannon, @pushist1y, do you have the same setting?

DustinCampbell avatar Jan 30 '18 21:01 DustinCampbell

@savpek yes, c#fixformat ask you to make change in settings on first start - looks like you agreed without reading message. :)

Leopotam avatar Feb 07 '18 08:02 Leopotam

I will close this issue, if @RobCannon, @pushist1y still has it i will reopen 😄

savpek avatar Feb 09 '18 16:02 savpek

resolved after updating to vs.code 1.20.1 and re-enabling omni-sharp.

pushist1y avatar Feb 15 '18 14:02 pushist1y

issue occurred on vs.code Version 1.21.1 Commit 79b44aa704ce542d8ca4a3cc44cfca566e7720f1 Date 2018-03-14T14:46:47.128Z Shell 1.7.9 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64

dotnet --info: Product Information: Version: 2.1.101 Commit SHA-1 hash: 6c22303bf0

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

Microsoft .NET Core Shared Framework Host

Version : 2.0.6 Build : 74b1c703813c8910df5b96f304b0f2b78cdf194d

Serg61 avatar Mar 21 '18 21:03 Serg61

I know this issue is closed but I am getting the same error on visual studio code 1.22.2 on Windows 10. Version 1.22.2 Commit 3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9 Date 2018-04-12T16:38:45.278Z Shell 1.7.12 Renderer 58.0.3029.110 Node 7.9.0 Architecture x64

I uninstalled all the extensions, reinstalled Visual Studio Code and still getting the same error.

ZeinSleiman avatar Apr 22 '18 03:04 ZeinSleiman

@ZeinSleiman

Ah got it, there was line "csharp.format.enable": false, in my user config, after cleared that it started working again. C# fixformat extensions seems to set it, tested to install it after cleared user settings ...

Leopotam avatar Apr 22 '18 05:04 Leopotam

I checked that and it is true. I don’t have any other extensions installed. When u install it by default it should be set true. I removed any data related to extensions before I installed.

ZeinSleiman avatar Apr 22 '18 18:04 ZeinSleiman

For those who've confirmed that "csharp.format.enable" is set to true and you're still having the issue, it's being tracked over here: https://github.com/OmniSharp/omnisharp-vscode/issues/2391

stamminator avatar Jun 29 '18 20:06 stamminator

For me helped when I switched from workspace project to folder project

ChaosEngine avatar Sep 10 '18 20:09 ChaosEngine

CaosEngine is correct. When opening a workspace project, or opening a lone .cs file outside of a folder project, it refuses to format the code. I doubt this is the intended behaviour. Somehow omnisharp needs to be registered as the default provider for formating, even when not using a folder project.

jakobhviid avatar Sep 27 '18 10:09 jakobhviid