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

SA1119 incorrectly reporting on pattern matching (is expression) #2372

Closed
nbarbettini opened this issue Jun 1, 2017 · 3 comments
Closed
Assignees
Milestone

Comments

@nbarbettini
Copy link
Contributor

Given this code:

object obj = null;

if (!(obj is string foo))
{
    // do something with foo
}

SA1119 reports the parenthesis as unnecessary (they are necessary). The code fix removes the parenthesis, resulting in syntax that won't compile:

if (! obj is string foo)
{
    // do something with foo
}

It would appear SA1119 is reaching for the proposed is not or aint operator. 😉

@nbarbettini
Copy link
Contributor Author

This should be part of #2268 since it's caused by a new C# 7 feature (is-expression pattern matching).

@sharwell sharwell added the c# 7 label Jun 8, 2017
@sharwell
Copy link
Member

sharwell commented Jun 8, 2017

This particular pattern should already be covered by the light-up functionality in #2370, allowing someone to branch off that work and correct this issue.

@sharwell sharwell self-assigned this Jun 16, 2017
@sharwell sharwell added this to the 1.1.0 Beta 4 milestone Jun 16, 2017
@sharwell sharwell added the bug label Jun 16, 2017
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jun 16, 2017
sharwell added a commit to sharwell/StyleCopAnalyzers that referenced this issue Jun 17, 2017
@AdjutantML
Copy link

Thank you for fixing this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants