Is there a way to get resharper to align invocations of secondment methods in a certain way

Say I have the following code in C #

var stringList = GetListOfStrings(); var firstString = stringList.Where(s => true) .Where(s => true) .Where(s => true) .FirstOrDefault(); 

It's not very much, but it is formatted the way I like it using the ReSharper function and Resharpers Code Cleanup.

Now let's say that I rewrite this code to just call the GetListOfStrings method without first assigning it to a variable. In this situation, Resharper formats it as follows:

  var firstString = GetListOfStrings() .Where(s => true) .Where(s => true) .Where(s => true) .FirstOrDefault(); 

Is there a way to change this so that ReSharper formats it as shown below:

  var firstString = GetListOfStrings().Where(s => true) .Where(s => true) .Where(s => true) .FirstOrDefault(); 

I use a preview of ReSharper 8 Beta and VS 2013, if that matters.

+4
source share
2 answers

I think you're looking for the "Chained Method Calls" option in the "Align Multiline Constructs" header here:

enter image description here

+6
source

With Resharper, you can use the following options:

Code EditingC#Formatting StyleLine Breaks and WrappingLine WrappingWrap chained method calls to Chop always

and

enable Code EditingC#Formatting StyleOtherAlign Multiline ConstructsChained method calls

+6
source

Source: https://habr.com/ru/post/1490561/


All Articles