下面的代码给了我警告Contract class 'FooContracts' should be an abstract class
。从我在线阅读的所有示例(例如http://www.infoq.com/articles/code-contracts-csharp)中,这应该可以工作(大概没有编译器警告)。
[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);
}
}
我在 Visual Studio 2010 中,Code Contracts
在项目属性部分具有以下设置:
- 执行运行时契约检查(设置为
Full
) - 执行静态合约检查(下
Static Checking
) - 签入后台
我还定义了CONTRACTS_FULL
编译符号以使 ReSharper 闭嘴。
我是否遗漏了一些东西来使这个编译没有警告?