我想要一些工具,最好是可以插入到VS 2008/2010中的,能够遍历我的方法并添加关于可能引发的异常的XML注释。 我不希望为我生成<summary>
或其他XML标记,因为我将自己填写这些内容,但如果即使在私有/受保护的方法中,我也可以看到可能会被抛出的异常列表,那就太好了。否则,我会逐个查看方法并悬停在其中的所有方法调用上以查看异常列表,然后更新该方法的<exception>
列表以包括它们。也许可以使用VS宏来完成此操作?
private static string getConfigFilePath()
{
return Path.Combine(Environment.CurrentDirectory, CONFIG_FILE);
}
转为:
/// <exception cref="System.ArgumentException"/>
/// <exception cref="System.ArgumentNullException"/>
/// <exception cref="System.IO.IOException"/>
/// <exception cref="System.IO.DirectoryNotFoundException"/>
/// <exception cref="System.Security.SecurityException"/>
private static string getConfigFilePath()
{
return Path.Combine(Environment.CurrentDirectory, CONFIG_FILE);
}
更新: 看起来这个工具需要递归地遍历方法,例如,方法1调用方法2,方法2又调用方法3,而方法3被记录为抛出 NullReferenceException
,因此该工具将记录方法1和方法2也会抛出 NullReferenceException
。该工具还需要消除重复项,例如,如果方法中的两个调用都被记录为抛出 DirectoryNotFoundException
,则该方法只会列出一个 <exception cref="System.IO.DirectoryNotFoundException"/>
。