Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

inheritdoc for individual parameter?

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?

like image 806
Leon Frickenschmidt Avatar asked Jan 23 '26 23:01

Leon Frickenschmidt


2 Answers

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() { }
like image 197
Peter Macej Avatar answered Jan 26 '26 15:01

Peter Macej


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"/>
like image 25
Christopher Eberle Avatar answered Jan 26 '26 16:01

Christopher Eberle



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!