【问题标题】:How to add a mouse-over summary如何添加鼠标悬停摘要
【发布时间】:2011-01-18 01:06:53
【问题描述】:

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

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

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

【问题讨论】:

  • 我刚刚使用了你的第一个例子,它奏效了。
  • 是的,我刚刚开始工作。我正在将我制作的各种类合并到一个命名空间下的一个库中,并且我正在使用我没有放入摘要的命名空间中的类。

标签: c# visual-studio mouseover summary


【解决方案1】:

我不明白为什么您的第一次尝试行不通。这是 &lt;summary&gt; 评论标签,它提供了你正在谈论的“工具提示”......

/// <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 插件之一..

【讨论】:

    【解决方案2】:

    我刚刚发现的两个要检查的添加项会阻止在悬停时显示摘要:

    不要在摘要描述中使用与号 (&amp;) 或尖括号 (&lt;)。

    休息:

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

    【讨论】:

      【解决方案3】:

      三斜杠 XML cmets 可用于在 Visual Studio 中创建 IDE 工具提示。尤其是“总结”和“例外”的效果非常好。 (其他诸如“代码”之类的东西在我使用的 Visual Studio 版本中不起作用。)

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

      【讨论】:

      • 不起作用,但得到了 。哦,好吧,无论如何,这都是装饰性的和外围的。
      • 如果设置了exception 元素的cref 属性,则异常将在工具提示中列出。可悲的是,元素内容被忽略了。所以让我们说它成功了一半。 :-)
      【解决方案4】:

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

      【讨论】:

      • 我也没有安装 ctrl-f 崩溃错误的修补程序,因为担心它会弄乱我电脑上的其他东西。这可以与那个相关联吗?
      【解决方案5】:

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

      【讨论】:

        【解决方案6】:

        除了以上答案,访问Microsoft docs link获取完整的标签列表,为你的课程做一个非常漂亮的总结。

        【讨论】:

          猜你喜欢
          • 2011-08-22
          • 1970-01-01
          • 2015-03-29
          • 1970-01-01
          • 2011-08-04
          • 2018-09-03
          • 1970-01-01
          • 2011-12-14
          • 1970-01-01
          相关资源
          最近更新 更多