【发布时间】:2011-12-25 02:31:01
【问题描述】:
我正在为 OS X 使用 MonoDevelop 2.4.2(Unity 3.4.1 附带的版本),并且想知道是否有某种方法可以从基类或属性继承 cmets。
例子:
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 的。
该问题中的一些解决方案提到了
似乎唯一的解决方案是在继承的类中复制属性 cmets。有其他选择吗?
【问题讨论】:
-
我会为 //Do Something 使用可覆盖的 OnABCChanged() 函数。
标签: c# properties overriding monodevelop unity3d