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
The following code gets flagged by S2758: "This operation returns the same value whether the condition is 'true' or 'false'" (this code is part of a class that generates a code file)
This seems like a false positive. I think it returns either
"return this.somefieldname;"
or
"return this.somefieldname.Value;"
These are two different strings.
Evangelink
changed the title
Rule S2758: false positive on conditional operator with interpolated string
Fix S2758: false positive on conditional operator with interpolated string
Oct 13, 2017
We currently rely on Roslyn to detect whether the 2 parts are equals or not. The problem is that we are still using Roslyn 1.0 which doesn't handle interpolated strings hence this False Positive.
We are planning to move to newer versions of Roslyn soon (to support .Net Core) and so this ticket will be automatically fixed.
So I am closing the ticket as we won't do anything on older versions.
Description
The following code gets flagged by S2758: "This operation returns the same value whether the condition is 'true' or 'false'" (this code is part of a class that generates a code file)
This seems like a false positive. I think it returns either
"return this.somefieldname;"
or
"return this.somefieldname.Value;"
These are two different strings.
Repro steps
Source code to copy into project for scanning:
Expected behavior
No issue is created as this clearly returns two different strings.
Actual behavior
S2758: "This operation returns the same value whether the condition is 'true' or 'false'" is reported
Related information
The text was updated successfully, but these errors were encountered: