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

Created on 20 Jan 2018  路  30Comments  路  Source: OmniSharp/omnisharp-vscode

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.

Editor-Formatting Resolved-External

Most helpful comment

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?

All 30 comments

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

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

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?

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.

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?

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

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

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

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?

ah ha! Thanks @savpek!

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

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

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

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

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

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

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 ...

I checked that and it is true. I don鈥檛 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.

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

For me helped when I switched from _workspace project_ to _folder project_

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.

This one worked for me https://marketplace.visualstudio.com/items?itemName=Leopotam.csharpfixformat

It is ridiculous that Microsoft can't even provide a formatter for their own language.

@montao We recently added the support for handling basic operations with stand-alone cs files which includes the formatting as well. Are you able to reproduce the issue with the latest version of the C# extension ?

Yes, I am able to reproduce.

Fresh install of VS Code and only one extension installed: ms-vscode.csharp 1.17.1.

Loaded .cs source file without project and experienced the same behavior.

Version: 1.30.2 (system setup)
Commit: 61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8
Date: 2019-01-07T22:54:13.295Z
Electron: 2.0.12
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
OS: Windows_NT x64 6.1.7601

@ssurba The "Miscellaneous" file is loaded into the omnisharp workspace once the user starts editing the file. Did you try to make some changes in the file. It "should" give you basic instellisense. Also, note that you must open the folder in vscode in which the file is contained.

Also, @ssurba since this is a closed issue, please file a separate issue if the error further reproduces.

@akshita31 Thanks for pointing out. After opening the directory IntelliSense started to work. However for me it was not clear that opening the directory is required for IntelliSense to function. Maybe it makes sense to state it somewhere in the documentation or even alert the user in Code (with balloon or in status bar) that they are editing file without having directory open.

@ssurba Glad you got it working. Yes I agree that we should have a note for this somewhere. @rchande Thoughts on what is the best place to add the note that users are supposed to have a file opened within a folder inorder to have intellisense via miscellaneous files to work.

@akshita31 I think we'd want to investigate activating the extension with just a file and no directory.

@rchande Sounds reasonable. I opened a new issue for it. https://github.com/OmniSharp/omnisharp-vscode/issues/2829

Was this page helpful?
0 / 5 - 0 ratings