mit einem Klick
csharp-coding-guidelines
// C# / .NET 10 coding guidelines for building maintainable, performant, and secure applications. Use this skill when generating C# or .NET code for applications.
// C# / .NET 10 coding guidelines for building maintainable, performant, and secure applications. Use this skill when generating C# or .NET code for applications.
This skill describes how to implement the server part of Server-Sent Events (SSE) in modern .NET (ASP.NET Core). Use this skill when the user asks about "SSE in .NET / ASP.NET Core".
Angular and TypeScript coding guidelines for building maintainable, performant, and accessible web applications. Use this skill when generating TypeScript or Angular code for web applications.
Best practices for frontend design, including layout, styling, and user experience considerations.
| name | csharp-coding-guidelines |
| description | C# / .NET 10 coding guidelines for building maintainable, performant, and secure applications. Use this skill when generating C# or .NET code for applications. |
You are an expert in modern C# and .NET 10 development. You write maintainable, performant, and secure code aligned with current .NET ecosystem best practices.
var when the type is obvious from the right-hand side.using directives at the top of the file; avoid unnecessary global using unless it reduces real duplication.ArgumentNullException.ThrowIfNull, is null checks, required members, and correct annotations).record / record struct where value semantics fit.init-only setters and read-only collections.switch expressions, property patterns, and is patterns.required members judiciously for DTOs/options where it improves correctness.Span<T>/ReadOnlySpan<T> and System.Text APIs for performance-critical code, but keep code readable and only optimize when it matters..Result and .Wait().Task/Task<T> (or ValueTask only when justified by profiling and allocations).CancellationToken through all public async entry points where cancellation is meaningful.ConfigureAwait(false); for ASP.NET Core app code it’s typically unnecessary.ArgumentException, InvalidOperationException, etc.).ArgumentException.ThrowIfNull, ArgumentException.ThrowIfNullOrEmpty, and ArgumentException.ThrowIfNullOrWhiteSpace; avoid manual if statements.Results<Ok<T>, NotFound>), but avoid over-engineering.IServiceProvider/HttpContext.RequestServices only when needed.IOptions<T>) and keep configuration strongly typed.ToListAsync, SingleOrDefaultAsync, etc.).AsNoTracking() for read-only queries.DbContext scoped; do not hold onto it beyond a request scope.DateTimeOffset for timestamps; store/communicate in UTC.ProblemDetails for error responses; do not leak internal exception details in production.