views:

751

answers:

10

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).

+4  A: 

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.

Dana the Sane
It doesn't work that well with C# though.
Sklivvz
+2  A: 

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, but hopefully someone will come along with a better answer :)

Lucas Richter
A: 

Second the Resharper suggestion. There are hundreds of other productivity boosts that will go along with it.

Jim
You should add such responses as a comment to the other answers. I believe that's why your post got downvoted.
Yaba
A: 

Take a look at Polystyle

jmatthias
A: 

For completeness, check out http://uncrustify.sourceforge.net/

Joel Lucsy
It doesn't work that well with C# though.
Sklivvz
A: 

Check out astyle. I am sure the KDE guys use it, but the website said that it supports C#.

+5  A: 

A bit late coming across this... 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.

James Nies
Thanks, I will take a look at it.
Antoine Aubry
A: 

I know this is an old post but I am going to second the ReSharper suggestion anyways. I can't live without it.

The built-in reformatting is under the ReSharper->Tools->Cleanup Code menu and is bound to Ctrl-E Ctrl-C by default.

rboarman
+1  A: 

I use emacs and csharp-mode. One keystroke and the module is reformatted according to my desires.

before:
alt text

after:
alt text

Cheeso
+1  A: 

See SD C# Formatter

Ira Baxter