There is the .NET tool "dotnet-format" that allows formatting a C# code in a somehow unified way. This works fine for some cases. However, especially when a code base is edited and autoformatted in different IDEs (e.g. Visual Studio and JetBrains Rider) running dotnet format afterwards does not lead to similarly formatted code and hence unnecessarily large diffs in Pull Requests. For example Rider by default introduces line breaks after a max line length is reached where VS does not. Also Rider formats inline list/dict initializations different from VS.

I'm looking for a tool that

  • formats code uniformly
  • is IDE independent
  • is verifiable/enforcable in CI (e.g. Github Actions)
  • PS: In Python there is a tool called black - "The uncompromising code formatter". It is deterministic and promises "the smallest diffs possible". I want something like black but for C#. Apr 9 '21 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.