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
A bit of an exotic error. The following conditional expression
var isSuccess = y is ISuccessEvaluator evaluator ? evaluator.Evaluate(result) : true;
results in a S1125 warning "remove the unnecessary boolean literal(s)" . The suggested code fix would result in:
var isSuccess = !y is ISuccessEvaluator evaluator || evaluator.Evaluate(result);
which produces a compiler error "! cannot be applied to operand of type "[whatever type y is]".
Expected behavior
var isSuccess = !(y is ISuccessEvaluator evaluator) || evaluator.Evaluate(result);
is the code fix that will not throw a compiler error. The braces are necessary in this instance because otherwise the compiler will try to apply the negation to type y which is not a bool.
Known workarounds
Add the braces manually after applying the code fix
Related information
SonarC# Version 7.16.0.8981
Visual Studio Version VS 2019 Version 16.2.0 Preview 3.0
The text was updated successfully, but these errors were encountered:
Description
A bit of an exotic error. The following conditional expression
var isSuccess = y is ISuccessEvaluator evaluator ? evaluator.Evaluate(result) : true;
results in a S1125 warning "remove the unnecessary boolean literal(s)" . The suggested code fix would result in:
var isSuccess = !y is ISuccessEvaluator evaluator || evaluator.Evaluate(result);
which produces a compiler error "! cannot be applied to operand of type "[whatever type y is]".
Expected behavior
var isSuccess = !(y is ISuccessEvaluator evaluator) || evaluator.Evaluate(result);
is the code fix that will not throw a compiler error. The braces are necessary in this instance because otherwise the compiler will try to apply the negation to type
y
which is not a bool.Known workarounds
Add the braces manually after applying the code fix
Related information
The text was updated successfully, but these errors were encountered: