Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Comments for Override Properties

I'm using MonoDevelop 2.4.2 for OS X (the version that comes with Unity 3.4.1), and was wondering if there was some way to inherit comments from the base class or property.

Example:

public class Foo
{
    /// <summary>
    /// The describes the ABC property
    /// </summary>
    public virtual int ABC
    {
        get { return _abc; }
        set { _abc = value; }
    }
    protected int _abc;

    /// <summary>
    /// The describes the XYZ property
    /// </summary>
    public virtual int XYZ
    {
        get { return _xyz; }
        set { _xyz = value; }
    }
    protected int _xyz;
}

public class Bar : Foo
{
    public override int ABC
    {
        set
        {
            // DO SOMETHING
            base.ABC = value;
        }
    }
}

Bar bar = new Bar();

// In MonoDevelop 2.4.2 (OS X), the ABC property doesn't show the comments
// in the autocomplete popup or when you hover the mouse over the property.
int abc = bar.ABC;

// ... but they do show up for XYZ, because it doesn't override
int xyz = bar.XYZ;

This question seems somewhat similar to Comment Inheritance for C# (actually any language), although I am mostly concerned with how they behave in the editor at this point, and this is specific to MonoDevelop.

Some of the solutions in that question referred to <inheritdoc />, which doesn't appear to be valid in MonoDevelop (or I'm misusing it), and Ghostdoc is for Visual Studio.

It seems like the only solution would be to duplicate the property comments in the inherited class. Are there any alternatives?

like image 517
Michael Ryan Avatar asked Nov 09 '11 08:11

Michael Ryan


1 Answers

I cannot really confirm it, but there used to be an addin called DocFood that is now part of MonoDevelop (latest version is 2.8.* i think). Try it, i think it can inherit the comments from the parent implementation.

like image 79
esskar Avatar answered Sep 30 '22 19:09

esskar