views:

57

answers:

2

In our solution we have a project that contains all the exceptions.

All of the exceptions inherit our base exception which inherits from ApplicationException.

Our base exception includes a field for exception number.

What I would like to do is to run a script that creates a list with exception name, number and xml documentation.

Any idea how to do this?

+1  A: 

A "script" is not going to be able to do this. You need a static code analyzer that traces all the method calls and detects when an object that derives from Exception is created and thrown. It gets sticky when the code calls methods in the .NET framework, you don't have the source code for it. System.Reflection is no help, it cannot reflect code.

This ultimately goes back to why exception specifications are such a bad idea.

Hans Passant
+1 Thanks for the reply, do you have a link to any doc on why exception spesifications are a bad idea?
Shiraz Bhaiji
Link: http://www.artima.com/intv/handcuffs.html
Hans Passant
+3  A: 

If you want to generate a list of the custom exceptions in your application, you can use XML comments for this task. See the accepted answer to this question. As far as I know, the comments will not be able to access the error number property, but you can add an XML comment to that property and state the error number there.

Jamie Ide
Thanks we used Sandcastle
Shiraz Bhaiji