Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BinaryExpression - Possibly change the way parens are formatted #356

Closed
belav opened this issue Jul 17, 2021 · 3 comments
Closed

BinaryExpression - Possibly change the way parens are formatted #356

belav opened this issue Jul 17, 2021 · 3 comments

Comments

@belav
Copy link
Owner

belav commented Jul 17, 2021

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
Copy link
Owner Author

belav commented Jul 17, 2021

Another example

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

@belav
Copy link
Owner Author

belav commented Jul 17, 2021

Another example

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

@brikabrak
Copy link
Contributor

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.

@belav belav closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants