modern-csharp-coding-standards
Audited by Runlayer on Feb 22, 2026
Malicious tool definition detected
Tool: SKILL.md [1/6] Description: --- name: modern-csharp-coding-standards description: Write modern, high-performance C# code using records, pattern matching, value objects, async/await, Span<T>/Memory<T>, and best-practice API design patterns.
Tool: SKILL.md [2/6] Description: Property patterns public decimal CalculateDiscount(Order order) => order switch { { Total: > 1000m } => order.Total * 0.15m, { Total: > 500m } => order.Total * 0.10m, { Total: > 100m } => order.Total * 0.05m, _ => 0m }; // Relational and logical patterns public string ClassifyTemperature(int temp) => temp switch { < 0 => "Freezing", >= 0 and < 10 => "Cold", >= 10 and < 20 => "Cool", >= 20 and < 30 => "Warm", >= 30 => "Hot", _ => throw new ArgumentOutOfRangeExcep
Tool: SKILL.md [3/6] Description: Task<List<Order>> GetOrdersAsync( string customerId, CancellationToken cancellationToken = default) { var orders = await _repository.GetOrdersByCustomerAsync(customerId, cancellationToken); return orders; } // Pass cancellation through the call stack public async Task<OrderSummary> GetOrderSummaryAsync( string customerId, CancellationToken cancellationToken = default) { var orders = await GetOrdersAsync(customerId, cancellationToken); var total = orders.Sum(o =>
Tool: SKILL.md [4/6] Description: | Need count | `IReadOnlyCollection<T>` | `IReadOnlyCollection<T>` | | Need indexing | `IReadOnlyList<T>` | `IReadOnlyList<T>` | | High-performance, sync | `ReadOnlySpan<T>` | `Span<T>` (rarely) | | Async streaming | `IAsyncEnumerable<T>` | `IAsyncEnumerable<T>` | | Caller needs mutation | - | `List<T>`, `T[]` | --- ### Method Signatures Best Practices ```csharp // ✅ GOOD: Complete async method signature public async Task<Result<Order, OrderError>> CreateOrderAs
Tool: SKILL.md [5/6] Description: explicit and traceable var dto = entity.ToDto(); var entity = request.ToEntity(); ``` ### Benefits of Explicit Mappings | Aspect | AutoMapper | Explicit Methods | |--------|------------|------------------| | **Compile-time safety** | No - runtime errors | Yes - compiler catches mismatches | | **Discoverability** | Hidden in profiles | "Go to Definition" works | | **Debugging** | Black box | Step through code | | **Refactoring** | Rename breaks silently | IDE ren
Tool: SKILL.md [6/6] Description: Money Total => new( UnitPrice.Amount * Quantity.Value, UnitPrice.Currency); } // 4.