2011-11-30 57 views
2

是否有更新文档的标准方法注释反映子类的名称而不是基类?另外,如果方法确实存在,这是我应该练习还是避免的?文档评论(子类)

实施例:

class BaseClass 
{ 
    /// <summary> 
    /// Gets or sets a value associated with the name of the BaseClass 
    /// </summary> 
    protected string Name { get; set; } 
} 

class SubClass : BaseClass 
{ 
    /// Gets or sets a value associated with the name of the Subclass <-- updated 
    /// protected string Name { get; set; } <-- defined on BaseClass 
} 

回答

0

号的文档仅适用于实现的代码 - 如果你的类继承从它的基类的方法,则该文档也继承。如果没有提供新的实现,则不能“覆盖”文档。 (这是有道理的 - 如果实现没有改变,那么文档也不需要改变。)

如果您在外部表单或智能感知中浏览文档,则基类中的文档将会根据需要显示,因此无需重新定义它们以查看相应的文档。

0

如果使用Sandcastle Help File Builder,则可以通过使用<inheritdoc/> tag来实现一定程度的重复使用说明。例如,您可以在您的基类上设置摘要,并在您的派生类上使用<inheritdoc/>来获取相同的内容。但是,我认为没有办法可以动态地改变它(例如替换类名)–您可以继承整个摘要文本,也可以不继承。