以下代码给出了警告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);
}
}
Run Code Online (Sandbox Code Playgroud)
我在Visual Studio 2010中,Code Contracts
在项目属性的部分中具有以下设置:
Full
)Static Checking
)我还定义了CONTRACTS_FULL
编译符号以使ReSharper闭合.
我是否遗漏了一些没有警告的编译?