How to fix ternary operator formatting?

Hello,
I how do I fix the weird indentation for ternary operator?

The following code fragment:

                        Console.WriteLine(
                            multipart.IsBody ?
                            "Multipart body:" + multipart.Data :
                            "Attachment name=" + multipart.Name);



gets reformatted to this:

                        Console.WriteLine(
                            multipart.IsBody ?
                                                 "Multipart body:" + multipart.Data :
                                                                                        "Attachment name=" + multipart.Name);


I've looked at all the options in the Formatting Style menu but I don't see anything for the ternary operator that fixes this.

I am using R# 5.1.

Thank you!
3 comments

Hello Thomas
     This is a known problem, but it has not been addressed yet. We'll do our best to fix it in one of the upcoming releases.

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0

I have another result on my computer:

Before:

                              string anyStringAndSoOn = "aaa";
                              Console.WriteLine(
                                anyStringAndSoOn.Length > 2 ?
                                "Multipart body:" + anyStringAndSoOn :
                                "Attachment name=" + anyStringAndSoOn);

After ReSharper 5.1 formatting (Ctrl+E,Ctrl+F):

                              string anyStringAndSoOn = "aaa";
                              Console.WriteLine(
                                anyStringAndSoOn.Length > 2
                                  ? "Multipart body:" + anyStringAndSoOn
                                  : "Attachment name=" + anyStringAndSoOn);



I can live with that.

0

Please sign in to leave a comment.