对于类属性的XML注释,正确的语法是什么?如何记录类属性
如何记录类属性
回答
安装此:http://submain.com/products/ghostdoc.aspx
的财产,选择 '文档本' 单击鼠标右键。 填空。
Ghostdoc很不错,但自动生成的注释并不真正有用,并且可以省略。 – 2010-10-15 14:14:00
是的,但它会自动添加正确的结构。您随后可以随时编辑自动生成的文本。还有一半的时间,如果你从逻辑上命名你的方法,它会得到正确的评论。 – MonkeyWrench 2010-10-15 14:19:06
这不回答这个问题。我仍然想知道在问题中详细描述的正确语法,无论是否有某种工具可以帮助我。这是特别的情况,因为我不在Windows上,所以我没有运行Visual Studio,所以我不能使用你的解决方案。 – gman 2014-12-02 05:43:22
根据MSDN,link,它看起来没有类属性的官方标签。但是,我会用这样的:
/// <summary>Here is an example of a propertylist:
/// <list type="Properties">
/// <item>
/// <description>Property 1.</description>
/// </item>
/// <item>
/// <description>Property 2.</description>
/// </item>
/// </list>
/// </summary>
为了应对显式实例的请求,下面的提取物是从了StyleCop帮助文档,“SA1623:PropertySummaryDocumentationMustMatchAccessors”:
酒店的摘要文本必须以文字开始描述中暴露的类型存取方法属性。如果该属性只包含一个get访问器,则摘要必须以单词“Gets”开头。如果该属性只包含一个设置访问器,则摘要必须以“Sets”字开头。如果属性公开get和set访问器,则摘要文本必须以“获取或设置”开头。
例如,请考虑以下属性,该属性公开get和set访问器。摘要文本以“获取或设置”开头。
/// <summary>
/// Gets or sets the name of the customer.
/// </summary>
public string Name
{
get { return this.name; }
set { this.name = value; }
}
如果该属性返回布尔值,则应用附加规则。布尔属性的摘要文本必须包含“获取指示是否的值”,“设置指示是否的值”或“获取或设置指示是否的值”的文字。例如,考虑下面的布尔属性,只公开了一个get访问:
/// <summary>
/// Gets a value indicating whether the item is enabled.
/// </summary>
public bool Enabled
{
get { return this.enabled; }
}
在某些情况下,一个属性的set访问可以具有比get访问更受限制的访问。例如:
/// <summary>
/// Gets the name of the customer.
/// </summary>
public string Name
{
get { return this.name; }
private set { this.name = value; }
}
在这个例子中,set访问已经被指定专用通道,这意味着它只能由包含它的类的本地成员访问。然而,get访问器继承了其父属性的访问权限,因此它可以被任何调用者访问,因为该属性具有公共访问权限。
在这种情况下,文档摘要文本应避免引用set访问者,因为它对外部调用者不可见。
StyleCop应用一系列规则来确定何时应该在属性的摘要文档中引用set访问器。通常,这些规则要求set访问者只要对get访问者的同一组调用者可见,或者只要它对外部类或继承类可见即可被引用。
确定是否包括财产的总结文件中的set访问的具体规则是:
1。set访问者与get访问者具有相同的访问级别。例如:
/// <summary>
/// Gets or sets the name of the customer.
/// </summary>
protected string Name
{
get { return this.name; }
set { this.name = value; }
}
2.该属性仅在组件内部可访问,并且set访问器也具有内部访问权限。例如:
internal class Class1
{
/// <summary>
/// Gets or sets the name of the customer.
/// </summary>
protected string Name
{
get { return this.name; }
internal set { this.name = value; }
}
}
internal class Class1
{
public class Class2
{
/// <summary>
/// Gets or sets the name of the customer.
/// </summary>
public string Name
{
get { return this.name; }
internal set { this.name = value; }
}
}
}
3.财产是私有或包含在私有类的下方,并set访问具有比其他私人任何访问修饰符。在下面的示例中,set访问器上声明的访问修饰符没有意义,因为set访问器包含在一个私有类中,因此不能被Class1之外的其他类看到。这有效地为set访问者提供与get访问者相同的访问级别。
public class Class1
{
private class Class2
{
public class Class3
{
/// <summary>
/// Gets or sets the name of the customer.
/// </summary>
public string Name
{
get { return this.name; }
internal set { this.name = value; }
}
}
}
}
4.每当set访问器保护或保护内部访问时,应该在文档中引用它。受保护或受保护的内部集合访问器始终可以被从包含该属性的类继承的类看到。
internal class Class1
{
public class Class2
{
/// <summary>
/// Gets or sets the name of the customer.
/// </summary>
internal string Name
{
get { return this.name; }
protected set { this.name = value; }
}
}
private class Class3 : Class2
{
public Class3(string name) { this.Name = name; }
}
}
- 1. 记录类属性
- 2. 如何记录对象属性?
- 3. 如何在Xcode中记录@IBInspectable属性
- 4. YUIDoc/javascript - 如何记录模块属性
- 5. 如何访问记录属性?
- 6. 如何仅记录类图中显示的属性?
- 7. 如何在phpdocumentor的类中正确记录数组属性?
- 8. 记录异常属性
- 9. 扩展属性记录
- 10. 选择属性记录
- 11. 未记录的CSS属性
- 12. 栏目列表记录属性如x
- 13. C#WPF类属性标记
- 14. 如何:MySQL如何根据三个属性检索记录?
- 15. 如何根据记录获取具有一定数量属性的记录?
- 16. C#类目录和属性
- 17. 如何动态更改给定数据记录的字段属性的属性?
- 18. 我该如何使用Numpy风格来记录类和对象的属性?
- 19. 如何使用MySQL数据库中的记录动态分配类属性?
- 20. JSDoc3 - 如何记录一类
- 21. nHibernate - 追踪“脏”属性以记录历史记录
- 22. JavaScript打印记录的属性保存在记录中
- 23. 在java日志记录中默认记录通用属性
- 24. ActiveRecord:通过嵌套记录属性筛选记录
- 25. 基于虚拟属性设置主动记录属性
- 26. 在扩展日志记录类中访问log4j属性
- 27. 德尔福RTTI迭代通用的记录类型的属性
- 28. 在Delphi COM向导中使用记录作为属性类型
- 29. 为MVC4中的Dropdownlist的某些记录设置类属性
- 30. 定义变量是记录属性的类型PL/SQL
M $有关于它的一些建议:http://msdn.microsoft.com/en-us/library/5ast78ax.aspx他们只是建议,但 - 你可以使用任何你喜欢你的自定义生成器。还有一些标签用于智能感应。 – 2010-10-15 14:08:21
可能希望将“XML”作为标记添加到您的问题中。 – KSwift87 2010-10-15 14:08:41