The analyzer has detected an error that has to do with assigning values to one and the same variable twice in a row, while this variable is not used in any way between the assignments.
Consider this example:
A = GetA();
A = GetB();
The 'A' variable being assigned values twice might indicate a bug. The code should have most probably looked like this:
A = GetA();
B = GetB();
Cases when the variable is used between the assignments are treated as correct and do not trigger the warning:
A = 1;
A = Foo(A);
The following is an example of the bug taken from a real-life application:
....
if (bool.TryParse(setting, out value))
_singleSignOn = value;
_singleSignOn = false;
....
A correct version of this code should look like this:
....
if (bool.TryParse(setting, out value))
_singleSignOn = value;
else
_singleSignOn = false;
....
The analyzer might output false positives sometimes. This happens when such variable assignments are used for debugging purposes. For example:
status = Foo1();
status = Foo2();
The false positive in this code can be handled in a number of ways:
This diagnostic is classified as:
You can look at examples of errors detected by the V3008 diagnostic. |
Was this page helpful?
Your message has been sent. We will email you at
If you do not see the email in your inbox, please check if it is filtered to one of the following folders:
Take
a chance!