如何添加鼠标悬停摘要

发布于 2024-08-21 22:21:40 字数 600 浏览 8 评论 0原文

我几乎可以肯定这将是一个非常简单的答案,但我似乎无法在任何地方找到它。我们都知道,当您将鼠标悬停在某物(例如字符串)上时,会弹出一个小摘要(如果已启用)。对于字符串,它表示:

系统字符串类

将文本表示为一系列 Unicode 字符。

当我将鼠标悬停在的一个类上时,它只是说:

类命名空间.Widget

我已经尝试了我发现的两个明显的例子:

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

和:

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

那么,如何向鼠标悬停弹出窗口添加摘要?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

心如狂蝶 2024-08-28 22:21:40

我不明白为什么你的第一次尝试不起作用。这是

评论标签,它提供了您正在谈论的“工具提示”...

/// <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();
    }
}

如果您需要自动化某些评论的帮助,请尝试免费的 GhostDoc。迄今为止最好的免费 VS 插件之一..

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

铜锣湾横着走 2024-08-28 22:21:40

我刚刚发现的两个附加检查将阻止悬停时显示摘要:

不要在您的代码中使用与号 (&) 或起始尖括号 (<)摘要描述。

中断:

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

改为使用:

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

中断:

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

这会起作用,但可能不是一个好的先例:

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

不要将 /// 行彼此分开。

休息:

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

休息:

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

工作:

    /// <summary>
    ///
    /// This
    ///    
    /// is
    ///
    /// fine.
    ///
    /// </summary>

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>
素衣风尘叹 2024-08-28 22:21:40

三斜杠 XML 注释可用于在 Visual Studio 中创建 IDE 工具提示。尤其是“总结”和“例外”效果非常好。 (“代码”等其他内容在我使用的 Visual Studio 版本中不起作用。)

如果这对您不起作用,则您的设置可能有问题。

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.

二智少女 2024-08-28 22:21:40

重置 Visual Studio 中的设置,它们似乎混乱了。为了让它显示出来,您必须使用第一个示例。

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.

笔芯 2024-08-28 22:21:40

您需要使用第一个语法,并且,如果您在 Visual Studio 解决方案之外使用该类,则需要在项目属性中选中“生成 XML 文档文件”。

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.

ゃ人海孤独症 2024-08-28 22:21:40

除了上述答案之外,请访问 Microsoft 文档链接,获取完整的标签列表,为您的课程制作非常漂亮的摘要。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文