覆盖属性的XML注释

时间:2011-11-09 08:04:16

标签: c# properties override monodevelop unity3d

我正在使用MonoDevelop 2.4.2 for OS X(Unity 3.4.1附带的版本),并且想知道是否有某种方法可以从基类或属性继承注释。

示例:

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;

这个问题似乎有些类似 Comment Inheritance for C# (actually any language),虽然我现在主要关注他们在编辑器中的表现,但这是MonoDevelop特有的。

该问题中的一些解决方案涉及&lt; inheritdoc /&gt;,它在MonoDevelop中似乎无效(或者我滥用它),而Ghostdoc适用于Visual Studio。

似乎唯一的解决方案是在继承的类中复制属性注释。还有其他选择吗?

1 个答案:

答案 0 :(得分:1)

我无法确认它,但曾经有一个名为DocFood的插件现在是MonoDevelop的一部分(最新版本是2.8。*我认为)。尝试一下,我认为它可以继承父实现的注释。