The following code gives me the warning Contract class 'FooContracts' should be an abstract class
. From all the examples I've read online (e.g. http://www.infoq.com/articles/code-contracts-csharp), this should work (presumably without compiler warnings).
[ContractClass(typeof(FooContracts))]
public interface IFoo {
void Bar(string foo);
}
[ContractClassFor(typeof(IFoo))]
internal sealed class FooContracts : IFoo {
void IFoo.Bar(string foo) {
Contract.Requires(foo != null);
}
}
I'm in Visual Studio 2010, with the following settings in the Code Contracts
section of the project's properties:
Full
)Static Checking
)I also defined the CONTRACTS_FULL
compilation symbol to make ReSharper shut up.
Am I missing something to make this compile without warnings?
Section 2.8 of the code contracts manual specifically states that it should be an abstract class:
The tools expect that the contract class is abstract and implements the interface it is providing contracts for.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With