Code analysis does not show CA1804 warning despite unused local string variable in C # (VS2010 Premium)

I have the following code that does not raise warning CA1804 (declared variable is never used) from code analysis (VS2010 Premium):

...
if( boolVariable )
{
    string errorText = "Bla Bla Bla"; // Never used
    ErrorProvider.SetError( SomeControl, "Some Warning" );
}
else
{
    string errorText = "Acme Acme Acme"; // Used below
    ErrorProvider.SetError( SomeControl, errorText );
}
...

When I delete the ErrorProvider.SetError (...) lines, warning CA1804 is displayed, but why is this not the case in the code example above?

(Btw: the code itself is not too large and just shown to illustrate my question.)

, ? , , IL , if, , , , , , , .

G.

+5
1

- , #. IL if:

string errorText;
if (boolVariable)
{
    errorText = "Bla Bla Bla";
    this.ErrorProvider.SetError(this.SomeControl, "Some Warning");
}
else
{
    errorText = "Acme Acme Acme";
    this.ErrorProvider.SetError(this.SomeControl, errorText);
}

SetError CA1804.

BTW, # CS0219, , -, . , , , , , Code Analysis. , , ?

+3

All Articles