locked
How to add my custom rules into Visual Studio 2005 RRS feed

  • Question

  • Visual Studio 2005 has integrated the FxCop.
    you can see the rules in vs2005 following the steps.
    1. Using Visual Studio, create a new C# ClassLibrary project. 
    2. In Solution Explorer, right-click the project and choose Properties
    3. In the Project Properties window, choose the Code Analysis tab .

    and then you can see the rules that the vs2005 provides. Now I want to add some custom rues into . please tell me what should I do? If possible, Please give the step by step tips. Thanks.

    I have added my customed rule's dll into the folder:"C:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\Rules". and then I restart my vs2005,but I can' t to see my custom rules on the  Code Analysis tab .Please give the step by step tips. Thanks.

    Friday, January 12, 2007 9:04 AM

Answers

All replies

  • See the following on the FxCop blog: FAQ: How do I integrate custom rules with Visual Studio?

    You might also be interested in the custom rules category on the blog: http://blogs.msdn.com/fxcop/archive/tags/Custom+Rules/default.aspx.

    Regards

    David

    Friday, January 12, 2007 3:01 PM
    Moderator
  • Hi,David, I am a chinese. so I use the vs2005's version is simplified character. when I custom my rules that refer to the FxCopSdk.dll and Microsoft.Cci.DLL from the vs2005. after I finish my rules, but they can't appear in FxCop's config pane.  If I refer to the FxCopSdk.dll and Microsoft.Cci.DLL from the FxCop1.35. they can successfully appear, please, tell me why, and how can I resolve this problem.

    Best regards.
    Friday, January 12, 2007 6:06 PM
  • That's because they are different versions, you need to compile your rules against the versions of those files that you want to run the rules against.

    See the following post for a easy way to do this:

    http://blogs.msdn.com/fxcop/archive/2006/05/31/faq-can-i-create-custom-rules-that-target-both-visual-studio-and-fxcop-david-kean.aspx

    Friday, January 12, 2007 6:23 PM
    Moderator
  • "That's because they are different versions, you need to compile your rules against the versions of those files that you want to run the rules against."

     

    Yes, it works... (Now !!)

    Just change your references from the C:\Downloaded Standalone version of FXCop1.35\MS.CCI.DLL & FXCopSDK.DLL
    to the dir of the FXCop DLL's shiped with Visual Studio 2005 !! (Don't have clue what version it is...!)

    Thats: D:\Program Files\Microsoft Visual Studio 8\Team Tools\Static Analysis Tools\FxCop\ (In my case....)

    Rebuild and copy the Rule.DLL to the RULE dir of Visual Studio...and it works great...


    And also handy to know:
    If you project is made for FXCop 1.36, than you have to change some things...
    If Visual Studio can't find some thing in the FXCop.SDK, just look in the Microsoft.Cci !
    They changed a lot, but only names and namespaces, it's very easy to fix !

     

    FXCop 1.36 => FXCop 1.35


    Microsoft.FxCop.Sdk.BaseIntrospectionRule => Microsoft.FxCop.Sdk.Introspection.BaseIntrospectionRule
    Microsoft.FxCop.Sdk.Member => Microsoft.Cci.Member
    Microsoft.FxCop.Sdk.ProblemCollection => Microsoft.FxCop.Sdk.Introspection.ProblemCollection
    Microsoft.FxCop.Sdk.ClassNode => Microsoft.Cci.TypeNode

    And so on.... Just search a little bit for it....

    Good luck, and David: "Thanx for the oneliner and copy pasting, no wonder you work for MS!"

    Friday, September 16, 2011 2:33 PM