How do I format so method parameters are stacked vertically, one per line?

Greg Smalter picture Greg Smalter · May 25, 2012 · Viewed 7.4k times · Source

I have a method that I want formatted like this:

public static IQueryable<ThingRequest> GetThings( this EntityContext one
                                                , int? two = null
                                                , int? three = null
                                                , int? four = null
                                                , int? five = null
                                                , String six = null 
                                                , IEnumerable<String> seven = null) {

Basically, if the method definition is going to exceed the length of line line, I'd like there to be one parameter per line. I'm not too concerned about the commas (if they appear at the end of each line instead, that's fine).

But R# formats it like this, instead:

public static IQueryable<ThingRequest> GetThings( this EntityContext one, int? two = null, int? three = null, int? four = null, int? five = null,
                                                  String six = null, IEnumerable<String> seven = null ) {

... so, it lines them up, but there are several parameters per line and it's just hard to pick out any one parameter.

Incidentally, when calling methods, it stacks arguments one-per-line if the max line length is exceed (even though, in that case, I'd almost prefer it didn't).

I've gone into R# options and explored there wide array of check boxes available, but I don't see how to improve my situation. Ideas?

Answer

Dmitry Osinovskiy picture Dmitry Osinovskiy · Jun 2, 2012

Try changing option from this path:

ReSharper | Options -> 
Code Editing | C# | Formatting style | Line breaks and Wrapping -> 
Line wrapping | Wrap formal parameters

to Chop always. I don't know if it is possible to place comma the way you want, but at least there would be one parameter per line. Good luck!