The path to your custom rules can include absolute file paths, relative paths, and use environment variables. Catch block should not be empty. The property will resolve to the location where the FxCop assemblies have been installed. Daniel, Just sounds like you are referencing an assembly that FXCopy cannot find. Every method has an instruction collection which is nothing but the actual code.

Please refer to answer given by Rajesh KS. Thanks all, now the problem has been solved. FxCop does not analyze the source code, it analyzes compiled IL-Assemblies! This could be done either by trying to cast it to a Microsoft. So that fact, and I imagine a couple of others, means the API has changed from previous versions. There is only a loose connection between the two. Well there isn’t one right now.

7 Steps to Write Your Own Custom Rule using FXCOP

Define a class to implement the rule and derive from our previously defined class. By posting your answer, you agree to the privacy policy and terms of service. As mentioned in the article i have created the project and i have attached the dll in the rules tab of FXCop and it shows dll name writing custom rules for fxcop there is no child nodes to that dll.

The rule we will implement checks whether or not the identifiers for private and internal fields use Hungarian notation. You are commenting using your Twitter account.

Sign up using Facebook. A better way is to use the free Reflector for. Catch block should not be empty. One common reason for that are compiler optimizations.


There is only a loose connection between the two. Random Number Generation and Sampling Methods. Polls Who am I?? What i did to resolve this problem: You can see in the output how the method name is displayed with the resolution read from the connection.

Don’t confuse these two kinds of analysis – they apply to writing custom rules for fxcop different kinds writing custom rules for fxcop software artifacts, and you should use them differently, although they can be partially used to fulfill the same needs.

I know exactly what i have written and i stick to it. I am not able to see the Rule in FxCop 1. The link may get broken over time, and it would be useful if some details are available here as well. This field represents the accuracy percentage of the rule. Footprints on the sand are not made by sitting at the shore.

The code is easily ported to. Targets tab is where you add the assembly.

Prashant, This just sounds like a basic method access issue. For that little story, you’ll have to read my next post In FXCop under myrules i am not able to see the rules techinical Dec 2: If you use ‘ildasm Rule.

writing custom rules for fxcop If you don’t believe me, then have a look at the IL of the following method using the ‘legendary’. FxCop is a static analysis tool that you can use to write custom rules those need to be followed by the developers.


I want to create extra rules in FXCop. Note that we have not released an SDK for implementing custom rules, so the API is undocumented and will almost certainly change in the future.

Shivprasad koirala 4-Nov 2: Your custom rules project will need to reference FxCopSdk. Recently I needed to create a set of custom FXCop rules and started playing with the latest version, which is currently 1.

FxCop Custom Naming Rules – Rahul Nath

If you use this code, please mention “www. When you run code analysis from Visual Studio the FxCopCmd command line utility is invoked to perform the analysis. Do not forget to watch my Learn step by step video series. There is no documentation for FxCop so developing custom rules is a matter of trial and error. The property will resolve to the location where the FxCop assemblies have been installed.

The format of the XML file writing custom rules for fxcop shown below. Now the last thing.