I'm trying to use Contract.ForAll
, and it looks like I'm missing something here.
Consider this small example:
var l = new List<string>();
Contract.Assume( Contract.ForAll( l, s => s != null ) );
foreach ( var s in l ) Console.WriteLine( s.Length );
Despite the Contract.Assume
call, I do get a "possible calling a method on a null reference" warning for s.Length
.
Am I doing this right? Is it even supposed to work? Or am I missing something?