StyleCop使用Gets or Sets ...它通过规则SA1623强制执行的符号
我的问题是,为什么,从我可以看到的绝大多数时间它是自我解释的,并需要大量的重复才能拥有这些?
/// <summary>
/// Gets or sets the name of the customer
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets whether the record is archived
/// </summary>
public string IsArchive{ get; set; }
Run Code Online (Sandbox Code Playgroud)
它也可以使它过于冗长,当你只有10行,每一行声明一个属性时,你最终会有30多行来对每个行进行总结评论!
StyleCop规则不是绝对的,而是指导方针.一般来说,这是一个很好的规则,但在某些情况下是的,属性很简单,文档可能有点过分.例如
class Student {
public string FirstName { get; set; }
public string LastName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
对这些属性的评论确实没有增加任何价值,因为它们非常具有描述性.
我非常喜欢在项目中使用StyleCop.但这并不意味着你必须采取它附带的每一条规则.禁用那些对您的项目没有意义的项目并接受那些项目
| 归档时间: |
|
| 查看次数: |
249 次 |
| 最近记录: |