From Java I know that the signatures of methods that can throw exceptions contain a throws
block, that contains the Exception(s) that might be thrown.
In C# there is no such thing and it is also not common practice to include such info in the XML-Header.
Is there a generally accepted way of drawing attention to potential exceptions or a place to commonly denote them?
3
XML headers (e.g. <exception>
) are the best way of drawing attention to exceptions in C#, as this information will appear in IDE when typing the function name, as well as in auto-generated docs. However you cannot force a user to deal with the exception since C# specifically avoids checked exceptions.
Most people don’t put exception information in XML doc comments because it’s too much work with low payoff, but if it was to be done, this would most reliably draw attention to the exceptions thrown.
1