docs icon indicating copy to clipboard operation
docs copied to clipboard

Requesting Example of how to use `inheritdoc` with params of a record-type

Open mariotee opened this issue 4 years ago • 2 comments

I was wondering how to do something like this:

/// <summary>
/// the animal concept
/// </summary>
/// <param name="Name">the name</param>
/// <param name="Age">the age</param>
public abstract record Animal(string Name, int Age);

/// <summary>
/// the cat model
/// </summary>
/// <param name="Name">***inheritdoc somehow***</param>
/// <param name="Age">***inheritdoc somehow***</param>
/// <param name="LikesMilk">if this cat likes milk</param>
public record Cat(string Name, int Age, bool LikesMilk)
    : Animal(Name, Age);

Document Details

⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

mariotee avatar Oct 05 '22 14:10 mariotee

/cc @mikadumont @CyrusNajmabadi

Is there a way to do this?

BillWagner avatar Oct 06 '22 13:10 BillWagner

ahh i think i found it. i just had to think about it differently. i used an example that was meant for method params. but it seems it works the same for the record params

/// <summary>
/// the animal concept
/// </summary>
/// <param name="Name">the name</param>
/// <param name="Age">the age</param>
public abstract record Animal(string Name, int Age);

/// <summary>
/// the cat model
/// </summary>
/// <param name="Name"><inheritdoc cref="Animal" path="/param[@name='Name']"/></param>
/// <param name="Age"><inheritdoc cref="Animal" path="/param[@name='Age']"/></param>
/// <param name="LikesMilk">if this cat likes milk</param>
public record Cat(string Name, int Age, bool LikesMilk)
    : Animal(Name, Age);

mariotee avatar Oct 06 '22 14:10 mariotee