gpt4 book ai didi

c# - 如何调试代码分析自定义规则?

转载 作者:太空狗 更新时间:2023-10-29 19:44:00 24 4
gpt4 key购买 nike

我按照在 this site 上找到的分步说明,用 C# 编写了一些自定义规则。 .当我尝试在 中运行代码分析时,我在 CA 结果 Pane 中收到 CA0054 错误。

我想调试我的规则,因为它显然抛出了异常。但是,我不知道该怎么做。我尝试将一个新的 Visual Studio 实例附加到另一个正在运行的实例,但它不起作用。

网络上有很多关于调试自定义规则的资源,但它们都是针对旧版本的 FxCop,具有单独的 GUI 和所有内容。我认为这与我的情况无关。

我是不是漏掉了什么?

最佳答案

我在这里找到了答案:

How to write custom static code analysis rules and integrate them into Visual Studio 2010

You can debug custom rules through FxCopCmd.exe. Normally you would run your rule against another project. To simplify the instructions in this blog we’re going to run our new rule against the implementation of the rule itself. In the project properties for your custom rules project on the Debug tab do the following

  1. Configure the project to launch an external program and enter in the path to FxCopCmd.exe. For example C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\FxCopCmd.exe

  2. For command line arguments specify /out:"results.xml" /file:"MyCustomRules.dll" /rule:"MyCustomRules.dll" /D:"C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop"

  3. Set the working directory to the build output folder. For example C:\Projects\MyCustomRules\MyCustomRules\bin\Debug\

Now you can to debug your custom rules by simply hitting F5 from your custom rules project. Try it

关于c# - 如何调试代码分析自定义规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25548915/

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