VS2010自定义代码分析规则
我正在尝试为 mstest 项目 VS2010 编写自定义 fxcop 规则。我想调试它,但当它尝试加载 mstest 项目的 dll 时,不断出现异常,它失败,指出找不到引用的程序集:
Microsoft.FxCop.Common.AssemblyLoadException
Could not load C:\Users\Administrator\Documents\Visual Studio 2010\Projects\20100106-CodeAnalysisRulesBlogDemo\BlogDemo\TestProject1\bin\Debug\TestProject1.dll.
Microsoft.FxCop.Sdk.InvalidMetadataException
The following error was encountered while reading module 'TestProject1': Assembly reference cannot be resolved: Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
有人知道如何解决此问题吗?如果我只是运行代码分析,它工作正常,但一旦我尝试调试它就会失败。
谢谢
I'm trying to write a custom fxcop rule for mstest projects VS2010. I'd like to debug it but keep getting an exception when it tries to load the dll for the mstest project it fails stating that it can't find referenced assembly:
Microsoft.FxCop.Common.AssemblyLoadException
Could not load C:\Users\Administrator\Documents\Visual Studio 2010\Projects\20100106-CodeAnalysisRulesBlogDemo\BlogDemo\TestProject1\bin\Debug\TestProject1.dll.
Microsoft.FxCop.Sdk.InvalidMetadataException
The following error was encountered while reading module 'TestProject1': Assembly reference cannot be resolved: Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
Does anyone have any idea how to resolve this? If I just run the code analysis it works fine but as soon as I try to debug it fails.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 /d 选项指定在程序集解析期间要搜索的其他目录。
代码分析不会自动从项目设置中获取程序集,除非您已将它们全部设置为“复制本地”。
You can use the /d option to specify additional directories to search during assembly resolving.
Code Analysis doesn't automatically fetch assemblies from the project settings, unless you've all set them to Copy-local.
解决编写 FxCop 规则的混乱问题的另一种方法是使用工具 NDepend。这个工具可以让我们编写基于 C# LINQ 查询的代码规则 我们所说的 CQLinq 。 免责声明:我是该工具的开发人员之一
超过200个代码默认情况下建议规则。借助众所周知的 C# LINQ 语法,自定义现有规则或创建自己的规则非常简单。
CQLinq 查询可以在 VisualStudio 中实时编辑,并提供即时结果,并具有结果浏览功能:
可以验证规则< a href="http://www.ndepend.com/Doc_VS_CQL.aspx" rel="nofollow noreferrer">在 Visual Studio 中运行,在构建过程中,在 生成的 HTML+javascript 报告。
An alternative to the mess of writing FxCop rules would be to use the tool NDepend. This tool that lets write Code Rules over C# LINQ Queries what we call CQLinq. Disclaimer: I am one of the developers of the tool
More than 200 code rules are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.
CQLinq queries can be edited live in VisualStudio, and offer instant result, with result browsing facilities:
Rules can be verified live in Visual Studio and at Build Process time, in a generated HTML+javascript report.