首页 > 编程语言 >C#教程 - 标准XML标签(Standard XML Documentation Tags)

C#教程 - 标准XML标签(Standard XML Documentation Tags)

时间:2022-09-22 09:14:18浏览次数:79  
标签:XML ... Tags C# member generators employee type

更新记录
转载请注明出处:
2022年9月22日 发布。
2022年9月10日 从笔记迁移到博客。

标准XML标签(Standard XML Documentation Tags)

<summary>    //简要说明
<param>     //参数说明
<returns>    //返回值说明
<example>    //实例说明
<code>          //代码说明
<seealso>    //see also 选项说明
<value>     //描述属性

标记使用方法:
https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/xmldoc/recommended-tags-for-documentation-comments

<summary>...</summary>

Indicates the tool tip that IntelliSense should display for the type or member.
Typically, a single phrase or sentence.

<remarks>...</remarks>

Additional text that describes the type or member.
Documentation generators pick this up and merge it into the bulk of a type or member’s description.

<param name="name">...</param>

Explains a parameter on a method.

<returns>...</returns>

Explains the return value for a method.

<exception [cref="type"]>...</exception>

Lists an exception that a method might throw (cref refers to the exception type).
cref指示异常的类型

<permission [cref="type"]>...</permission>

Indicates an IPermission type required by the documented type or member.

<example>...</example>

Denotes an example (used by documentation generators).
This usually contains both description text and source code
(source code is typically within a or tag).

<c>...</c>

Indicates an inline code snippet. This tag is usually used within an block.

<code>...</code>

Indicates a multiline code sample. This tag is usually used within an block.
一般放置在

<see cref="member">...</see>

Inserts an inline cross-reference to another type or member.
HTML documentation generators typically convert this to a hyperlink.
The compiler emits a warning if the type or member name is invalid.

<seealso cref="member">...</seealso>

Cross-references another type or member.
Documentation generators typically write this
into a separate “See Also” section at the bottom of the page.

<paramref name="name"/>

References a parameter from within a

or tag.

<list>...</list>
<list type=[ bullet | number | table ]>
 <listheader>
  <term>...</term>
  <description>...</description>
 </listheader>
 <item>
  <term>...</term>
  <description>...</description>
 </item>
</list>

Instructs documentation generators to emit a bulleted, numbered, or table-style list.

<para>...</para>

Instructs documentation generators to format the contents into a separate paragraph.

<include>...</include>
<include file='filename' path='tagpath[@name="id"]'>
  ...
</include>

Merges an external XML file that contains documentation. The path attribute denotes an XPath query to a specific element in that file.

注释实例

/// <summary>
/// DataStorage is used to persist and retrieve
/// employee data from the files
/// </summary>
class DataStorage
{
    /// <summary>
    /// Save an employee object to a file
    /// named with the employee name
    /// </summary>
    /// <remarks>
    /// This method uses
    /// <seealso cref="System.IO.FileStream"/>
    /// in addition to
    /// <seealso cref="System.IO.StreamWriter"/>
    /// </remarks>
    /// <param name="employee">
    /// The employee to persist to a file</param>
    /// <data>January 1, 2000</date>
    public static void Store(Employee employee)
    {
        // ...
    }
    /** <summary>
    * Loads up an employee object
    * </summary>
    * <remarks>
    * This method uses
    * <seealso cref="System.IO.FileStream"/>
    * in addition to
    * <seealso cref="System.IO.StreamReader"/>
    * </remarks>
    * <param name="firstName">
    * The first name of the employeee</param>
    * <param name="lastName">
    * The last name of the employee</param>
    * <returns>
    * The employee object corresponding to the names
    * </returns>
    * <date>January 1, 2000</date>**/
    public static Employee Load(string firstName, string lastName)
    {
        // ...
    }
}

配置项目的XML注释文档导出

在.csproj 项目配置文件中,添加以下代码

<PropertyGroup>
  <DocumentationFile>SomeFile.xml</DocumentationFile>
</PropertyGroup>

作用:
智能提示(IntelliSense),比如Visual Studio中
使用第三方工具生成代码的文档

第三方XML生成API文档工具

NDoc http://ndoc.sourceforge.net/
Sandcastle https://github.com/EWSoftware/SHFB
XmlCommentMarkDownGenerator https://github.com/Pxtl/XmlCommentMarkDownGenerator
GhostDoc http://submain.com/
编译器输出XML文档:https://docs.microsoft.com/zh-cn/dotnet/csharp/language-reference/compiler-options/doc-compiler-option

标签:XML,...,Tags,C#,member,generators,employee,type
From: https://www.cnblogs.com/cqpanda/p/16712675.html

相关文章

  • C#教程 - 编译器(Compile)
    更新记录转载请注明出处:2022年9月22日发布。2022年9月10日从笔记迁移到博客。编译器的类型csc//.NETFrameworkmsc//Monodotnet//.NetCoreC#......
  • static关键字
    static为编程语言中的一个关键字,是一种修饰符,既可以修饰变量也可以修饰方法在类中,用static声明的成员变量为静态成员变量,也称之为类变量,类变量的生命周期和类相同,在整个......
  • Kubectl 日志输出详细程度和调试
    引用自:https://kubernetes.io/zh-cn/docs/reference/kubectl/cheatsheet/#kubectl-日志输出详细程度和调试Kubectl日志输出详细程度是通过-v或者--v来控制的,参数后跟......
  • 第一章:TypeScript快速入门
    一、TypeScript开发环境搭建1、TypeScript有什么用编译时的强类型模块化已有的类库可以很方便的使用2、下载Node.jsnode.js官网:Node.js(nodejs.org)......
  • 删除Console密码
    场景:当telnet、ssh等方式无法管理设备且console口密码被忘记时。华为设备清除方法盒式V100R002/V100R003删除Console密码重启交换机,进入BootRoM菜单后,选择5.Enterfil......
  • 【笔记】P1606 [USACO07FEB]Lilypad Pond G 及相关
    题目传送门建图首先,根据题目,可以判断出这是一道最短路计数问题。但是要跑最短路,首先要用他给的信息建图,这是非常关键的一步。根据题意,我们可以想出以下建图规则:起点......
  • CSS的优先级如何计算?
    选择器的特殊性值分为四个等级行内样式:X000id选择器:0X00类选择器/伪类选择器/属性选择器:00X0元素选择器/伪元素选择器:000X在判断优先级时先看是否......
  • 使用tensorbaoardx报错——Descriptors cannot not be created directly. If this cal
    运行代码报错:fromtensorboardXimportSummaryWriter  报错内容:   发生异常:TypeErrorDescriptorscannotnotbecreateddirectly.Ifthiscallc......
  • Python cv2(Opencv) 图像基本操作
    OpenCV是一个基于Apache2.0许可(开源)发行的跨平台计算机视觉和机器学习软件库,可以运行在Linux、Windows、Android和MacOS操作系统上。它轻量级而且高效,由一系列C函数和少......
  • CSP-S模拟8
    Cat最喜欢清北营赛制了!但是这个赛制暗示了以下全是鬼畜题…… A.选举居然可以dp,我本来以为是贪心的题,联想到了学长提到的过关得到相应的星星,可以选择拿1颗或两颗,代价......