开发者

VS2010 Custom Code Analysis Rule

开发者 https://www.devze.com 2022-12-23 11:32 出处:网络
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 ca

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:



  
   Micr开发者_运维知识库osoft.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


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.


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:

VS2010 Custom Code Analysis Rule

Rules can be verified live in Visual Studio and at Build Process time, in a generated HTML+javascript report.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号