question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Omnisharp ignores omnisharp.json settings while formatting in v1.25.1

See original GitHub issue

Issue Description

Omnisharp does not respect the omnisharp.json files anymore under VS Code C# extension v1.25.1 while it does for v1.25.0.

Steps to Reproduce

I use the omnisharp language server for among other formatting of my source code in VS Code. I have an omnisharp.json file in %USERPROFILE%/.omnisharp. Also, for testing purposes I copied this file to my projects working directory.

Steps:

  • Open a file (C# of course)
  • Format

Expected Behavior

I expected omnisharp to respect the formatting choices as present in the configuration file as it did every previous day.

Actual Behavior

It used the default configuration for formatting.

Workaround

I rolled back to the VS Code C# extension v1.25.0 (which you can see in the logs below) and this fixed the issue. I do not know if some new settings are needed from my side maybe with the new omnisharp.useModernNet or that something has gone awry with the included update to omnisharp 1.39.2.

Logs

OmniSharp log

Starting OmniSharp server at 11/9/2022, 11:18:59 AM Target: c:\Users\5803969\src\stitch

OmniSharp server started with .NET 6.0.403 . Path: c:\Users\5803969.vscode\extensions\ms-dotnettools.csharp-1.25.0-win32-x64.omnisharp\1.39.0-net6.0\OmniSharp.dll PID: 17164

    Starting OmniSharp on Windows 10.0.19044.0 (x64)
    Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
    Using the 'dotnet' on the PATH.
    DotNetPath set to dotnet
    Located 2 MSBuild instance(s)
        1: .NET Core SDK 6.0.403 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.403\"
        2: .NET Core SDK 6.0.401 17.3.1 - "C:\Program Files\dotnet\sdk\6.0.401\"
    Registered MSBuild instance: .NET Core SDK 6.0.403 17.3.2 - "C:\Program Files\dotnet\sdk\6.0.403\"
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    No solution files found in 'c:\Users\5803969\src\stitch'
    Queue project update for 'c:\Users\5803969\src\stitch\stitch\stitch.csproj'
    Queue project update for 'c:\Users\5803969\src\stitch\tests\tests.csproj'
    Detecting CSX files in 'c:\Users\5803969\src\stitch'.
    Loading project: c:\Users\5803969\src\stitch\stitch\stitch.csproj
    Did not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'c:\Users\5803969\src\stitch' on host 17916.
    Successfully loaded project file 'c:\Users\5803969\src\stitch\stitch\stitch.csproj'.
    Adding project 'c:\Users\5803969\src\stitch\stitch\stitch.csproj'
    Loading project: c:\Users\5803969\src\stitch\tests\tests.csproj
    Successfully loaded project file 'c:\Users\5803969\src\stitch\tests\tests.csproj'.
    Adding project 'c:\Users\5803969\src\stitch\tests\tests.csproj'
    Update project: stitch
    Update project: tests

C# log

Empty

Environment information

VSCode version: 1.73.0 C# Extension: 1.25.0

Dotnet Information .NET SDK (reflecting any global.json): Version: 6.0.403 Commit: 2bc18bf292

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

global.json file: Not found

Host: Version: 6.0.11 Architecture: x64 Commit: 943474ca16

.NET SDKs installed: 3.1.425 [C:\Program Files\dotnet\sdk] 6.0.401 [C:\Program Files\dotnet\sdk] 6.0.403 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.31 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET: https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs: https://aka.ms/dotnet/runtimes-sdk-info

Visual Studio Code Extensions
Extension Author Version
better-toml bungcip 0.3.2
code-spell-checker streetsidesoftware 2.11.0
crates serayuzgur 0.5.10
csharp ms-dotnettools 1.25.0
docomment k–kato 0.1.31
errorlens usernamehw 3.6.0
githistory donjayamanne 0.6.19
gitlens eamodio 13.0.4
haskelly UCL 0.5.5
hexeditor ms-vscode 1.9.9
intellicode-api-usage-examples VisualStudioExptTeam 0.2.6
isort ms-python 2022.4.0
jupyter ms-toolsai 2022.9.1202862440
jupyter-keymap ms-toolsai 1.0.0
jupyter-renderers ms-toolsai 1.0.12
language-haskell justusadam 3.6.0
latex-workshop James-Yu 9.0.1
LiveServer ritwickdey 5.7.9
material-product-icons PKief 1.4.1
python ms-python 2022.18.1
r REditorSupport 2.6.1
rainbow-csv mechatroner 3.3.0
reflow-paragraph TroelsDamgaard 1.3.0
rust-analyzer rust-lang 0.3.1277
svg jock 1.4.22
unique-lines bibhasdn 1.0.0
vscode-html-css ecmel 1.13.1
vscode-intelephense-client bmewburn 1.8.2
vscode-jupyter-cell-tags ms-toolsai 0.1.6
vscode-jupyter-slideshow ms-toolsai 0.1.5
vscode-lldb vadimcn 1.8.1
vscode-pull-request-github GitHub 0.54.0
vscode-pylance ms-python 2022.11.10
vscode-todo-highlight wayou 1.0.5
vsliveshare ms-vsliveshare 1.0.5762
wordpress-toolbox wordpresstoolbox 1.3.14

Issue Analytics

  • State:closed
  • Created 10 months ago
  • Reactions:7
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
chickenSandwichcommented, Nov 9, 2022

Thanks for posting the logs. Actually, there was a change in OmniSharp 1.39.2 where editorconfig is given higher priority over formatting options set via omnisharp.json (which is sort of legacy).

Because the extension enables editor config by default, this results in the behavior you experience. If you switch off editorconfig support ("omnisharp.enableEditorConfigSupport": false, also make sure that omnisharp.json does not enable it too, as it could) then it should again respect the formatting settings from omnisharp.json.

However going forward, I think it would be best to move your formatting options to editorconfig file for a number of reasons (can be portable between editors, single place to manage formatting and diagnostics and so on).

@filipw : Thank-you. This is working after adding "omnisharp.enableEditorConfigSupport": false,, and updating to 1.25.1.

7reactions
fmoocommented, Nov 11, 2022

I would have expected a setting like “Enable Editor Config Support” to fall back to omnisharp.json when there is no .editorconfig in the workspace, which the current implementation did not do.

It seems inappropriate to make the default behavior break backwards compatibility in a patch release.

Read more comments on GitHub >

github_iconTop Results From Across the Web

VSCode Omnisharp ignores format settings in omnisharp.json
Reinstalling the C# extension to v1.25.0 from v1.25.2 fixed it for me. My understanding is that the newly added omnisharp setting "Enable Editor ......
Read more >
Hidden features of OmniSharp and C# extension for VS Code
In this post I wanted to show you a few of such less known features. OmniSharp options. Typically, tweaking different OmniSharp features or ......
Read more >
Dafny Reference Manual
Specifications and ghost constructs are used only during verification; the compiler omits them from the executable code. The dafny verifier is run as...
Read more >
Compare Packages Between Distributions - DistroWatch.com
architecture.builder-protocol.json-20221106-git ... bamboo-theme-blueprint-2010.2.25.1 ... emacs-json-reformat-20220905.2342 emacs-jsonrpc-1.0.15
Read more >
Multilenguag 2 Visual Basic Tabla de Contenidos 2806 Paginas
global.json ... Better calendar support and additional formatting options for DateTime values. ... editors get editor IntelliSense using Omnisharp.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found