Skip to content

AddParens only if it is not already a ParenthesizedExpressionSyntax #1146

Closed
@LucTremblay

Description

@LucTremblay

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);
    }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions