csharp-rules

Solid

C#/.NET coding rules: style, patterns, security, testing. Triggers: .cs, .csproj, .sln, ASP.NET, ASP.NET Core, EF Core, LINQ, NUnit, xUnit, dotnet.

AI & Automation 155 stars 19 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 93/100

Stars 20%
73
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# C#/.NET Rules These rules come from `app/rules/csharp/` in ai-toolkit. They cover the project's standards for coding style, frameworks, patterns, security, and testing in C#/.NET. Apply them when writing or reviewing C#/.NET code. # C# Coding Style ## Naming - PascalCase: classes, structs, enums, interfaces, methods, properties, events. - camelCase: local variables, parameters, private fields. - Prefix interfaces with `I`: `IUserRepository`, `IDisposable`. - Prefix private fields with `_`: `private readonly ILogger _logger;`. - UPPER_SNAKE: not conventional in C#. Use PascalCase for constants. ## Nullable Reference Types - Enable `<Nullable>enable</Nullable>` in all projects. - Use `string?` only when null is semantically meaningful. - Use `!` (null-forgiving) operator sparingly -- only when compiler cannot infer. - Use `??` (null-coalescing) and `?.` (null-conditional) for safe navigation. - Use `required` modifier (C# 11) on properties that must be set at initialization. ## Records and Types - Use `record` for immutable value objects and DTOs. - Use `record struct` for small, stack-allocated value types. - Use `init` properties for immutable-after-construction objects. - Use `with` expressions for non-destructive mutation of records. - Use primary constructors (C# 12) for concise class definitions. ## Pattern Matching - Use `is` pattern for type checks: `if (obj is string s)`. - Use `switch` expressions for exhaustive matching over enums/types. - Use property patter...

Details

Author
softspark
Repository
softspark/ai-toolkit
Created
2 months ago
Last Updated
2 days ago
Language
Python
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category