[英]How to add a mouse-over summary
我几乎可以肯定这将是一个非常简单的答案,但我似乎无法在任何地方找到它。 我们都知道,当您将鼠标悬停在某物(如字符串)上时,会弹出一个小摘要(如果已启用)。 对于字符串,它说:
类 System.String
将文本表示为一系列 Unicode 字符。
当我鼠标移到我的一个类,它只是说:
类 Namespace.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.
那么,如何向鼠标悬停弹出窗口添加摘要?
我不明白为什么你的第一次尝试不起作用。 它是<summary>
注释标签,它提供您正在谈论的“工具提示”...
/// <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 插件之一。
我刚刚发现的两个要检查的添加项将阻止在悬停时显示摘要:
&
( &
) 或起始尖括号 ( <
)。休息:
///<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
// - This line only has 2 dashes
/// </summary>
作品:
/// <summary>
///
/// This
///
/// is fine.
///
/// </summary>
三斜线 XML 注释可用于在 Visual Studio 中创建 IDE 工具提示。 特别是,“摘要”和“例外”工作得非常好。 (诸如“代码”之类的其他内容在我使用的 Visual Studio 版本中不起作用。)
如果这对您不起作用,那么您的设置可能有问题。
在 Visual Studio 中重置您的设置,它们似乎被搞砸了。 为了显示它,您必须使用第一个示例。
您需要使用您的第一个语法,并且,如果您在 Visual Studio 解决方案之外使用该类,则需要检查项目属性中的生成 XML 文档文件。
除了上述答案,请访问Microsoft 文档链接以获取完整的标签列表,以便为您的课程制作非常精美的摘要。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.