Home > Mobile >  Visual Studio 2022 editorconfig not applied on cleanup
Visual Studio 2022 editorconfig not applied on cleanup

Time:04-26

I'm having a bit of trouble understanding how .editorconfig should work.

  • I created the .editorconfig file at the solution level

  • enforced the file scoped namespaces in it

  • I correctly see the warning in my .cs file for the above rule

  • I would have expected that to be applied automatically when running Visual Studio's code cleanup, but nothing happens

Am i understanding something wrong? shouldn't vs code cleanup refactor files based on .editorconfig rules?

moreover, if i try to open the .editorconfig file i get an empty UI in VS.

What am i missing?

CodePudding user response:

Visual Studio's Code Cleanup feature runs a set of predefined tasks, as configured in the Code Cleanup profile. Most of these tasks correspond to specific IDE settings, some of which may be configured by .editorconfig.

Among those is Format Document, which uses takes a lot of the .editorconfig settings into account when applying formatting all in one big operation. However, Format Document does not make refactoring changes to the existing code. It wouldn't change the overall structure of the document.

There is a Code Fix (or lightbulb, or suggested action, or... it goes by lots of names) that will appear on the namespace block. That will provide a gesture to make the edit in that file, or across the entire project or solution (each file will be modified as applicable, as .editorconfig applies to directory hierarchies, and may not be present for all projects in the solution).

moreover, if I try to open the .editorconfig file I get an empty UI in VS..

This sounds like a bug and should be reported using the VS Feedback tool.

  • Related