views:

117

answers:

3

I work on a fairly complex Open Source project (opensimulator.org). It's currently sitting around 300 KLOC of C#, and there are a number of places where code has built up to trap and ignore exceptions, which end up disguising subtle bugs.

I'm wondering what tools are out there that can produce reports of overly general exception catching, and also if there are tools available that will log every thrown exception, whether it is suppressed or not, for examination later.

It would be ideal if the tools could be introduced into our CI build & test script, so that daily reports can be made, but isn't a requirement.

+2  A: 

Use FxCop, or the Code Analysis feature of Visual Studio Team System Developer Edition.

Also, I've found ReSharper useful for this.

John Saunders
That is a good suggestion.
Jonathan C Dickinson
+1  A: 

All righ, I agree with @John Saunders but if there is a lot of code, you can write a simple analyzer or use some exisiting code to replace all the swallowed exception patterns with logging code. Very simple, like replace:

catch(Exception ex)
{
}

with:

catch(Exception ex)
{
    System.Diagnostics.Debug.WriteLine(ex.ToString());
}

Note, you'd also want to check for catch(Exception), probably just use some regular expressions and this would not be difficult at all. I understand since it is a lot of code, you might want an automated way of getting basic logging in there. Replace the Debug.WriteLine() with whatever you want. This is kind of crude but simple.

BobbyShaftoe
A: 

Visual Studio has this built in, read up on how to enable it.

Jonathan C Dickinson