csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

ParenthesizedExpression breaking inconsistently

Open belav opened this issue 2 years ago • 1 comments

Having a single invocation on a ParenthesizedExpression that is too long causes it to break like below. It would look better if it stayed consistent with the second example.

(
    someObject as SomeLongType__________________________________________
).CallMethod();

(someObject as SomeLongType__________________________________________)
    .CallMethod()
    .CallMethod();

A potential solution is "never break ParenthesizedExpression unless its contents break"

belav avatar Jun 28 '23 19:06 belav

Sounds like a good rule. It's inconsistent and adds an additional line of code for just a single bracket!

The first example would look better as

(someObject as SomeLongType__________________________________________)
  .CallMethod();

Applying the same logic (don't break unless its contents break) to if (..), while (..), catch (..), (..) => would fix #924

jods4 avatar Aug 16 '23 20:08 jods4