[英]Inheriting base constructor parameter <summary> in a derived class C#
I would like to know whenever is it possible to refer/inherit description of base constructors parameters.我想知道何时可以引用/继承基本构造函数参数的描述。 Based on my research I was able to figure out how to refer to description of a property however so far it does not seem to be possible to refer to a constructor parameter (signature matching being the main problem).
根据我的研究,我能够弄清楚如何引用属性的描述,但是到目前为止,似乎无法引用构造函数参数(签名匹配是主要问题)。
<param name="number"><inheritdoc cref="Number" path="/summary"/></param>
public class A
{
/// <summary>
/// Some description
/// </summary>
/// <param name="param">I want to inherit this summary in a derrived class.</param>
public A(string param)
{
}
}
public class B : A
{
/// <summary>
/// Some decription
/// </summary>
/// <param name="param">I would like inherit description from the base class. </param>
/// <param name="newParam">Some new description.</param>
public B(string param, int newParam) : base(param)
{
}
}
Inheritdoc works great but only If you want to take everything from parent and nothing from yourself.
Inheritdoc 效果很好,但前提是你想从父母那里拿走所有东西,而不是从你自己那里拿走任何东西。
Not really, you can use the <inheritdoc>
tag to grab what you need from the base class.并非如此,您可以使用
<inheritdoc>
标记从基类中获取您需要的内容。 Everything or the value of a specific node through XPath
expression as shown in:通过
XPath
表达式的所有内容或特定节点的值如下所示:
Is it possible to inherit documentation from specific parameters?是否可以从特定参数继承文档?
In your case, you should have something like:在你的情况下,你应该有类似的东西:
public class A
{
/// <summary>
/// Some description
/// </summary>
/// <param name="param">I want to inherit this summary in a derrived class.</param>
public A(string param)
{
}
}
public class B : A
{
/// <summary>
/// Some decription
/// </summary>
/// <param name="param"><inheritdoc cref="A(string)" path="/param[@name='param']"/></param>
/// <param name="newParam">Some new description.</param>
public B(string param, int newParam) : base(param)
{
}
}
Where:在哪里:
cref="A(string)"
Specifies the base class ctor. cref="A(string)"
指定基类 ctor。path="/param[@name='param']"
Specifies the required param. path="/param[@name='param']"
指定所需的参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.