Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReSharper Formatting Ternary Operator in C#

Tags:

c#

resharper

This is driving me up the wall now. The ternary formatting options in ReSharper -> Options -> C# do not cover indentation, just spacing of '?' and ':' characters, and line chopping.

What I want is:

var x = expr1
      ? expr2
      : expr3;

But what I get is:

var x = expr1
? expr2
: expr3;

If the ternary operator formatting was offering no assistance, I thought that the Chained binary expressions may help, but no. That is set as follows.

var a = someOperand + operand2
        + operand3
        + operand4;

Any ideas?

like image 361
Chris Kemp Avatar asked Jan 29 '15 09:01

Chris Kemp


1 Answers

Try enabling ReSharper | Options | Code Editing | C# | Formatting Style | Other | Align Multiline Constructs | Expression

like image 168
Alexander Kurakin Avatar answered Sep 30 '22 19:09

Alexander Kurakin