0

I'm not sure if my title is entire accurate, however, I would like to disable the feature in ReSharper formatting where it indents deep (?) upon formatting. The following image describes the behaviour (red = before format, green = after format)

: ReSharper formatting

As you can see the indentation for all the statements after the first line are indented very far.

var shouldSendMails = requester.Email != model.Email
    || requester.PhoneNumber != model.PhoneNumber
    || requester.Address != model.Address
    || requester.PostalCode != model.PostalCode
    || requester.City != model.City
    || requester.MedicalInformation != model.MedicalHistory;

Turns into

var shouldSendMails = requester.Email != model.Email
                    || requester.PhoneNumber != model.PhoneNumber
                    || requester.Address != model.Address
                    || requester.PostalCode != model.PostalCode
                    || requester.City != model.City
                    || requester.MedicalInformation != model.MedicalHistory;

I would like to disable this behaviour. So what I want is when I format the code, it does format the code, but without the 4 extra tabs before putting the new line of code there.

Any help would be greatly appreciated.

2
  • @DavidG that is the end of the statement, the picture shows a Git diff Commented Jun 26, 2017 at 14:01
  • Yeah, figured that out in the end :) Commented Jun 26, 2017 at 14:01

2 Answers 2

2

Shortly after posting the question I found the feature.

It is named "Align Multiline Constructs" and can be found here:

ReSharper -> Options -> C# -> Formatting Style -> Other -> Align Multiline Constructs.

For me, the option "Expression" was checked/enabled. Disabling this option fixed the problem for me.

Before disabling "Expression" option:

destination = source1
                  ? source2
                  : source3;

After disabling "Expression" option:

destination = source1
    ? source2
    : source3;
Sign up to request clarification or add additional context in comments.

Comments

0

That also fixes indent in LINQ extension methods.

Since I use EF a lot, it was incredibly annoying...

var invoice = this.context.Invoices
                  .Include(i => i.InvoiceLines)
                  .Where(i => ........................................)

Becomes like that after disabling:

var invoice = this.context.Invoices
    .Include(i => i.InvoiceLines)
    .Where(i => ........................................)

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.