title: auto-document exceptions on methods in C#/.NET
body: <p>I would like some tool, preferably one that plugs into VS 2008/2010, that will go through my methods and add XML comments about the possible exceptions they can throw.  I don't want the <code>&lt;summary&gt;</code> or other XML tags to be generated for me because I'll fill those out myself, but it would be nice if even on <code>private</code>/<code>protected</code> methods I could see which exceptions could be thrown.  Otherwise I find myself going through the methods and hovering on all the method calls within them to see the list of exceptions, then updating that method's <code>&lt;exception</code> list to include those.  Maybe a VS macro could do this?</p>
  
  <p><strong>From this:</strong></p>
  
  <pre><code>private static string getConfigFilePath()
  {
      return Path.Combine(Environment.CurrentDirectory, CONFIG_FILE);
  }
  </code></pre>
  
  <p><strong>To this:</strong></p>
  
  <pre><code>/// &lt;exception cref="System.ArgumentException"/&gt;
  /// &lt;exception cref="System.ArgumentNullException"/&gt;
  /// &lt;exception cref="System.IO.IOException"/&gt;
  /// &lt;exception cref="System.IO.DirectoryNotFoundException"/&gt;
  /// &lt;exception cref="System.Security.SecurityException"/&gt;
  private static string getConfigFilePath()
  {
      return Path.Combine(Environment.CurrentDirectory, CONFIG_FILE);
  }
  </code></pre>
  
  <p><strong>Update:</strong>  it seems like the tool would have to go through the methods recursively, e.g., method1 calls method2 which calls method3 which is documented as throwing <code>NullReferenceException</code>, so both method2 and method1 are documented by the tool as also throwing <code>NullReferenceException</code>.  The tool would also need to eliminate duplicates, like if two calls within a method are documented as throwing <code>DirectoryNotFoundException</code>, the method would only list <code>&lt;exception cref="System.IO.DirectoryNotFoundException"/&gt;</code> once.</p>