如何让我的Visual Studio显示例外,任何方法可能引发? [英] How do I make visual studio show exceptions that any method may throw?
问题描述
我想知道我怎样才能使Visual Studio中显示的例外任何 的方法可能会抛出,而不仅仅是在.NET Framework方法(我使用C#)。
I was wondering about how I can make visual studio show the exceptions that any method may throw, not just the .NET Framework methods (I am using C#).
例如,这里的展示,当我将鼠标悬停在Console.WriteLine它说:异常信息:System.IO.IOException的图片。
For example, here's a picture showing that when I hover over Console.WriteLine it says "Exceptions: System.IO.IOException".
然而,当我这样做,因为我写的不说,它抛出什么异常,如下面的图片的任何方法。
However when I do that for any method I wrote it doesn't say what exception it throws, as shown in the following picture.
那么,如何让我的Visual Studio中显示这些异常?我需要一个特定的属性添加到方法?
So how do I make visual studio show those exceptions? Do I need to add a specific attribute to the method?
推荐答案
您可以通过添加做到这一点的 <异常>
标记的方法发表评论:
You can do this by adding an <exception>
tag to the methods comment:
/// <summary>
/// Fooes this instance.
/// </summary>
/// <exception cref="ArgumentNullException">Yay for exception</exception>
public void Foo()
{ }
这篇关于如何让我的Visual Studio显示例外,任何方法可能引发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!