Question

I am currently looking into the code contracts of the .NET framework. What I'd like to do is to use those contracts, while avoiding that my coworkers are forced to install the required extensions for Visual Studio and continue there work as is.

Aber setting up some methods with the contracts and receive a message from the executed application that the CONTRACT_FULL symbol is defined but the rewriter was not called. I checked my entire project and this symbol is not defined anywhere. Where is this definition coming from and how do I get rid of it?

This error disappears of cause in case in activate the contract rewriter, but as I said I like to avoid the need to install this rewriter.

Was it helpful?

Solution

The rest of the message probably states that you are using Contract.Requires< TException >.

As the documentation states, you have to enable runtime checking when using Contract.Requires<TException>. The reason is that your code's execution depends on Contract.Requires<T> throwing the expected exception if it pre-condition fails.

On the other hand, Contract.Requires(Boolean) only defines a precondition and doesn't affect your program's execution. At most, it will display an annoying Assertion message when it's pre-condition fails. No rewriting is necessary in this case.

The message is a bit misleading as the error is caused even when you don't enable Full runtime contract checking.

To fix this, you'll have to install the rewriter on all machines, or switch to using Contract.Requires(Boolean).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top