A List of FxCop/Code Analysis Rules with MSDN Details
I am starting a fairly large project that will involve many developers. As part of the ramp up, I wanted to review all the code analysis/FxCop rules and choose which one we want to enforce as a check in policy for TFS. To help with the analysis, what I really wanted was a spreadsheet that listed all the rules and their descriptions that I can use to guide a meeting with a few other stakeholders.
Unfortunately, I couldn’t really find such a list. The closest I came was this list that had the rule type names and listed whether they were supported in a couple of versions of FxCop and Visual Studio Code Analysis 2005 and 2008. This list was good, but only had the pascal cased rule type names. These names weren’t always enough to really understand what the rule did.
What I really wanted was a list that had enough information to sit down and go through all the rules in a group so we could decide whether we wanted to enforce it as policy. The closest I was able to find was the msdn documentation located located here.
The msdn documentation was great. Each rule has its own page with a description, cause and how to fix instructions with other information. But visiting a page for over 200 rules is way too tedious. What I really wanted was a spreadsheet with all that information.
To get that list, I decided to write a program to scrape all the details from the MSDN documentation into a single list. To do so I navigate the main page to each category, then for each category, I navigate each of the rules and scrape all the relevant details by parsing the HTML. The code is written in C#, and leverages a codeplex project, the HTML Agility pack to allow me to use XPath to navigate the HTML returned via WebClient.
The code itself generates a pipe delimited file, which I then used Excel to import and save as an Excel 2007 Workbook.
Here is a link to a zipped version of the source code if you want to write something similar. And here is a link to the full spreadsheet (includes cause and how to fix columns) if you just want to have the output list of Rules with full detail.