Search code examples
c#visual-studiointellisensexml-documentation

VS Intellisense: Show INDENTED multiline code example on hover-over


Is such a thing possible? If it's not clear what I'm talking about, here's a detailed example:

Take this quick utility class I wrote a few weeks ago (details omitted), along with the example I want to share:

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
        };
    }
}

I have the following XML above the abstract class:

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

Now, I could have SWORN that when I originally created the class, the tooltip looked like I wanted ... but maybe I'm hallucinating. At any rate, during this week's refactor (during which the file was moved/renamed and fed through ReSharper's cleanup), I noticed that the Intellisense tooltip now looks like hot garbage:

Intellisense with zero whitespace control

Adding <br/> to the end of each line only helps a little:

enter image description here

...and I haven't been able to find a way to manually specify indentation the way <br/> specifies new lines. I've also tried many combinations of <remarks>, <example>, <para>, and various ways to nest the blocks, but nothing worked.

So: Is there any way to (ideally) get Visual Studio 2019 to actually parse whitespace found inside an XML documentation <code></code> block, or (barring that) use some other block that manually adds indentation, the way I've manually added new lines with <br/>? I've looked and looked, and can't find a way to do either.


Solution

  • For what it's worth - I have been able to indent source code in XML documentation (at least on VS 2022), by copy/pasting Unicode character u2800 (the Braille pattern blank character).

    I have not tried in other versions of Visual Studio. Unfortunately, the width of the blank character is not the same width as the rest of the monospaced characters (at least with the font I normally use, which is Office CodePro Light), so you can't rely on this character to create nice looking ascii-block diagrams that look right on both the editor as well as on the hover-over Intellisense view)

    For convenience, the character can be copied here (between the single quotes):

    '⠀'
    

    enter image description here