csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

BinaryExpression - Possibly change the way parens are formatted

Open belav opened this issue 4 years ago • 3 comments

Currently csharpier formats this way

        if (
            string.Equals(
                node.BoundAttribute.TypeName,
                ModelExpressionTypeName,
                StringComparison.Ordinal
            )
            || (
                node.IsIndexerNameMatch
                && string.Equals(
                    node.BoundAttribute.IndexerTypeName,
                    ModelExpressionTypeName,
                    StringComparison.Ordinal
                )
            )
        ) { }

Prettier formats the same thing this way

if (
  string.Equals(
    node.BoundAttribute.TypeName,
    ModelExpressionTypeName,
    StringComparison.Ordinal
  ) ||
  (node.IsIndexerNameMatch &&
    string.Equals(
      node.BoundAttribute.IndexerTypeName,
      ModelExpressionTypeName,
      StringComparison.Ordinal
    ))
) {
}

Should csharpier do something similar? The prettier method doesn't seem consistent with other parens that are formatted, but it does keep the line count down.

belav avatar Jul 17 '21 16:07 belav

Another example

        var x =
            (
                cbPasswordBuffer
                || Constants.MAX_STACKALLOC_BYTES_____________________________________________
            )
            && true;

belav avatar Jul 17 '21 16:07 belav

Another example

                    if (
                        (
                            resourceClients.Length == 1
                            && resourceClients[0]
                                == ApplicationProfilesPropertyValues.AllowAllApplications
                        )
                        || resourceClients.Contains(client.ClientId)
                    ) {
                        client.AllowedScopes.Add(identityResource.Name);
                    }

belav avatar Jul 17 '21 16:07 belav

I think I prefer the way csharpier does things currently. The parentheses and line breaks seem more logical and readable that way, which I'd personally prioritize over (within reason) line savings.

brikabrak avatar Jul 23 '21 04:07 brikabrak