Code contracts guarantee external external support for ReSharper

Does anyone know how to add code contracts to ReSharper ExternalAnnotations? It is not there in the latest v7.1.3, nor in the latest v8 EAP, nor in any of the custom xmls floating around.

In particular, it should detect if the method does not return null: Contract.Ensures(Contract.Result<T>() != null);

+3
source share
1 answer

If you are trying to just calm the analysis mechanism, the easiest thing to use is [NotNull] before declaring the method. The contract annotations you linked to above are a more powerful mechanism for defining the relationship between the input parameters and the return value, for example, [ContactAnnotation("null => null")] .

However, explicit analysis for the Contract.Ensures operator is a completely different proposition, because you cannot define automatic analysis for this operator through [ContractAnnotation] or any other ReSharper annotation attribute.

+4
source

Source: https://habr.com/ru/post/1481781/


All Articles