Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run EditorConfig over C# Files From the Command Line?

Newer versions of Visual Studio Support EditorConfig within the IDE which is useful, however it would be best if I could run it from the command line (and therefore in automation).

Is there any stand alone tool that supports all of the EditorConfig Settings as the Visual Studio IDE does? Microsoft Docs: .NET coding convention settings for EditorConfig

Here's what I have found so far:

  • ReSharper CleanupCode Command-Line Tool - It is unclear if this supports editorconfig, there is some mention in the resharper documentation but it is unclear if this is supported by the stand alone tool.
  • dotnet/codeformatter - This for sure does not support editorconfig and according to this issue the project is dead

Baring a stand alone tool is there any way to force Visual Studio into running the code cleanup "headless"? That might be my only solution.

like image 399
aolszowka Avatar asked Nov 13 '18 15:11

aolszowka


1 Answers

I've been hunting for the same thing, just found a very new tool for this, dotnet-format, put out from the Roslyn team:

https://github.com/dotnet/roslyn/tree/master/src/Tools/dotnet-format

From their README:

dotnet-format is a code formatter for dotnet that applies style preferences to a project or solution. Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used.

Looks like the indented usage is something like:

$ dotnet format -w MyApplication.sln
like image 83
Ryan Davis Avatar answered Sep 20 '22 05:09

Ryan Davis