小编tmo*_*ont的帖子

Contract class should be an abstract class

以下代码给出了警告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闭合.

我是否遗漏了一些没有警告的编译?

abstract-class code-contracts c#-4.0

7
推荐指数
1
解决办法
1756
查看次数

标签 统计

abstract-class ×1

c#-4.0 ×1

code-contracts ×1