Standardmäßig ist der Prompt ausgewählt, der zuerst die Quelle prüft. Sie können zu einem direkten Befehl wechseln oder eine lokale Kopie herunterladen.
Quelldateien prüfen
Lesen Sie SKILL.md und alle von SkillsMP angezeigten Begleitdateien, bevor Sie sich für eine Installation entscheiden.
Mit Codex oder Claude installieren Kopieren Sie diesen Prompt, fügen Sie ihn in Codex, Claude oder einen anderen Assistant ein und lassen Sie die Skill-Seite prüfen und installieren.
Ein direkter Befehl überspringt den Prüf-Prompt. Prüfen Sie die Quelle, bevor Sie ihn ausführen.
{"short-description":".NET skill guidance for csharp tasks"}
dotnet-csharp-coding-standards
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.
Activation Guidance
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.
Scope
Naming conventions (PascalCase, camelCase, I-prefix for interfaces)
File organization and namespace conventions
Code style rules (expression bodies, using directives, var usage)
EditorConfig integration for style enforcement
Out of scope
Language feature patterns (records, pattern matching) -- see [skill:dotnet-csharp-modern-patterns]
Async naming and await conventions -- see [skill:dotnet-csharp-async-patterns]
SOLID/DRY design principles -- see [skill:dotnet-solid-principles]
Code smells and anti-patterns -- see [skill:dotnet-csharp-code-smells]
Naming Conventions
General Rules
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
Async Method Naming
Suffix async methods with Async:
// Correctpublic Task<Order> GetOrderAsync(int id);
public ValueTask SaveChangesAsync(CancellationToken ct);
// Wrongpublic Task<Order> GetOrder(int id); // missing Async suffixpublic Task<Order> GetOrderTask(int id); // wrong suffix
```text
Exception: Event handlers andinterfaceimplementationswheretheframeworkdoesnotusethe `Async` suffix (e.g.,
ASP.NETCoremiddleware `InvokeAsync` isalreadynamedbytheframework).
### BooleanNamingPrefixbooleanswith `is`, `has`, `can`, `should`, orsimilar:
```
{ ; ; }
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: -
csharp
public
bool
IsActive
get
set
public
bool
get
publicboolCanDelete(Order order)
### Collection Naming
for
public
get
// not OrderList
public
string
int
get
// descriptive
## File Organization
### One Type Per File
level type (class, record, struct, interface, enum) should be in its own file, named exactly as the type.
Nested types stay in the containing type's file.
```text
OrderService.cs -> publicclass OrderService
IOrderRepository.cs -> publicinterface IOrderRepository
OrderStatus.cs -> publicenum OrderStatus
OrderSummary.cs -> publicrecord OrderSummary
```csharp
### File-Scoped Namespaces
Always use file-scopednamespaces (C# 10+):
```csharp
// Correctnamespace MyApp.Services
# Language Design Notes (Mads Torgersen et al.)** -- Design rationale behind C# language features that affect
this
file
scopednamespaces (reducing nesting for readability),
pattern matching over type checks (expressiveness), `required` members (compile-time initialization safety), and `var`
usage guidelines (readability-first). The language design team explicitly chose these features to reduce ceremony
while maintaining safety. Source: https://github.com/dotnet/csharplang/tree/main/meetings
> **Note:** This skill applies publicly documented design rationale. It does not represent or speak for the named
> sources.
## Code Navigation (Serena MCP)
**Primary approach:** Use Serena symbol operations for efficient code navigation:
1. **Find definitions**: `serena_find_symbol` instead of text search
2. **Understand structure**: `serena_get_symbols_overview` forfile organization
3. **Track references**: `serena_find_referencing_symbols` for impact analysis
4. **Precise edits**: `serena_replace_symbol_body` for clean modifications
**When to use Serena vs traditional tools:**
- ✅ **Use Serena**: Navigation, refactoring, dependency analysis, precise edits
- ✅ **Use Read/Grep**: Reading full files, pattern matching, simple text operations
- ✅ **Fallback**: If Serena unavailable, traditional tools work fine
**Example workflow:**
```text
# Instead of:
Read: src/Services/OrderService.cs
Grep: "publicvoid ProcessOrder"
# Use:
serena_find_symbol: "OrderService/ProcessOrder"
serena_get_symbols_overview: "src/Services/OrderService.cs"
```
## References
- [Framework Design Guidelines](https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/)
- [C# Coding Conventions](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/coding-conventions)
- [C# Identifier Naming Rules](https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/coding-style/identifier-names)
- [.editorconfig for .NET](https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options)
- [C# Language Design Notes](https://github.com/dotnet/csharplang/tree/main/meetings)