Attribute to inform method caller of the type of exceptions thrown by that method

In C# you document classes and their members with a XML documentation. In Visual Studio, start typing slashes over something and by the third slash it'll auto-generate the most common tags for you to fill in. It looks vaguely like Javadoc and JSDoc.

You are looking, specifically, for this tag.


My intent for using attributes is so that the project does not compile if the name of the exception has been changed or if the exception no longer exists. Therefore, How To Document Thrown Exceptions, is NOT the same question.

You can do this without using attributes, instead by writing <exception> documentation and configuring your project like this:

Project properties -> 'Build' tab:
'Output' section: Check 'XML documentation file'.
'Treat warnings as erros' section: Check 'Specific warnings' and add warning 1574.

This way project won't compile if XML documentation cref attribute value cannot be resolved.