在 TeamCity 中全局禁用 FxCop 错误

发布于 2024-08-27 01:16:37 字数 519 浏览 3 评论 0原文

好的,今天还有一个 FxCop 问题。

我已经阅读了有关 IdentifiersShouldBeCasedCorrectly 规则的争论,以及它是否应该是“XML”或“Xml”。嗯,我是一个“XML”人,并且我想保持这种状态。因此,我希望 FxCop 一直纠正我。

我仅在特定情况下使用 SuppressMessage 属性。我还使用 FxCop 标记大量错误,并将它们作为“模块”级 SuppressMessage 语句复制到 assemblyinfo.cs 中。这效果很好。

但是,现在我真的想全局禁用这个烦人的 IdentifiersShouldBeCasedCorrectly 规则。我正在使用 TeamCity 5.0.3,并且没有使用 FxCop 项目文件(但是,我可以执行此操作)。我希望可以向 FxCopCmd 传递一个参数来告诉它忽略此错误,但从文档中看起来并非如此。

那么...除了在 TeamCity 构建服务器上创建 FxCop 项目文件并将其用于 FxCop 构建运行程序之外,我还能做些什么吗?

Ok, another FxCop question for today.

I've read the arguments regarding the IdentifiersShouldBeCasedCorrectly rule, and whether or not it should be "XML" or "Xml". Well, I'm an "XML" guy and I want to stay that way. Therefore, I do not want FxCop to correct me all of the time.

I have been using the SuppressMessage attribute only for specific cases. I have also used FxCop to mark a ton of errors and copied them as "module" level SuppressMessage statements into assemblyinfo.cs. That works pretty well.

However, now I really want to globally disable this annoying IdentifiersShouldBeCasedCorrectly rule. I'm using TeamCity 5.0.3, and am not using an FxCop project file (however, I could do this). I was hoping that I could pass a parameter to FxCopCmd to tell it to ignore this error, but it doesn't look that way from the documentation.

So... is there anything I can do short of creating an FxCop project file on the TeamCity build server and using it for the FxCop build runner?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

日久见人心 2024-09-03 01:16:37

查看FxCop的安装目录(我的是c:/program files/microsoft fxcop 1.36)。该目录中应该有一个 CustomDictionary.xml 文件。您可以将 XML 添加到 CustomDictionary.xml 末尾的 CasingExceptions 部分,并且该计算机上所有项目的所有命名空间和函数名称元素都将忽略 XML 大小写(当然,除非在命令行上覆盖 CustomDictionary.xml)。

您还可以将 CustomDictionary.xml 复制到项目目录,并在项目目录副本的 CasingExceptions 部分中添加 XML。我认为这将自动找到,不需要 FxCop 项目文件,并且仅用于该项目。

这就是我为 TeamCity 构建所做的,但由于另一个原因我需要 FxCop 项目文件,因此我不记得(也无法检查)FxCop 是否会自动找到 CustomDictionary.xml。

例子:

  <Acronyms>
<CasingExceptions>
  <Acronym>Pi</Acronym>
  <Acronym>Na</Acronym>   <!-- NaN -->
  <Acronym>NESW</Acronym> <!-- North East South West -->
  <Acronym>NWSE</Acronym> <!-- North West South East -->
  <Acronym>XML</Acronym> <!-- XML -->
</CasingExceptions>

MSDN FxCop 中还有一个略有不同的忽略单词的示例常见问题解答
希望这有帮助!

Look in the install directory of FxCop (mine is c:/program files/microsoft fxcop 1.36). There should be a CustomDictionary.xml file in that directory. You can add XML to the CasingExceptions section at the end of CustomDictionary.xml and XML casing will be ignored for all namespace and function name elements of all projects on that machine (unless CustomDictionary.xml is overridden on the command line, of course).

You can also copy CustomDictionary.xml to the project directory and add XML in the CasingExceptions secion of the project directory copy. I think that this will be found automatically, with no need of an FxCop project file and will only be used for that project.

That's what I did for our TeamCity build, but I needed an FxCop project file for another reason, so I cannot remember (and cannot check) if CustomDictionary.xml will be found automatically by FxCop.

Example:

  <Acronyms>
<CasingExceptions>
  <Acronym>Pi</Acronym>
  <Acronym>Na</Acronym>   <!-- NaN -->
  <Acronym>NESW</Acronym> <!-- North East South West -->
  <Acronym>NWSE</Acronym> <!-- North West South East -->
  <Acronym>XML</Acronym> <!-- XML -->
</CasingExceptions>

There is also a slightly different example of ignoring words at MSDN FxCop FAQ
Hope this helps!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文