XML Comments - How to comment on several reasons for an exception?

Here is an example:

public void DoSomething(String param1, String param2) { if (param1 == null) throw new ArgumentNullException("param1"); if (param2 == null) throw new ArgumentNullException("param2"); } 

2 different reasons for ArgumentNullException. MSDN The String.Format example shows two different reasons for a FormatException . So, this is done:

 /// <exception cref="ArgumentNullException"> /// <paramref name="param1"/> is null. /// </exception> /// <exception cref="ArgumentNullException"> /// <paramref name="param2"/> is null. /// </exception> 

or in any other way?

 /// <exception cref="ArgumentNullException"> /// Some other way to show the 2 reasons with an "-or-" between them. /// </exception> 
+8
exception xml-comments
source share
1 answer

If you think that each of the lines of the document as one <exception cref=...> </exception> , then the logically correct way to do this is to use the second alternative:

 /// <exception cref="ArgumentNullException"> /// <p><paramref name="param1"/> is null. </p> /// <p>- or - </p> /// <p><paramref name="param2"/> is null. </p> /// </exception> 

You can use the 'p' elements to indicate strings.

+14
source share

All Articles