问题描述
'ContractClassFor'辅助类的推荐命名约定是什么?
What is recommended naming convention for 'ContractClassFor' helper classes ?
2.9中的示例使用以下格式:
The sample in 2.9 uses the format:
抽象类I< interface-name>合同
abstract class I<interface-name>Contract
第4.1节使用格式:
类ContractFor< interface-name>
class ContractFor<interface-name>
与代码合同一起提供的大多数标准程序集似乎都使用2.9格式。这种格式会生成fxcop / stylecop警告,因为以"I"开头的名称是为接口类型而不是抽象类保留的。
Most of the standard assemblies that ship with code contract seem to use the 2.9 format. This format generates however fxcop/stylecop warnings as names starting with 'I' are reserved for interface types and not abstract classes.
  ;
推荐答案
由于此类永远不会被实例化,因此将其标记为抽象是个好主意,默认情况下使其符合StyleCop标准对我来说也是合理的。
Since this class is never gonna be instantiated then marking it abstract is good idea, making it StyleCop compliant by default does also sound reasonable for me.
BTW,您使用哪个版本的StyleCope?我使用v4.4.0并没有抱怨像"抽象类IPaymentServiceContracts"这样的类......
BTW, which version of StyleCope do you use? I use v4.4.0 and it doesn't complain about classes like "abstract class IPaymentServiceContracts"...
这篇关于建议为接口命名ContractClassFor辅助类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!