fix: Null coalescing not own its line with complex left-hand side
There was an issue where if the left-hand side of ?? was even slightly complex, the right-hand side would become part of the group and could not have its own line.
I reconsidered the conditions for grouping and changed it from judging the complexity of the left-hand side by a threshold to a condition where "the left-hand side is an InvocationExpression and consists solely of MemberAccessExpression that does not include an InvocationExpression".
fix #1769
Upon reviewing the PR that was created, I noticed there are some oversights. I'll work on the corrections later.
After reviewing the results in the csharpier-repos, I have added support for the following:
- ParenthesizedExpressionSyntax
- CastExpressionSyntax { Expression: ParenthesizedExpressionSyntax }
- ConditionalAccessExpressionSyntax
@belav I made additional changes thinking they would be an improvement, but perhaps they weren't? I would be grateful for your opinion. Thank you.
Taking a look at the changes it made I think everythink looks good except this one - https://github.com/belav/csharpier-repos/pull/159/changes/e097ff1d5ab4cfc42a3ca55c92ceb38e3bfbd6c3#diff-bb147afabd02afcf48b4b4c09aad50f6bb117fea0bae21a1b2f1adef34f16beb
Your first pass had ?? false on a new line but the most recent version keeps it on the same line.
I don't see a test case for it which is probably why it ended up being undone.
Was there something specific you didn't think was an improvement? I do like the way it groups it with the ending paren
) ?? result
Ideally I'd have an action for doing the formatting on csharpier-repos - I think I attempted it a while back and it wasn't super straightforward.
Added support for when the leftmost element is a parenthesized expression.