Automation of exception documentation

In our decision, we have a project containing all exceptions.

All exceptions inherit our base exception, which inherits from ApplicationException.

Our base exception has a field for the exception number.

What I would like to do is run a script that creates a list with the name, name, number and XML documents.

Any idea how to do this?

+4
source share
2 answers

If you want to create a list of 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, comments cannot access the error number property, but you can add an XML comment to this property and specify the error number there.

+4
source

A "script" cannot do this. You need a static code analyzer that monitors all method calls and detects when an object is created and an object is thrown from Exception. It becomes sticky when the code calls methods in the .NET framework, you do not have the source code for it. System.Reflection does not help, it cannot reflect code.

This is ultimately due to why exception specifications are such a bad idea.

Redgate had a product called "Exception Hunter" to do this. But they refused it, could not make it reliable enough. The interruption announcement is here . Don't buy too many stocks to blame .NET 4 for this.

+2
source

Source: https://habr.com/ru/post/1299000/


All Articles