Code Analysis in .NET

By Michael Flanakin @ 10:25 AM :: 723 Views :: 0 Comments :: .NET, Patterns & Practices :: Digg it!

I just started working on a project that needs a lot of clean-up work done. It's one of those systems that's grown over the years and nobody has ever really gone thru and cleaned out the closets. To give you an idea, running the latest standalone copy of FxCop Mobile-ready link on the assemblies in the web app produce 12,020 messages.

When I first loaded the project in Visual Studio 2005, I tried to run the built-in code analysis feature, but didn't know where to find it. Eventually, I found out that code analysis is only available on a project-by-project basis. This means I'd have to run it on each project independantly. There's no way I was going to do that! Eventually, I found out about a macro Mobile-ready link created by Daniel Fisher Mobile-ready link that would enable code analysis for all projects (I am hoping to release this as a VS add-in in the future). Executing this and re-running code analysis is what I needed. That gave me 9320 warning messages. Of these, I noticed 50 were not code analysis messages (i.e. updated libraries, deprecated methods, and several other typical compilation warnings). Having this list was just what I wanted... well, almost. I ultimately plan on getting these items imported into Team Foundation Server as development tasks, so I needed to save this list to a file. Of course, when you run code analysis on a project, an XML file is created. Great, right? Not quite. Each project created its own XML file, so I had to dig thru the unorganized directory structure to find all of the files (actually, I just seached for all XML files with "codeanalysis" in the name). After looking at these files, tho, I noticed that they only accounted for 6932 messages -- assuming I was reading them correctly -- which, as far as I'm concerned, is a far cry from the original list.

I dug around trying to find a way to save the error list to a file to no avail. The best I could find was to simply select all of the items, copy them, and paste them in some editor to manipulate. If I have time, I will see about creating the ability to export this list to XML in that VS add-in I mentioned. For the meantime, tho, I needed another way to get the list.

I ultimately resigned myself to the standalone version of FxCop, Visual Studio's code analysis predecessor. The latest version Mobile-ready link, 1.35, was released in June 2006, 8 months after Visual Studio. This, of course, led me to see if there was a way to update Visual Studio's built-in code analysis capabilities. Unfortunately, there isn't Mobile-ready link. So, I decided to just keep it simple and stick with FxCop 1.35.

I plan on keeping my eyes open for a resolution to this issue. The best I can see for now, tho, is that we'll have to wait for the next release of Visual Studio, which I'm hoping will be available in very early 2007.

Ratings

Comments

Currently, there are no comments. Be the first to post one!
Click here to post a comment



Archives Archives

Categories Categories

Related Links Related Links