用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/rudironsoni/Synaxis --skill dotnet-csharp-coding-standards命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Routes .NET/C# work to domain skills. Loads coding-standards for code paths.
基于 SOC 职业分类
正在显示 SKILL.md
| name | dotnet-csharp-coding-standards |
| description | Defines baseline C# conventions loaded first -- naming, file layout, style rules. |
Modern .NET coding standards based on Microsoft Framework Design Guidelines and C# Coding Conventions. This skill covers naming, file organization, and code style rules that agents should follow when generating or reviewing C# code.
Load this skill by default for any task that plans, designs, generates, modifies, or reviews C#/.NET code. Do not wait for explicit user wording such as "coding standards", "style", or "conventions". If code will be produced, this skill should be active before implementation starts. This skill is a baseline dependency that should be loaded before domain-specific C#/.NET skills.
Cross-references: [skill:dotnet-csharp-modern-patterns] for language feature usage, [skill:dotnet-csharp-async-patterns] for async naming conventions, [skill:dotnet-solid-principles] for SOLID, DRY, and SRP design principles at the class and interface level.
| Element | Convention | Example |
|---|---|---|
| Namespaces | PascalCase, dot-separated | MyCompany.MyProduct.Core |
| Classes, Records, Structs | PascalCase | OrderService, OrderSummary |
| Interfaces | I + PascalCase | IOrderRepository |
| Methods | PascalCase | GetOrderAsync |
| Properties | PascalCase | OrderDate |
| Events | PascalCase | OrderCompleted |
| Public constants | PascalCase | MaxRetryCount |
| Private fields | _camelCase | _orderRepository |
| Parameters, locals | camelCase | orderId, totalAmount |
| Type parameters | T or T + PascalCase | T, TKey, TValue |
| Enum members | PascalCase | OrderStatus.Pending |
Suffix async methods with Async:
// Correct
public Task<Order> GetOrderAsync(int id);
public ValueTask SaveChangesAsync(CancellationToken ct);
// Wrong
public Task<Order> GetOrder(int id); // missing Async suffix
public Task<Order> GetOrderTask(int id); // wrong suffix
```text
Exception: Event handlers and interface implementations where the framework does not use the `Async` suffix (e.g.,
ASP.NET Core middleware `InvokeAsync` is already named by the framework).
### Boolean Naming
Prefix booleans with `is`, `has`, `can`, `should`, or similar:
```
{ ; ; }
HasOrders { ; }
;
```csharp
Use plural nouns collections:
```csharp
IReadOnlyList<Order> Orders { ; }
Dictionary<, > CountsByName { ; }
```csharp
---
Each top-;
{ }
{
{ }
}
```text
Place `` directives at the top of the , outside the . With `<ImplicitUsings>enable</ImplicitUsings>`
( modern .NET), common namespaces are already imported. Only `` statements namespaces
covered usings.
Order of `` directives:
`System.*` namespaces
Third-party namespaces
Project namespaces
Organize feature layer, matching :
```
//
/
/
/
/
/
```
---
##
###
, - :
```
()
{
Process(order);
}
(order.IsValid)
Process(order);
```text
Use expression bodies single-expression members:
```csharp
FullName => ;
=> ;
```text
Use `` the type obvious the right-hand side:
```csharp
orders = List<Order>();
customer = GetCustomerById(id);
name = ;
IOrderRepository repo = serviceProvider.GetRequiredService<IOrderRepository>();
total = CalculateTotal(items);
```text
Prefer pattern matching over checks:
```csharp
(order ) { }
(order { Status: OrderStatus.Active }) { }
(order != ) { }
(order ) { }
(!(order )) { }
```text
Use -conditional -coalescing operators:
```csharp
name = customer?.Name ?? ;
orders = customer?.Orders ?? [];
items ??= [];
```csharp
Prefer interpolation over concatenation `.Format`:
```csharp
message = ;
json = $idname{{name}};
message = .Format(, orderId, total);
message = + orderId + + total.ToString();
```text
---
Always specify access modifiers explicitly. Do rely defaults:
```csharp
{
IOrderRepository _repo;
{ }
}
{
IOrderRepository _repo;
}
```text
Follow the standard order:
``` = ;
=> repo.GetDefaultAsync();
=> Name;
```csharp
---
These conventions implement SOLID DRY principles at the code level. For comprehensive coverage anti-patterns
fixes, see [skill:dotnet-solid-principles].
Seal classes that are designed inheritance.
{
}
```text
Only leave classes unsealed you explicitly design them classes.
```csharp
{
{
validator.ValidateAsync(order);
notifier.NotifyAsync(order);
}
}
{ }
: { }
: { }
```text
Keep interfaces focused. Prefer multiple small interfaces over one large one:
```csharp
{
Task<Order?> GetByIdAsync( id, CancellationToken ct = );
Task<IReadOnlyList<Order>> GetAllAsync(CancellationToken ct = );
}
{
;
;
}
: , { }
```text
---
Accept `CancellationToken` the last parameter methods. Use `` the optional
tokens:
```
{
_repo.GetByIdAsync(id, ct);
}
```text
Always forward the token to downstream calls. Never ignore a received `CancellationToken`.
---
Add XML docs to API surfaces. Keep them concise:
```csharp
Task<Order?> GetByIdAsync( id, CancellationToken ct = );
```text
Do XML docs to:
- = file_scoped:warning
csharp_prefer_braces = :warning
csharp_style_var_for_built_in_types = :suggestion
csharp_style_var_when_type_is_apparent = :suggestion
dotnet_style_require_accessibility_modifiers = always:warning
csharp_style_prefer_pattern_matching = :suggestion
```csharp
See [skill:dotnet--analyzers] full analyzer configuration.
---
Conventions skill are grounded publicly available content :
- **Microsoft Framework Design Guidelines** -- The canonical reference .NET naming, type design, API surface
conventions. Source: https:
- **C
coding standards. Key decisions relevant to skill: -