Search code examples
c#visual-studiomouseoversummary

How to add a mouse-over summary


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??


Solution

  • 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..