Skip to content

CodeGeneration produces unnecessary parentheses #26586

@svick

Description

@svick

Version Used: master

Steps to Reproduce:

Attempt to run CodeGeneration tests like:

public void TestAddExpression1()
{
TestExpression(
f => f.CreateAddExpression(
f.CreateConstantExpression(1),
f.CreateConstantExpression(2)),
cs: "1 + 2",
vb: "1 + 2");
}

Expected Behavior: The test passes.

Actual Behavior:

Test Name:	Microsoft.CodeAnalysis.Editor.UnitTests.CodeGeneration.ExpressionGenerationTests.TestAddExpression1
Test FullName:	Microsoft.CodeAnalysis.Editor.UnitTests.CodeGeneration.ExpressionGenerationTests.TestAddExpression1
Test Source:	C:\code\roslyn\src\EditorFeatures\Test\CodeGeneration\ExpressionGenerationTests.cs : line 129
Test Outcome:	Failed
Test Duration:	0:00:04,771

Result StackTrace:	
at Roslyn.Test.Utilities.AssertEx.Fail(String message) in C:\code\roslyn\src\Test\Utilities\Portable\Assert\AssertEx.cs:line 341
   at Roslyn.Test.Utilities.TokenUtilities.AssertTokensEqual(String expected, String actual, String language) in C:\code\roslyn\src\Test\Utilities\Portable\Syntax\TokenUtilities.cs:line 45
   at Microsoft.CodeAnalysis.Editor.UnitTests.CodeGeneration.AbstractCodeGenerationTests.Test(Func`2 nodeCreator, String cs, String vb) in C:\code\roslyn\src\EditorFeatures\Test\CodeGeneration\AbstractCodeGenerationTests.cs:line 31
   at Microsoft.CodeAnalysis.Editor.UnitTests.CodeGeneration.ExpressionGenerationTests.TestAddExpression1() in C:\code\roslyn\src\EditorFeatures\Test\CodeGeneration\ExpressionGenerationTests.cs:line 131
Result Message:	
Unexpected token.  Actual '^(^ 1 ) + ' Expected '^1^ + 2  '
Actual:
(1) + (2)

The test failure seems to be caused by unnecessary parentheses.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-IDEBughelp wantedThe issue is "up for grabs" - add a comment if you are interested in working on it

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions