Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper settings for method chaining

Is it possible to configure resharper to chop all methods in a method chain

e.g.

var query = list.Where(x => true).Select(x => x);

becomes

var query = list
            .Where(x => true)
            .Select(x => x);

If not, then is it possible to configure resharper to ignore method chains when formatting? So I can chop the text manually without having to worry about resharper re-formatting it.

like image 595
stevev Avatar asked Oct 22 '22 13:10

stevev


1 Answers

Unfortunately, there is no way to align .Where under list.

As for chopping, there is an option in ReSharper | Options -> Code Editing | C# | Formatting Style | Line Breaks and Wrapping -> Line Wrapping called Wrap chained method calls. If you set it to Chop always, it would chop, but it uses a slightly different formatting:

var query = list.Where(x => true)
                .Select(x => x);

If you leave it to Chop if long (default value), then it wouldn't re-chop your code unless it would be very long (more than Right margin option, which is in the same option group mentioned above).

like image 159
Dmitry Osinovskiy Avatar answered Dec 19 '22 06:12

Dmitry Osinovskiy