gpt4 book ai didi

c# - 如何让 FxCop 理解 'multi-case' 字?

转载 作者:太空宇宙 更新时间:2023-11-03 10:51:02 25 4
gpt4 key购买 nike

我在一家公司工作,他们的首字母缩略词类似于 XyZ(大写后跟小写而不是再大写)。

这个词遍布我们所有的命名空间。当我针对我们的项目运行 FxCop 时,它会提示 IdentifiersShouldBeCasedCorrectly ( CA1709 )。建议只将第一个字母大写(我不想要的)。

我如何让 FxCop 理解单词 XyZ 已知、拼写正确且大小写正确? (换句话说,写得很好)

I added the word to the CustomDictionary.xml 文件:I've added to Recognized words; 无法识别 单词;以及带有 CasingExceptionsAcronyms。这些都没有任何效果。

我还验证了 FxCop 确实在读取自定义词典文件,当我在首字母缩略词中添加另一个词时,它不再像预期的那样报告为大小写错误(但仅适用于所有大写词)。

我在 C# 项目中使用 FxCop 1.36(GUI 版本)。


更新

仅将 Xy 添加到套管异常中似乎可以使 FxCop 按我的意愿忽略 XyZ

仍然不是一个很好的解决方案,因为当(唯一)正确的单词是 XyZ 时,它会允许错误的单词,例如 XyXXyW

最佳答案

您可以将 XyZ 添加到 FxCop 字典中 - 参见 How to: Customize the Code Analysis Dictionary .

Code Analysis uses a built-in dictionary to check identifiers in your code forerrors in spelling, grammatical case, and other naming conventions of the .NETFramework guidelines. You can create a custom dictionary Xml file to add, remove, or modify terms, abbreviations, and acronyms to the built-in dictionary.

Dictionary/Acronyms/CasingExceptions/Acronym

<Dictionary>
<Acronyms>
<CasingExceptions>
<Acronym>NESW</Acronym> <!-- North East South West -->
...
</CasingExceptions>
...
</Acronyms>
...
</Dictionary>

Dictionary/Acronyms/CasingExceptions 节点中的术语应用于以下代码分析规则:

CA1709: Identifiers should be cased correctly

关于c# - 如何让 FxCop 理解 'multi-case' 字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21405171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com