Skip to content

IDE0047 suggest removing parentheses, which leads to invalid code #80082

@Dreamescaper

Description

@Dreamescaper

Version Used:

Steps to Reproduce:

For the following code:

class Command: List<int>;

var commands = new[] {1,2,3,4,5,6,7,8 }
    .Chunk(3)
    .Select(chunk => (Command)([.. chunk]))
    .ToList();

IDE0047 suggest removing parentheses:

class Command: List<int>;

var commands = new[] {1,2,3,4,5,6,7,8 }
    .Chunk(3)
    .Select(chunk => (Command)[.. chunk])
    .ToList();

Which is invalid C# code.

Diagnostic Id:

IDE0047

Expected Behavior:

IDE0047 shouldn't suggest removing parentheses if that leads to invalid code.

Actual Behavior:

IDE0047 suggests removing parentheses when that leads to invalid code.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions