You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Starting with c# 7.0 the is keyword can be used with a constant pattern as an alternative to == or .Equals(). This is not yet covered by the S1125 rule
Repro steps
var x = false;
if (x == true)
{
// S1125 warning
}
if (x is true)
{
// no S1125 warning
}
Expected behavior
Both of the above statements should get the S1125 warning since they're equivalent
Actual behavior
Only the first statement gets the warning
Known workarounds
None
The text was updated successfully, but these errors were encountered:
For nullable value type bool?, the is true or is false does also a null check.
cristian-ambrosini-sonarsource
changed the title
S1125 should recognize "is" keyword with constant pattern
Fix S1125 FN: recognize "is" keyword with constant pattern
Jul 25, 2023
Description
Starting with c# 7.0 the
is
keyword can be used with a constant pattern as an alternative to==
or.Equals()
. This is not yet covered by the S1125 ruleRepro steps
Expected behavior
Both of the above statements should get the S1125 warning since they're equivalent
Actual behavior
Only the first statement gets the warning
Known workarounds
None
The text was updated successfully, but these errors were encountered: