Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper multiline method invocation parenthesis alignment

Tags:

c#

resharper

Resharper is formatting multiline method calls like this:

foo.Bar(
    x,
    y
    );

I would prefer it to align the closing parenthesis with the first line e.g.:

foo.Bar(
    x,
    y
);

I've looked through the Resharper code layout options, but cannot see the right setting. Can someone tell me how to achieve this alternative formatting?

like image 971
Andrew Davey Avatar asked Sep 08 '11 18:09

Andrew Davey


3 Answers

In Visual Studio, go to Resharper > Options > Languages > C# > Formatting Style > Other > Indentation > Continuous line indent multiplier and set it to 0.

like image 57
SuperOli Avatar answered Nov 03 '22 19:11

SuperOli


Can I recommend you take a look at StyleCop, and then StyleCop for ReSharper?

StyleCop allows you to create exceptions or warnings for various types of formatting. The latter project, StyleCop for ReSharper allows ReSharper to automatically implement certain formats. There is quite a steep learning curve initially with SfR, but it is well worthwhile. This is a very under-used tool, and I wish Microsoft would advertise StyleCop more.

Both are Codeplex projects, and can be found at their respective URL's:

  • http://stylecop.codeplex.com/

  • http://stylecopforresharper.codeplex.com/

I hope this helps you out somewhat.

like image 1
csharpforevermore Avatar answered Nov 03 '22 18:11

csharpforevermore


In 2016.2 version appeared an option Intent method calls' parenthesis.

It does exactly what you expect:

screenshot

like image 1
lorond Avatar answered Nov 03 '22 17:11

lorond