| name | csharp |
| description | Use when: write or review modern, idiomatic C# with async, nullable reference types, and clean structure. |
Goal: modern C# that is null-safe, async-correct, and testable.
Use for:
- new classes, services, or APIs in C#/.NET
- reviewing async usage, nullability, and structure
- modernizing legacy patterns to current language features
Workflow:
- Enable nullable reference types and honor the warnings.
- Use async/await end to end; never block on async code.
- Model data with records and pattern matching.
- Prefer immutable types and expression-bodied members.
- Inject dependencies; program to interfaces, not concretions.
- Verify with the test runner, analyzers, and dotnet format.
Idioms:
- records for value-like data
- LINQ for transformations over manual loops
- pattern matching and switch expressions
- using declarations for IDisposable
- CancellationToken threaded through async APIs
Rules:
- never call .Result/.Wait() on a Task; await it
- treat nullable warnings as errors to fix
- pass CancellationToken to cancellable operations
- keep methods small; depend on abstractions for testability