Is there a tool for reformatting C# code? [closed]
Asked Answered
D

10

11

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

Daph answered 26/8, 2008 at 2:4 Comment(0)
D
5

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.

Dendrochronology answered 6/1, 2009 at 23:21 Comment(0)
L
4

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.

Loveinidleness answered 26/8, 2008 at 2:15 Comment(1)
It doesn't work that well with C# though.Trifid
D
3

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.

Dirigible answered 26/8, 2008 at 2:16 Comment(0)
I
1

Take a look at Polystyle

Intro answered 26/8, 2008 at 2:39 Comment(0)
D
1

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

Before:

Alt text

After:

Alt text

Dr answered 9/5, 2010 at 11:23 Comment(0)
P
1

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.

Politics answered 8/7, 2010 at 10:5 Comment(0)
K
0

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

Kalgan answered 26/8, 2008 at 23:55 Comment(1)
It doesn't work that well with C# though.Trifid
P
0

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

Platoon answered 29/9, 2008 at 21:23 Comment(0)
R
0

I am going to second the ReSharper suggestion. I can't live without it.

The built-in reformatting is under ReSharper → ToolsCleanup Code menu and is bound to Ctrl + E, Ctrl + C by default.

Runty answered 21/4, 2010 at 19:37 Comment(0)
P
0

Maybe you could take a look at this free Addin for Visual Studio 2010/2012 i recently wrote :)

Pemphigus answered 22/9, 2013 at 16:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.