【问题标题】:Is there a way to use <inheritdoc /> within a <list>?有没有办法在 <list> 中使用 <inheritdoc />?
【发布时间】:2021-12-21 14:55:42
【问题描述】:

我正在使用 XML 标记来记录我的程序,因此当我将鼠标悬停在我的类、方法等上时,我可以看到描述。我想在我的一个类上显示一个列表,如下所示:

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

问题是 没有在预览中加载任何内容。但是,当我以完全相同的格式将 移到 之外时,它会完美显示。有什么方法可以引用列表中对 MyMethod() 的描述吗?

【问题讨论】:

    标签: c# xml


    【解决方案1】:

    &lt;inheritdoc&gt; 默认情况下包括目标 XML cmets 中的所有成员。如果您需要&lt;summary&gt;,则需要使用path 属性选择它:

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

    它应该呈现如下内容:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-09-20
      • 1970-01-01
      • 2014-06-13
      • 2012-10-28
      • 2021-01-05
      相关资源
      最近更新 更多