Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make visual studio show exceptions that any method may throw?

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#).

For example, here's a picture showing that when I hover over Console.WriteLine it says "Exceptions: System.IO.IOException".

enter image description here

However when I do that for any method I wrote it doesn't say what exception it throws, as shown in the following picture.

enter image description here

So how do I make visual studio show those exceptions? Do I need to add a specific attribute to the method?

like image 699
Pavel Avatar asked Jun 23 '15 14:06

Pavel


1 Answers

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()
{ }
like image 171
Yuval Itzchakov Avatar answered Sep 19 '22 22:09

Yuval Itzchakov