VS Intellisense:悬停时显示缩进的多行代码示例

kha*_*ast 6 c# intellisense xml-documentation visual-studio

这样的事可能吗?如果不清楚我在说什么,这里有一个详细的例子:

以我几周前编写的这个快速实用程序类(详细信息省略)以及我想分享的示例为例:

public abstract class CommonOdinAttributesForOwnedType<TProperty, TParent> : OdinAttributeProcessor<TProperty>
{
    //snip
}

//EXAMPLE IMPLEMENTATION (Recommended to be nested inside MyBaseType):
protected class BoolAttributesInsideMyBaseType : CommonOdinAttributesForOwnedType<bool, MyBaseType>
{
    protected override List<Attribute> GetAdditionalAttributes()
    {
        return new List<Attribute>()
        {
            new ToggleLeftAttribute(), //add more desired attributes here
        };
    }
}
Run Code Online (Sandbox Code Playgroud)

我在抽象类上方有以下 XML:

/// <summary>
/// Gives ALL objects of type TProperty drawn within classes derived from TParent a requested list of 
/// Odin GUI attributes
/// <code>
/// //EXAMPLE IMPLEMENTATION (Recommended to be nested inside MyBaseType):
/// protected class BoolAttributesInsideMyBaseType : CommonOdinAttributesForOwnedType&lt;bool, MyBaseType&gt;
/// {
///     protected override List&lt;Attribute&gt; GetAdditionalAttributes()
///     {
///         return new List&lt;Attribute&gt;()
///         {
///             new ToggleLeftAttribute(), //add more desired attributes here
///         };
///     }
/// }
/// </code>
/// </summary>
Run Code Online (Sandbox Code Playgroud)

现在,我可以发誓,当我最初创建该类时,工具提示看起来像我想要的......但也许我产生了幻觉。无论如何,在本周的重构期间(在此期间文件被移动/重命名并通过 ReSharper 的清理提供),我注意到 Intellisense 工具提示现在看起来像热垃圾:

具有零空白控制的智能感知

添加<br/>到每行末尾只会有一点帮助:

在此输入图像描述

...而且我还没有找到一种方法来手动指定缩进<br/>指定新行的方式。我还尝试了<remarks><example><para>和各种嵌套块的方法的许多组合,但没有任何效果。

那么:有没有什么办法(理想情况下)让 Visual Studio 2019 实际解析 XML 文档<code></code>块内找到的空格,或者(除非)使用其他手动添加缩进的块,就像我手动添加新行一样<br/>?我也找了又找,也找不到办法。

Blu*_*rat 4

无论如何,我已经能够通过复制/粘贴 Unicode 字符 u2800(盲文模式空白字符)来缩进 XML 文档中的源代码(至少在 VS 2022 上)。

\n

我没有在其他版本的 Visual Studio 中尝试过。不幸的是,空白字符的宽度与其余等宽字符的宽度不同(至少与我通常使用的字体 Office CodePro Light 不同),因此您不能依靠该字符来创建漂亮的字体查看在编辑器以及悬停在 Intellisense 视图上的 ascii 框图)

\n

为了方便起见,可以在此处复制字符(在单引号之间):

\n
\'\xe2\xa0\x80\'\n
Run Code Online (Sandbox Code Playgroud)\n

在此输入图像描述

\n