Is there an automatic code formatter for C#?

Question :

Is there an automatic code formatter for C#?,

Answer :

In my work I deal mostly with C# code nowadays, with a sprinkle of java from time to time. What I absolutely love about Eclipse (and I know people using it daily love it even more) is a sophisticated code formatter, able to mould code into any coding standard one might imagine. Is there such a tool for C#? Visual Studio code formatting (Crtl+K, Crtl+D) is subpar and StyleCop only checks the source without fixing it.

My dream tool would run from console (for easy inclusion in automated builds or pre-commit hooks and for execution on Linux + Mono), have text-file based configuration easy to store in a project repository and a graphical rule editor with preview – just like the Eclipse Code Formatter does.

Read More  Domain Specific Language resources

,

For Visual Studio, take a look at  It’s an awesome tool and a definite must-have. Versions after 4.0 have the code formatting and clean-up feature that you are looking for. There’s also including formatting settings file.

You’ll probably want  as well, for spell-checking the identifiers and comments. ReSharper supports per-solution formatting setting files, which can be checked into version control system and shared by the whole team. The keyboard shortcut for code cleanup is Ctrl + E, C.

In ‘vanilla’ Visual Studio, the current file can be automatically formatted with Ctrl + K, Ctrl + D, and Ctrl + K, Ctrl + F formats the selected text.

Read More  Giving class unique ID on instantiation: .Net

As for a runs-everywhere command line tool to be used with commit hooks, try . It’s free, can process whole directories at once and runs on Mono as well as on Microsoft .NET.

Some people also use the command line tool, although it requires Perl and works better with C/C++ code than with C#.

That’s the answer Is there an automatic code formatter for C#?, Hope this helps those looking for an answer. Then we suggest to do a search for the next question and find the answer only on our site.

Read More  Accessing audio/video metadata with .NET

Disclaimer :

The answers provided above are only to be used to guide the learning process. The questions above are open-ended questions, meaning that many answers are not fixed as above. I hope this article can be useful, Thank you