I am looking for a (preferably) command-line tool that can reformat the C# source code on a directory tree. Ideally, I should be able to customize the formatting. Bonus points if the tool can be run on Mono (or Linux).
You could also try NArrange to reformat your code. The formatting options it supports are still pretty limited, but it can process an entire directory and is a command-line tool. Also, NArrange runs under Mono.
You could give Artistic Style a try. It requires Perl to be installed though.
It's got a decent list of formatting options, and supports C and Java as well.
This isn't command-line, Mono or Linux, but it's something: I've been using ReSharper (made by JetBrains) and it's rather good. It's a Visual Studio plugin, so I'm guessing it's not your cup of tea.
I use Emacs and csharp-mode. One keystroke and the module is reformatted according to my desires.
Before:
After:
See our SD C# Formatter. Uses a full C# parser and prettyprinter; it will not break your code.
EDIT: September, 2013: Now runs on Windows and Linux. Covers C# v5.
For completeness, check out http://uncrustify.sourceforge.net/
Check out astyle. I am sure the KDE guys use it, but the website said that it supports C#.
I am going to second the ReSharper suggestion. I can't live without it.
The built-in reformatting is under ReSharper → Tools → Cleanup Code menu and is bound to Ctrl + E, Ctrl + C by default.
Maybe you could take a look at this free Addin for Visual Studio 2010/2012 i recently wrote :)
© 2022 - 2024 — McMap. All rights reserved.