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

IDE0010: Populate Switch gives up with simple or pattern match #73245

Open
RenderMichael opened this issue Apr 26, 2024 · 2 comments
Open

IDE0010: Populate Switch gives up with simple or pattern match #73245

RenderMichael opened this issue Apr 26, 2024 · 2 comments
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@RenderMichael
Copy link

Version Used:
.NET 8.0.204

Steps to Reproduce:

public bool DummySwitch(Values value)
{
    switch (value)
    {
        case Values.One or Values.Two:
            return true;
        default:
            return false;
    }
}

enum Values
{
    One,
    Two,
    Three
}

Diagnostic Id:

IDE0010

Expected Behavior:

Warning: Populate switch

Actual Behavior:

No Warning

Additional Context

If you use the classic switch cases, the warning appears:

public bool DummySwitch(Values value)
{
    switch (value)
    {
        case Values.One:
        case Values.Two:
            return true;

        default:
            return false;
    }
}

enum Values
{
    One,
    Two,
    Three
}
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 26, 2024
@RenderMichael
Copy link
Author

I am happy to try and fix this myself, as long as this is desired behavior. The analysis for this can get arbitrarily complex, and there's gotta be a cutoff somewhere, especially for an analyzer this... minor. But the simple or case feels like a scenario which should be supported.

@CyrusNajmabadi
Copy link
Member

Sure! Go ahead :)

@genlu genlu added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it Concept-Continuous Improvement and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 30, 2024
@genlu genlu added this to the Backlog milestone Apr 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Continuous Improvement help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
None yet
Development

No branches or pull requests

4 participants