This is the internal definition of the System.Object contract code: (link) . As you can see, they defined ToString() with this restriction:
Contract.Ensures(Contract.Result<string>() != null);
To answer your question, Code Contracts knows that it is not null due to the definition of an internal contract.
Amy
source share