If you're attempting to simply appease the analysis engine, the simplest thing to use is [NotNull]
in front of the method declaration. The Contract Annotations to which you posted a link above is a more powerful mechanism for defining relationships between input parameters and the return value, e.g., [ContactAnnotation("null => null")]
.
However, explicitly analyzing for a Contract.Ensures
statement is an entirely different proposition, as no automatic analysis can be defined for this statement via [ContractAnnotation]
or any other ReSharper annotation attribute.