review-dotnet
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSkill: Review .NET
技能:.NET代码审查
Purpose
目的
Review code in the .NET ecosystem (C#, F#) for language and runtime conventions only. Do not define scope (diff vs codebase) or perform security/architecture analysis; those are handled by scope and cognitive skills. Emit a findings list in the standard format for aggregation. Focus on async/await and ConfigureAwait, nullable reference types and NRE avoidance, API and versioning, resources and IDisposable, collections and LINQ, and testability.
仅审查.NET生态(C#、F#)下的代码是否符合语言及运行时规范。无需定义审查范围(差异对比 vs 整个代码库),也无需进行安全/架构分析;这些工作由范围类技能和认知类技能负责。输出符合标准格式的问题发现列表,便于汇总。重点审查async/await与ConfigureAwait的使用、可空引用类型与空引用异常(NRE)避免、API与版本控制、资源与IDisposable、集合与LINQ,以及可测试性。
Use Cases
适用场景
- Orchestrated review: Used as the language step when review-code runs scope → language → framework → library → cognitive for .NET projects.
- .NET-only review: When the user wants only language/runtime conventions checked (e.g. after adding a new C# file).
- Pre-PR .NET checklist: Ensure async, nullable, and resource patterns are correct.
When to use: When the code under review is .NET (C#/F#) and the task includes language/runtime quality. Scope (diff vs paths) is determined by the caller or user.
- 编排式审查:当review-code针对.NET项目按“范围→语言→框架→库→认知”的流程运行时,作为语言审查步骤使用。
- 仅.NET审查:当用户仅需检查语言/运行时规范时(例如添加新C#文件后)。
- PR前.NET检查清单:确保async、可空类型及资源管理模式的正确性。
何时使用:当待审查的代码为.NET(C#/F#)且任务包含语言/运行时质量检查时。审查范围(差异对比 vs 指定路径)由调用方或用户决定。
Behavior
行为规范
Scope of this skill
技能范围
- Analyze: .NET language and runtime conventions in the given code scope (files or diff provided by the caller). Do not decide scope; accept the code range as input.
- Do not: Perform scope selection (diff vs codebase), security review, or architecture review; do not review non-.NET files unless asked to ignore language.
- 分析内容:在给定代码范围(由调用方提供的文件或差异)内,检查.NET语言及运行时规范。无需自行决定范围,直接接受输入的代码范围即可。
- 禁止操作:不要进行范围选择(差异对比 vs 整个代码库)、安全审查或架构审查;除非明确要求忽略语言类型,否则不要审查非.NET文件。
Review checklist (.NET dimension only)
.NET维度审查清单
- async/await and ConfigureAwait: Correct use of async; ConfigureAwait(false) where appropriate (library code); cancellation token propagation; avoid async void except event handlers.
- Nullable reference types and NRE: Nullable annotations; null checks and null-forgiving where justified; avoid unnecessary null-forgiving.
- API and versioning: Public API surface stability; breaking changes; versioning or deprecation strategy for libraries.
- Resources and IDisposable: Proper use of IDisposable, using statements, and IAsyncDisposable; no leaking handles or streams.
- Collections and LINQ: Appropriate use of LINQ; allocation and enumeration; avoid multiple enumeration; span/memory where relevant.
- Testability: Dependency injection and testability; static usage; sealed/overridable where it affects testing.
- async/await与ConfigureAwait:正确使用async;在合适的场景(如库代码)中使用ConfigureAwait(false);传递取消令牌;除非是事件处理程序,否则避免使用async void。
- 可空引用类型与NRE:可空注解;合理的空检查与空原谅运算符使用;避免不必要的空原谅运算符。
- API与版本控制:公共API表面的稳定性;破坏性变更;库的版本控制或弃用策略。
- 资源与IDisposable:正确使用IDisposable、using语句及IAsyncDisposable;避免句柄或流泄漏。
- 集合与LINQ:合理使用LINQ;内存分配与枚举;避免多次枚举;在相关场景下使用span/memory。
- 可测试性:依赖注入与可测试性;静态方法的使用;密封/可重写对测试的影响。
Tone and references
语气与参考
- Professional and technical: Reference specific locations (file:line). Emit findings with Location, Category, Severity, Title, Description, Suggestion.
- 专业且技术化:引用具体位置(文件:行号)。输出的问题发现需包含位置、类别、严重程度、标题、描述、建议。
Input & Output
输入与输出
Input
输入
- Code scope: Files or directories (or diff) already selected by the user or by the scope skill. This skill does not decide scope; it reviews the provided .NET code for language conventions only.
- 代码范围:由用户或范围类技能已选定的文件、目录(或差异)。本技能不负责决定范围,仅针对提供的.NET代码审查语言规范。
Output
输出
- Emit zero or more findings in the format defined in Appendix: Output contract.
- Category for this skill is language-dotnet.
- 输出零个或多个符合附录:输出约定格式的问题发现。
- 本技能的类别为language-dotnet。
Restrictions
限制
- Do not perform security, architecture, or scope selection. Stay within .NET language and runtime conventions.
- Do not give conclusions without specific locations or actionable suggestions.
- Do not review non-.NET code for .NET-specific rules unless the user explicitly includes it (e.g. embedded scripts).
- 禁止进行安全审查、架构审查或范围选择。仅专注于.NET语言及运行时规范。
- 禁止在没有具体位置或可操作建议的情况下给出结论。
- 禁止针对非.NET文件审查.NET特定规则,除非用户明确要求(例如嵌入的脚本)。
Self-Check
自我检查
- Was only the .NET language/runtime dimension reviewed (no scope/security/architecture)?
- Are async, nullable, IDisposable, LINQ, and testability covered where relevant?
- Is each finding emitted with Location, Category=language-dotnet, Severity, Title, Description, and optional Suggestion?
- Are issues referenced with file:line?
- 是否仅审查了.NET语言/运行时维度(未涉及范围/安全/架构)?
- 是否覆盖了相关的async、可空类型、IDisposable、LINQ及可测试性内容?
- 每个问题发现是否都包含位置、类别=language-dotnet、严重程度、标题、描述及可选的建议?
- 是否引用了文件:行号?
Examples
示例
Example 1: Async method
示例1:异步方法
- Input: C# method that is async and calls other async methods without passing CancellationToken.
- Expected: Emit a finding (e.g. minor/suggestion) for CancellationToken propagation; reference the method and parameter list. Category = language-dotnet.
- 输入:一个异步C#方法,调用其他异步方法但未传递CancellationToken。
- 预期输出:输出一个关于CancellationToken传递的问题发现(例如:次要/建议级别);引用该方法及参数列表。类别=language-dotnet。
Example 2: Nullable and disposal
示例2:可空类型与资源释放
- Input: C# class that holds an IDisposable and does not implement IDisposable or use using.
- Expected: Emit finding(s) for resource disposal and possibly nullable if the field can be null. Category = language-dotnet.
- 输入:一个持有IDisposable实例但未实现IDisposable或使用using语句的C#类。
- 预期输出:输出关于资源释放的问题发现,若字段可为空则同时输出可空类型相关问题。类别=language-dotnet。
Edge case: Mixed C# and SQL
边缘案例:混合C#与SQL
- Input: File with C# and embedded SQL strings.
- Expected: Review only the C# parts for .NET conventions (e.g. async, nullable, disposal). Do not emit SQL-injection findings; that is for review-security or review-sql.
- 输入:包含C#及嵌入SQL字符串的文件。
- 预期输出:仅审查C#部分的.NET规范(例如async、可空类型、资源释放)。不要输出SQL注入相关的问题发现;这类问题由review-security或review-sql技能处理。
Appendix: Output contract
附录:输出约定
Each finding MUST follow the standard findings format:
| Element | Requirement |
|---|---|
| Location | |
| Category | |
| Severity | |
| Title | Short one-line summary. |
| Description | 1–3 sentences. |
| Suggestion | Concrete fix or improvement (optional). |
Example:
markdown
- **Location**: `src/Services/DataLoader.cs:22`
- **Category**: language-dotnet
- **Severity**: minor
- **Title**: Async method does not accept or forward CancellationToken
- **Description**: Long-running or cancellable operations should support cancellation.
- **Suggestion**: Add CancellationToken parameter and pass it to underlying async calls.每个问题发现必须遵循以下标准格式:
| 元素 | 要求 |
|---|---|
| 位置 | |
| 类别 | |
| 严重程度 | |
| 标题 | 简短的单行摘要。 |
| 描述 | 1–3句话。 |
| 建议 | 具体的修复或改进方案(可选)。 |
示例:
markdown
- **Location**: `src/Services/DataLoader.cs:22`
- **Category**: language-dotnet
- **Severity**: minor
- **Title**: Async method does not accept or forward CancellationToken
- **Description**: Long-running or cancellable operations should support cancellation.
- **Suggestion**: Add CancellationToken parameter and pass it to underlying async calls.