I’ve started using Microsoft’s Code Contracts and finding some interesting interactions with Code Analysis (aka fxCop), a feature of Visual Studio that I’m already using heavily.
When writing a method to check contract invariants, Code Contracts wants me to declare it as a private method
containing only calls to
However, Code Analysis sees this and tells me I shouldn’t have an uncalled private method.
Normally, the advice from Code Analysis is correct - but in this case, it needes suppressing like so: