Given the following code:
class MyControl : Control
public void DoIt()
if (_foo != null)
Contract.Assert(_foo != null);
protected override void OnGotMouseCapture(MouseEventArgs e)
_foo = this;
ReSharper (5.1.1708.23) will flag the Contract.Assert expression as "expression is always true". Yet that's not the case - CaptureMouse may result in OnGotMouseCapture being called, which will set the flag.
Strangely, if I switch to Debug.Assert the warning goes away.