C# VisualStudio |如果忘记在摘要中声明异常,则通知

C# VisualStudio |如果忘记在摘要中声明异常,则通知,c#,visual-studio,visual-studio-2017,resharper,C#,Visual Studio,Visual Studio 2017,Resharper,我有以下FooClass。有三种方法,其中两种方法可以引发异常。 如果您仅在haseexception方法中声明可以引发异常。 当您有大型项目时,可能会忘记在摘要中描述异常 如果我忘记声明异常,则可以扫描解决方案?在我的示例中,缺少四个异常(声明)。 public class FooClass { public FooClass() { HasException(); HasNoException(); HasChildExce

我有以下
FooClass
。有三种方法,其中两种方法可以引发
异常
。 如果您仅在
haseexception
方法中声明可以引发
异常。
当您有大型项目时,可能会忘记在摘要中描述
异常

如果我忘记声明
异常
,则可以扫描解决方案?在我的示例中,缺少四个
异常
(声明)。

public class FooClass
{
    public FooClass()
    {
        HasException();

        HasNoException();

        HasChildException();
    }

    /// <summary>
    /// This method does not throw an <see cref="Exception"/>.
    /// </summary>
    public void HasNoException()
    {

    }

    /// <summary>
    /// This method is throwing an <see cref="Exception"/>.
    /// </summary>
    /// <exception cref="Exception">Is immediately thrown.</exception>
    public void HasException()
    {
        throw new Exception();
    }

    /// <summary>
    /// This method can throwing an <see cref="Exception"/> from a method it calls.
    /// </summary>
    public void HasChildException()
    {
        //throws an exception
        HasException();

        //throws also an exception
        int.Parse("foo");
    }
}
公共类
{
公共类()
{
HasException();
HasNoException();
HasChildException();
}
/// 
///此方法不会抛出错误。
/// 
public void HasNoException()
{
}
/// 
///这种方法是抛出一个错误。
/// 
///立即抛出。
公共无效HasException()
{
抛出新异常();
}
/// 
///此方法可以从它调用的方法中抛出。
/// 
公共无效HasChildException()
{
//抛出异常
HasException();
//也抛出一个异常
int.Parse(“foo”);
}
}
工具提示

这应该是如何描述该方法的示例

/// <summary>
/// This method can throwing an <see cref="Exception"/> from a method it calls.
/// </summary>
/// <exception cref="Exception"></exception>
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="FormatException"></exception>
/// <exception cref="OverflowException"></exception>
public void HasChildException()
{
    //throws an exception
    HasException();

    //throws also an exception
    int.Parse("foo");
}
//
///此方法可以从它调用的方法中抛出。
/// 
/// 
/// 
/// 
/// 
公共无效HasChildException()
{
//抛出异常
HasException();
//也抛出一个异常
int.Parse(“foo”);
}

一种方法(不是唯一的方法)是使用名为“Exception”的Resharper扩展。转到Resharper>扩展管理器>搜索“异常”,安装并重新启动Visual Studio。之后,所有可能引发异常的位置(未记录)都将加下划线,并且使用alt enter可以自动创建异常文档模板。对于您的示例,它会查找您提到的所有案例,甚至更多(构造函数本身,它也会引发所有thsoe异常)。

您能使用Resharper吗?是的,我能使用ResharperUse For vs 2015>您是我的英雄;)这正是我想要的!!