Files
dotfiles/.config/opencode/skills/csharp/SKILL.md
T
colem a4fc747df2 feat(opencode): add language-specific coding skills
- 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
2026-08-11 15:28:09 -05:00

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 record types 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 sealed by 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 = default and 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

  • PascalCase for types and members.
  • _camelCase for private fields.

Testing

  • Use xUnit. Mirror the source structure under a Tests/ directory with a Tests suffix on file names.