【问题标题】:Code Analysis Microsoft.Naming warnings on the abbreviation "ID"代码分析 Microsoft.Naming 对缩写“ID”的警告
【发布时间】:2023-09-22 20:20:01
【问题描述】:

我在所有属性名和 sql 列名中都使用了 ID(大写)。现在我已经开始纠正所有代码分析警告,以在团队中强制执行新的编码准则。

有没有办法将 ID 添加到不会生成警告的字典中(例如 CA1709)?

示例 -

Warning 4   CA1709 : Microsoft.Naming : Correct the casing of 'ID' in member name 'City.CityID' by changing it to 'Id'.
'Id' is an abbreviation and therefore is not subject to acronym casing guideline.

【问题讨论】:

标签: c# .net code-analysis fxcop


【解决方案1】:

我最终将它添加到自定义词典中 - 它有效。谢谢阿拉斯泰尔·皮茨

<Dictionary>
  <Acronyms>
    <CasingExceptions>
      <Acronym>ID</Acronym>   <!-- Identifier -->
    </CasingExceptions>
  </Acronyms>
</Dictionary>

它还可以帮助我添加它抱怨的其他拼写 - 例如 facebook、twitter 等。

【讨论】:

    最近更新 更多