C# code formatting adding new line after ( and indenting to same column

When Resharper formats my C# code if it decides a line is too long, it frequently will add a new line after ( and then indent the following line to the same column as it would have been at without the new line. What it does is this:

         () =>

And what I'd like is this:

A.CallTo(() =>

My settings are Prefer wrap after "(" in * off for all and Wrap chained method calls is set to Chop if long. It seems as though the chopping is happening from the end, rather than the beginning of the line. I'd rather only chop if the line extends beyond e.g. 80 and then start by wrapping the outer chained methods first, then parameters, then chained methods in parameters, then parameters, then chained methods in parameters, etc.

Is there some setting to at least get Resharper to stop inserting the new lines after ( if it's just going to go and indent the next line to the same column it would have been at if the line hadn't been broken?



Comment actions Permalink

Hello Colin,

  Please try untincking ReSharper | Options | Code Editing | C# | Formatting Style | Other | Align Multiline Constructs | "First call argument by '('" and "Call arguments". It won't provide exactly the same formatting as you desired but I guess it will be looks a little bit better than now.


Comment actions Permalink

You're right, that is a bit better, but not what I'm looking for. Here's another example of some of the odd choices it makes:

VS Formatting.png
The red arrows indicate the redundant (to me) new lines, the blue show where things get truly bizarre because those choices actually result in a longer line and the green shows where I think it should have elected to place a new line.

A nice feature would be the ability to force things like <, [, (, etc. to never have a new line after and >, ], ), etc. to never have a new line before, even if that results in exceeding the max column. This is what I'd really like it to end up like:

VS Formatting 2.png


Please sign in to leave a comment.