Code contracts work great until you have to add a bazillion Contract.Assume(...)
for the results coming out of framework code. For instance, MemoryStream.ToArray()
never returns a null array, as best as I can tell from looking at it in Reflector, but it's not documented as a contract, so I have to Assume
it everywhere.
Is there a magical way to create a contract library for functions which already exist? I'm guessing that once you got a few dozen of the most commonly used framework functions contracted out, the warnings would get much more palatable.