Quantcast
Channel: Active questions tagged visual-studio-code - Stack Overflow
Viewing all articles
Browse latest Browse all 98994

Settings from the .editorconfig are not respected in Omnisharp / VS Code

$
0
0

I'm trying to set up my Visual Stuido Code so that Omnisharp uses settings supplied in an .editorconfig, as described in https://www.strathweb.com/2019/07/editorconfig-support-in-omnisharp-and-c-extension-vs-code/. I set up a new .net-core 3.1 console project using dotnet new console and added a .editorconfig file to the root of the project. Then I filled in the exact values from the blog post (see below) and enabled editorconfig and roslyn analyzers for OmniSharp. I even tried both methods for enabling the features: In settings.json and in omnisharp.json. But when I used the refactoring capabilities of OmniSharp to create a field from a constructor parameter the generated name was equal to the parameter name instead of being prefixed with _. Restarting the OmniSharp server multiple times didn't help as well.

.editorconfig

[*.cs]
dotnet_style_qualification_for_field = false
dotnet_naming_style.instance_field_style.capitalization = camel_case
dotnet_naming_style.instance_field_style.required_prefix = _

Sample class with auto-generated field

public class MyClass
{
    private readonly string a;  // This should have been named _a

    public MyClass(string a)
    {
        this.a = a;  // Should be without the this.-prefix
    }
}

What I am using:

  • VS Code version 1.42.1
  • C# extension for VS Code version 1.21.12
  • Omnisharp server (part of the extension) version 1.34.13

I would appreciate it alot if anyone could tell me what I am doing wrong or point me in the right direction.


Viewing all articles
Browse latest Browse all 98994

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>