VS 2003 Tip #8: Exception information in the Object browser

One of the complaints we received from VS7 was that you couldnt tell the exceptions that a particular method could throw. We scratched our heads thinking of ways to do this, as the xml docs did contain this informattion about the class libraries. Ideally we would have liked to have put this information into intellisense, but this request came up after we had done our coding for the milestone. The thing that pushed us off the edge was a usability test we saw, where a guy remarked how painful it was not to have that information.

We ended up adding this information to the object browser. To view it, try something like - Open Object Browser. Open System.IO.File and select the Open method in the right pane. At the bottom of the Object Browsers information pane (where they have method signatures and summary etc), scroll down and you'll see the Exceptions header which should list the exceptions the method can throw.

Addendum #1: This is C#/J# only.

Addendum#2: If you create a dll and put its xml comments file next to it and then view it through the Object browser in a C# project, you should see this for your exceptions too. The equivalent xml tags should be something of the sort:

<exception cref="T:System.ArgumentOutOfRangeException">

<paramref name="index" /> is less than zero. <para>-or-</para><para><paramref name="index" /> is greater than <see langword="Count" />.</para></exception>

Comments

  • Anonymous
    March 16, 2004
    Is there a way to add this info to the XML Documentation for your own class, and have it show up the same way?

  • Anonymous
    March 16, 2004
    I opened up my object browser and saw no exceptions for any of the File methods.
    System.IO.File.Open, etc. I saw Summary, Parameters and Return Values. I am using VB.NET although I assume that should not make a difference.

  • Anonymous
    March 16, 2004
    The comment has been removed

  • Anonymous
    March 17, 2004
    How about a feature in Whidbey using Smart Tags to allow you to decorate any calls with a try/catch clause for a specific exception or all of them?

  • Anonymous
    March 17, 2004
    I know me and David had this discussion a couple of times in the past, how to declare the possible exceptions that a function call might throw in c#. Speaking under correction but I think you can do it in C with exception specifications.

  • Anonymous
    March 17, 2004
    I know me and David had this discussion a couple of times in the past, how to declare the possible exceptions that a function call might throw in c#. Speaking under correction but I think you can do it in C with exception specifications.

  • Anonymous
    June 01, 2009
    PingBack from http://paidsurveyshub.info/story.php?id=25648

  • Anonymous
    June 18, 2009
    PingBack from http://outdoordecoration.info/story.php?id=1556