10

I'm almost certain this is going to be a very simple answer but I can't seem to find it anywhere. We all know when you hover your mouse over something (like a string) a little summary pops up (if its enabled). For a string, it says:

class System.String

Represents text as a series of Unicode characters.

When I mouse over one of my classes, it simply says:

class Namespace.Widget

I've tried the two obvious examples I've found:

/// <summary>
/// This summary does not work, I know it's for html documenting tools but thought it was worth a shot.
/// </summary>

and:

// Summary:
//     This is what is in some of the base libraries, and does not work as well.

So, how do I add a summary to the mouse-over pop-up??

Community
  • 1
  • 1
Steve H.
  • 3,283
  • 4
  • 24
  • 32
  • I just used your first example and it worked. – Joel Feb 17 '10 at 20:10
  • Yea I just got it to work. I am in the process of combining various classes I've made into one library under one namespace and I was using the class from the namespace I didn't put the summary in. – Steve H. Feb 17 '10 at 20:21

6 Answers6

8

I don't see why your first attempt wouldn't work. It's the <summary> comment tag which supplies the 'tooltip' you're talking about...

/// <summary>
/// This text should automatically show up as the summary when hovering over
/// an instance of this class in VS
/// </summary>
public class MyClass
{
    public MyClass() {}      
}

public class MyClass2
{
    public MyClass()
    {
        //hovering over 'something' below in VS should provide the summary tooltip...
        MyClass something = new MyClass();
    }
}

If you want help automating some of your commenting, try the free GhostDoc. By far one of the best free VS addons..

KP.
  • 13,218
  • 3
  • 40
  • 60
4

Two additions to check for that I just discovered will prevent the summary from showing when hovering:

Do not use ampersands (&) or starting angle brackets (<) in your summary description.

Breaks:

    ///<summary>
    ///Class does this & that
    ///</summary>

Instead use:

    ///<summary>
    ///Class does this AND that
    ///</summary>

Breaks:

    /// <summary>
    /// Checks if this < that
    /// </summary>

This will work, but probably not a good precedent to set:

    /// <summary>
    /// Checks if this > that 
    /// </summary>

Do not separate the /// lines from each other.

Breaks:

    /// <summary>
    /// This text will not show
    
    /// </summary>

Breaks:

    /// <summary>
    /// This text will also not show
    //  because THIS line only has 2 dashes
    /// </summary>

Works:

    /// <summary>
    ///
    /// This
    ///    
    /// is
    ///
    /// fine.
    ///
    /// </summary>
Graeme Rock
  • 601
  • 5
  • 21
1

The three-slash XML comments may be used to create the IDE tool-tips in Visual Studio. In particular, "summary" and "exception" work very well. (Other things like "code" have not worked in the versions of Visual Studio that I have used.)

If this is not working for you, then something may be wrong with your settings.

Jeffrey L Whitledge
  • 58,241
  • 9
  • 71
  • 99
  • doesn't work, but got . Oh well, this was cosmetic and peripheral anyway. – Steve H. Feb 19 '10 at 18:06
  • If the `cref` attribute of the `exception` element is set, then the exception will be listed in the tool-tip. Sadly, the element content is ignored. So let's say that it half works. :-) – Jeffrey L Whitledge Feb 22 '10 at 23:20
0

Reset your settings in visual studio, they seem to be messed up. And for it to show up, you'd have to use the first example.

Malfist
  • 31,179
  • 61
  • 182
  • 269
  • I also have not installed the hotfix for the ctrl-f crash bug for fear of it messing up other things on my computer. Could this be linked to that? – Steve H. Feb 17 '10 at 20:16
0

You need to use your first syntax, and, if you're using the class outside of your Visual Studio solution, you need to check Generate XML Documentation file in Project Properties.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

In addition to the above answers, visit the Microsoft docs link to get a complete list of tags to make a very beautiful summary for your classes.

Salik
  • 458
  • 7
  • 14