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

AddParens only if it is not already a ParenthesizedExpressionSyntax #1146

Closed
LucTremblay opened this issue Oct 31, 2024 · 1 comment
Closed

Comments

@LucTremblay
Copy link
Contributor

Hello

While debugging the code, we can see a lot of unneeded parenthesis are added to the converted code.

A lot of parenthesis are directly over another set of parenthesis and they seems to be added by the AddParens method.

Those extra parenthesis seems unneeded and makes debugging harder (to me at least).

The fix is simple and it also could help a bit to speed up the simplification phase, what do you thing?
1ed28ce

    public static ExpressionSyntax AddParens(this ExpressionSyntax expression)
    {
        if (expression is ParenthesizedExpressionSyntax)
            return expression;
        return SyntaxFactory.ParenthesizedExpression(expression);
    }
@GrahamTheCoder
Copy link
Member

Feel free to PR, just check if another similar method already exists.

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