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

IDE0046: 'if' statement can be simplified #60859

Open
wstaelens opened this issue Apr 20, 2022 · 1 comment
Open

IDE0046: 'if' statement can be simplified #60859

wstaelens opened this issue Apr 20, 2022 · 1 comment
Assignees
Labels
Area-IDE Concept-Continuous Improvement Feature - IDE0046 Use conditional expression help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@wstaelens
Copy link

Version Used: Visual Studio 17.2.0 Preview 3.0

Steps to Reproduce:

        public override object ConvertFieldValueForStorage(object value)
        {
            if (value is Product vfetval)
            {
                return (decimal)vfetval.ID;
            }
            else
            {
                return -1m;
            }
        }

Convert to conditional expression --> IDE0046: 'if' statement can be simplified

Expected Behavior:

       return value is Product vfetval ? (decimal)vfetval.ID : -1m;

Actual Behavior:

       return value is Product vfetval ? (decimal)vfetval.ID : (object)-1m;

(object) cast is being added, while this doesn't seem to be needed.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Apr 20, 2022
@jinujoseph jinujoseph added Bug 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 Bug labels Apr 28, 2022
@jinujoseph jinujoseph added this to the Backlog milestone Apr 28, 2022
@CyrusNajmabadi CyrusNajmabadi added the Feature - IDE0046 Use conditional expression label Nov 1, 2022
@github-project-automation github-project-automation bot moved this to InQueue in Small Fixes Oct 22, 2024
@CyrusNajmabadi
Copy link
Member

We would take a small community pr for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Concept-Continuous Improvement Feature - IDE0046 Use conditional expression help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Projects
Status: InQueue
Development

No branches or pull requests

5 participants