Hm, apparently, the static analysis of Resharper is smarter than me .... The code in which I correctly get the "expression is always true" is a warning:
int[] someArray = new int[10]; while (someArray != null) { Foo(ref someArray); someArray.Bar(); }
I get a warning that someArray != null is redundant, which is why I, although Resharper misinterpreted the ref parameter, because someArray can actually be null. But this is not the reason that the warning is correct. Then the subtle fact plays: someArray is null, meaning that the invocation Bar method will NullReferenceException , and with this change the control thread so that the start of the while loop is not reached, so even when someArray to null in Foo, the warning is correct.
My mistake, and thank you all for your efforts.
source share