Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use <inheritdoc /> within a <list>?

Tags:

c#

xml

I'm using XML tags to document my program so I can see descriptions when I hover over my classes, methods, and such. I want to display a list on one of my classes like so:

/// <remarks>
/// <b>List of methods below</b>
/// <list type="table">
///     <listheader>
///         <term>
///             <see cref="MyMethod()"/>
///         </term>
///         <description>
///             <inheritdoc cref="MyMethod()"/>
///         </description>
///     </listheader>
/// </list>
/// </remarks>
public class MyClass
{
    /// <summary>
    /// Description of MyMethod()
    /// </summary>
    public void MyMethod()
    {
        // Do something
    }
}

The problem is that <inheritdoc /> is not loading anything in the preview. However, When I move <inheritdoc /> outside of the <list>, with the exact same formatting, it displays perfectly. Is there any way to reference the description of MyMethod() within the list?

like image 410
Wapelo Avatar asked Jan 22 '26 16:01

Wapelo


1 Answers

<inheritdoc> by default includes all members in the target XML comments. If you need the <summary> you need to select it using the path attribute:

<inheritdoc cref="MyMethod" path='//summary/text()'/>

It should render something like this:

enter image description here

like image 51
weichch Avatar answered Jan 24 '26 07:01

weichch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!