Resharper formatting chained method
Asked Answered
M

1

10

Is there a setting in R# to format chained method to start at the same character of the class instantiated.

What I want:

var foo = new FooDataBuilder()
              .WithDate(myDate)
              .WithBar(myBar)
              .Build();

What R# is giving me:

var foo = new FooDataBuilder()
    .WithDate(myDate)
    .WithBar(myBar)
    .Build();
Madsen answered 16/3, 2013 at 14:2 Comment(1)
No, there is no such setting.Komi
G
16

With Resharper 7.1.2, you can get the following formatting:

var foo = new FooDataBuilder().WithDate(myDate)
                              .WithBar(myBar)
                              .Build();

By setting the following Resharper options:

Code Editing->C#->Formatting Style->Line Breaks and Wrapping->Line Wrapping->Wrap chained method calls to Chop always

and

enable Code Editing->C#->Formatting Style->Other->Align Multiline Constructs->Chained method calls

I don't think you can align with FooDataBuilder() unless you do it manually. (This has been confirmed by @Dmitry Osinovskiy from Jetbrains so this may be the closest you're going to get to what you want.)

Glair answered 16/3, 2013 at 18:54 Comment(1)
For ReSharper 2017.3 the section "Align Multiline Constructs" with the setting "Chained Method Calls" can be found under "Tabs, Indents, Alignment".Rough

© 2022 - 2024 — McMap. All rights reserved.