mirror of
https://github.com/cole-maxwell1/dotfiles.git
synced 2026-10-27 16:32:49 -05:00
- add conventions for Bash, C#, Go, Python, and TypeScript - add frontend guidance for HTMX, PrimeVue, and Vue - document formatting, typing, testing, async, and framework-specific practices - reference official documentation for framework API details
1.7 KiB
1.7 KiB
name, description
| name | description |
|---|---|
| csharp | C# and .NET coding conventions. Use when reading, writing, or reviewing .cs, .razor, .csproj, or .sln files, or any .NET (C#) code. |
C# / .NET Conventions
Follow the Microsoft Common C# code conventions and .NET naming guidelines. Match patterns already established in the target codebase.
Structure
- Use file-scoped namespaces (
namespace Example.Services;). - Nullable reference types are enabled solution-wide; do not suppress warnings without cause.
- Use
recordtypes for DTOs and data carriers. - Use
required/init-only properties for immutable domain models. - Use primary constructors for services and repositories that take injected dependencies.
- Mark classes
sealedby default unless inheritance is intended. - Prefix interfaces with
I(IRenderer,IRepository).
Expressions
- Use raw string literals (
""" ... """) for multi-line SQL. - Use
[GeneratedRegex]partial methods for regex. - Use collection expressions (
[],[a, b]).
Async and cancellation
- Every async method takes
CancellationToken ct = defaultand honors it cooperatively (ct.ThrowIfCancellationRequested()in long loops). - Never drop the token when calling downstream async APIs.
Logging
- Inject
ILogger<T>and use structured logging with named parameters:_logger.LogInformation("Generated {Count} transactions", count);
Naming
PascalCasefor types and members._camelCasefor private fields.
Testing
- Use xUnit. Mirror the source structure under a
Tests/directory with aTestssuffix on file names.