I want to use inheritdoc to grab the description of a parameter. So I have:
/// <param name="nameOfParameter">parameter description</param>
MethodName(int nameOfParameter)`
...
/// <summary>
/// <inheritdoc cref="ClassName.MethodName" select="param[@name='nameOfParameter']" />
/// </summary>
AnotherFunc
But AnotherFunc now has the description of MethodName rather than the parameter. Is this possible?
It seems that the select attribute is no longer used in inheritdoc tag. Use path instead:
/// <summary>
/// <inheritdoc cref="ClassName.MethodName" path="/param[@name='nameOfParameter']" />
/// </summary>
void AnotherFunc() { }
UPDATE
The xpath above will also include the inherited <param> tag itself inside the <summary> tag. It's not visible in the Intellisense quick info. But the more appropriate xpath should insert just the contents of the inherited <param> tag:
/// <summary>
/// <inheritdoc cref="MethodName" path="//param[@name='nameOfParameter']/node()" />
/// </summary>
void AnotherFunc() { }
I didn't completely succeed using @Peter's answer though it pointed me in the right direction.
I was successful with the following syntax (C# 7.3, VS 2022):
///<summary>
///Description of method here.
///</summary>
///<inheritdoc cref="crefedMethod(parmtype,parmtype)" path="/param[@name='parmName']"/>
This results in the parmName parameter's doc being inherited.
Additionally the following syntax results in any matching (by name) parameters being inherited:
///<summary>
///Description of method here.
///</summary>
///<inheritdoc cref="crefedMethod(parmtype,parmtype)" path="/param"/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With