Description
Do not use is not { }.
This code is confusing, and 99% of the time can be refactored into more readable and less obfuscated code.
In the (very)rare case that this is cleaner, it can be accepted.
Noncompliant code snippet
if(SomeMethod() is not { } token) // Noncompliant
{
DoSomethingWithoutToken();
}
DoSomethingWithToken(token);
Compliant code snippet
if(SomeMethod() is { } token) // Compliant
{
DoSomethingWithToken(token);
}
DoSomethingWithoutToken();
Description
Do not use
is not { }.This code is confusing, and 99% of the time can be refactored into more readable and less obfuscated code.
In the (very)rare case that this is cleaner, it can be accepted.
Noncompliant code snippet
Compliant code snippet