I’ve recently been setting up our team coding standards in .editorconfig styles as an alternative to ReSharper. This morning I’ve been driving myself insane because nothing I try will get the styles to apply when and where they should. I’ve seen so many other threads and nothing has solved the problem. This question is closest to my problem, but was never resolved.
Our limitations:
- Visual Studio 2017 (15.9.4)
- .NET 4.8
- We need to load solutions with
devenv MySolution.sln /useenv
I’ve reduced my .editorconfig file to four rules, with no set severity to make things simple to test. (And also because I wasn’t sure if something else in the file was breaking it.) So this is all that’s in the current file (at the same level as the .sln file, included as a solution item):
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
###############################
# .NET Coding Conventions #
###############################
[*.{cs}]
# this. preferences
dotnet_style_qualification_for_field = true
dotnet_style_qualification_for_property = true
dotnet_style_qualification_for_method = true
dotnet_style_qualification_for_event = true
My personal/machine-specific settings are the opposite:
Because .editorconfig files are supposed to override personal settings, I would expect Intellisense to be happy with ‘this’ keywords and not remove them when formatting the document. Instead I get the lightbulb telling me I can simplify the name by removing ‘this’:
And when I format the document, it just removes them. So VS2017 is clearly just ignoring the .editorconfig file. VS2022 and VSCode both respect the settings (though this wasn’t using devenv).
Things I have tried:
- Making sure my folder hierarchy doesn’t contain square brackets
- Adding
root = true
- Adding at the project level as well as/in addition to the solution level
- Changing the severity level
- Putting .editorconfig right at the top level of my repository
- Some other things I didn’t note down, like adding some specific lines to the .csproj files
Does anyone know what I’m missing or how I can get this working?