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

Add Use pattern matching analyzer/codefix for property patterns #65613

Open
DoctorKrolic opened this issue Nov 25, 2022 · 0 comments
Open

Add Use pattern matching analyzer/codefix for property patterns #65613

DoctorKrolic opened this issue Nov 25, 2022 · 0 comments
Labels
Area-IDE Feature Request help wanted The issue is "up for grabs" - add a comment if you are interested in working on it
Milestone

Comments

@DoctorKrolic
Copy link
Contributor

It would be nice, if VS could offer to use pattern matching for code like this:

using System.Text;

var cl = new MyClass();

if (cl.MyProperty is string ||
    cl.MyProperty is StringBuilder)
{

}

class MyClass
{
    public object MyProperty { get; set; }
}

or this:

using System.Text;

var cl = new MyClass();

if (cl.MyProperty is string ||
    cl is { MyProperty: StringBuilder })
{

}

class MyClass
{
    public object MyProperty { get; set; }
}

The expected end result looks like:

using System.Text;

var cl = new MyClass();

if (cl is { MyProperty: string or StringBuilder })
{

}

class MyClass
{
    public object MyProperty { get; set; }
}

Real-world usage case where this could be helpful: #65249 (comment)

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Issues and PRs which have not yet been triaged by a lead label Nov 25, 2022
@DoctorKrolic DoctorKrolic changed the title Expand Use pattern matching analyzer/codefix to suggest property patterns Expand Use pattern matching analyzer/codefix to suggest complex property patterns inferred from several conditions Nov 26, 2022
@DoctorKrolic DoctorKrolic changed the title Expand Use pattern matching analyzer/codefix to suggest complex property patterns inferred from several conditions Add Use pattern matching analyzer/codefix for property patterns Jan 12, 2023
@ryzngard ryzngard added help wanted The issue is "up for grabs" - add a comment if you are interested in working on it and removed untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 18, 2023
@ryzngard ryzngard added this to the Backlog milestone Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE Feature Request 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

2 participants