Search code examples
c#.netconventionsxml-comments

Preserve comments when Overriding


Is there a way (tool, or something) that permits do not duplicate the same XML comments when inheriting/Overriding methods from the base classes?

Eg.:

/// <summary>
/// Represent a brand new object in .NET
/// </summary>
public class MyObject : Object
{
    /// <summary>
    /// Copy-Paste the same Xml comment 
    /// like in the base class is boring!
    /// </summary>
    /// <param name="obj">and params too!! ((</param>
    /// <returns>this one too!!! (((</returns>
    public override bool Equals(object obj)
    {
        return base.Equals(obj);
    }
}

Solution

  • I think you're looking for inheritdoc:

    /// <inheritdoc />
    public override bool Equals(object obj)
    

    This is not a standard tag (so Intellisense may not support it, for exampple), but it's pretty commonly used - in particular, Sandcastle supports it.