I'm running into a false warning problem (first saw it in ReSharper 8 and still exists in 8.0.1 EAP). This error did not occur in 6.6. It is difficult to reproduce so I haven't been able to build a small test case for it, unfortunately. Hopefully someone else can reproduce it too. My code looks like this:
public partial class MyForm : Form
private readonly bool _flag; // false warning is shown here
public MyForm(bool flag)
_flag = flag;
private void MyForm_Load(object sender, EventArgs e)
// Lots of various form and control initialization occurs here. Nothing fancy but there needs to be at least 40+ lines of code here for the issue to occur.
someControl.Enabled = _flag;
There are a few strange things here. The problem only occurs when there is a good amount of code ahead of the first (and only) usage of the '_flag' field. If I move it up closer to the beginning of the MyForm_Load method, then the warning goes away. Also, changing some of the code that appears before the _flag usage also seems to affect this bug. That is, if I had something like 'field.Enabled = otherField.Enabled' and then changed it to something like 'field.Enabled = false' then the issue may disappear. This is quite odd since the '_flag' field isn't involved with this other code at all. It seems there is some condition(s) that is causing the ReSharper analyzer to get confused. Lastly, if I took ReSharper's suggested fix of 'Convert to local variable' that produces uncompilable code as the '_flag' field is no longer available in the MyForm_Load method. It is as if ReSharper can no longer see the usage of '_flag' in MyForm_Load when there is a lot of code ahead of it or something. Very weird, hopefully this can be fixed for 8.0.1.