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

Unnecessary parenthesis check is incompatible with is operator #2790

Closed
abatishchev opened this issue Sep 20, 2018 · 1 comment
Closed

Unnecessary parenthesis check is incompatible with is operator #2790

abatishchev opened this issue Sep 20, 2018 · 1 comment
Labels

Comments

@abatishchev
Copy link
Contributor

Having the following expression:

var obj = new GetSome();
if (!(obj is null))
{
}

I'm getting a suggestion:

Statement must not use unnecessary parenthesis.

Removing the parenthesis:

var obj = new GetSome();
if (!obj is null)
{
}

leads to a compiler error:

Error CS0023 Operator '!' cannot be applied to operand of type 'Foo'

The version I'm using:

<PackageReference Include="StyleCop.Analyzers" Version="1.0.2" PrivateAssets="All" />
@vweijsters
Copy link
Contributor

The obj is null is a C# 7 language construct. StyleCop.Analyzers 1.0.2 does not support c# 7, 1.1.0-beta releases are meant for that.

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

No branches or pull requests

2 participants