Skip to content

Incorrect IDE0004 (Cast is redundant) in sign extended operations #20617

@sharwell

Description

@sharwell

Version Used: 15.3 Preview 3

🔗 Originally filed internally as bug 398604.

Steps to Reproduce:

Add the following method:

public static void MethodName()
{
    const long x = ~(long)~1U;
    switch (x)
    {
    case 1:
        var y = x;

    default:
        break;
    }
}

Expected Behavior:

IDE0004 is not reported, and no code fix tries to remove the cast to long.

Actual Behavior:

IDE0004 is reported. When the code fix removes the cast to long, the program no longer compiles.

Metadata

Metadata

Assignees

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