csharp-docs
它能做什么
这个智能体可以帮你为 C# 代码添加文档注释,让代码更容易理解。它会确保注释遵循最佳实践,让其他程序员(或将来的你自己)都能看懂代码的作用。
适用场景
- ✓在编写会与他人共享的 C# 代码时。
- ✓在创建其他开发者会使用的库或 API 时。
- ✓为了提高你自己 C# 代码的清晰度和可维护性。
技能链接
https://github.com/github/awesome-copilot/blob/main/skills/csharp-docs/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请按照最佳实践,为我的 C# 代码中的公共成员和内部成员添加 XML 文档。”
每周 5 个新技能,1 分钟读完。
工作原理
这个智能体会分析你的 C# 代码,并在合适的位置插入 XML 注释(`///`),例如类、方法和属性的前面。它会使用 `<summary>`、`<remarks>` 和 `<param>` 等特定标签,说明代码的用途、细节和参数。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
C# Documentation Best Practices
- Public members should be documented with XML comments.
- It is encouraged to document internal members as well, especially if they are complex or not self-explanatory.
Guidance for all APIs
- Use
<summary>to provide a brief, one sentence, description of what the type or member does. Start the summary with a present-tense, third-person verb. - Use
<remarks>for additional information, which can include implementation details, usage notes, or any other relevant context. - Use
<see langword>for language-specific keywords likenull,true,false,int,bool, etc. - Use
<c>for inline code snippets. - Use
<example>for usage examples on how to use the member.- Use
<code>for code blocks.<code>tags should be placed within an<example>tag. Add the language of the code example using thelanguageattribute, for example,<code language="csharp">.
- Use
- Use
<see cref>to reference other types or members inline (in a sentence). - Use
<seealso>for standalone (not in a sentence) references to other types or members in the "See also" section of the online docs. - Use
<inheritdoc/>to inherit documentation from base classes or interfaces.- Unless there is major behavior change, in which case you should document the differences.
Methods
- Use
<param>to describe method parameters.- The description should be a noun phrase that doesn't specify the data type.
- Begin with an introductory article.
- If the parameter is a flag enum, start the description with "A bitwise combination of the enumeration values that specifies...".
- If the parameter is a non-flag enum, start the description with "One of the enumeration values that specifies...".
- If the parameter is a Boolean, the wording should be of the form "
<see langword="true" />to ...; otherwise,<see langword="false" />.". - If the parameter is an "out" parameter, the wording should be of the form "When this method returns, contains .... This parameter is treated as uninitialized.".
- Use
<paramref>to reference parameter names in documentation. - Use
<typeparam>to describe type parameters in generic types or methods. - Use
<typeparamref>to reference type parameters in documentation. - Use
<returns>to describe what the method returns.- The description should be a noun phrase that doesn't specify the data type.
- Begin with an introductory article.
- If the return type is Boolean, the wording should be of the form "
<see langword="true" />if ...; otherwise,<see langword="false" />.".
Constructors
- The summary wording should be "Initializes a new instance of the <Class> class [or struct].".
Properties
- The
<summary>should start with:- "Gets or sets..." for a read-write property.
- "Gets..." for a read-only property.
- "Gets [or sets] a value that indicates whether..." for properties that return a Boolean value.
- Use
<value>to describe the value of the property.- The description should be a noun phrase that doesn't specify the data type.
- If the property has a default value, add it in a separate sentence, for example, "The default is
<see langword="false" />". - If the value type is Boolean, the wording should be of the form "
<see langword="true" />if ...; otherwise,<see langword="false" />. The default is ...".
Exceptions
- Use
<exception cref>to document exceptions thrown by constructors, properties, indexers, methods, operators, and events. - Document all exceptions thrown directly by the member.
- For exceptions thrown by nested members, document only the exceptions users are most likely to encounter.
- The description of the exception describes the condition under which it's thrown.
- Omit "Thrown if ..." or "If ..." at the beginning of the sentence. Just state the condition directly, for example "An error occurred when accessing a Message Queuing API."
常见问题
C# 中的 XML 注释是什么?
这是 C# 代码中一种特殊的注释,使用 XML 标签(比如 `<summary>`)来描述代码的作用。工具可以利用这些注释自动生成文档。
为什么要为内部成员添加文档?
虽然不是必须的,但为内部成员添加文档有助于解释复杂或不直观的代码部分,让维护者更容易理解。
什么是 `<inheritdoc/>`?
这是一个标签,用来告诉编译器从父成员(比如基类或接口)复制文档到当前成员。当行为相同时,这样可以避免重复编写代码。
详情
作者的原始描述
Ensure that C# types are documented with XML comments and follow best practices for documentation.
repo: github/awesome-copilot
热度
- GitHub 星标
- 40k
- 排名
- #7152
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
acquire-codebase-knowledge
40k帮你的智能体理解并编写现有代码项目的文档。它有助于新成员快速上手,或者快速了解项目架构。
acreadiness-assess
40k让你的智能体评估一个项目对 AI 的准备程度,并生成报告。它有助于了解项目在使用 AI 工具方面的准备情况。
acreadiness-generate-instructions
40k帮你的智能体根据评估结果编写 AI 工具的指令文件。它有助于改善 AI 与代码的交互方式,并弥补已发现的不足。
acreadiness-policy
40k让你的智能体协助制定或应用 AI 项目评估的政策。它有助于规范项目的评估方式,并确保合规。