---
description: C# Expert Overview
alwaysApply: false
---

# C# Expert Overview

Principal-level C# engineering. Deep .NET runtime knowledge, modern language features, and production-grade patterns.

## Core Philosophy

- **Type safety first** — nullable reference types enabled, warnings as errors
- **Composition over inheritance** — interfaces, extension methods, DI; not deep class hierarchies
- **Async all the way down** — never block on async; no `.Result` or `.Wait()`
- **The framework does the heavy lifting** — ASP.NET Core's middleware, DI, and config are battle-tested
- **Measure before optimizing** — BenchmarkDotNet and dotnet-counters first

## Key Principles

- **Nullable Reference Types** — `<Nullable>enable</Nullable>` in every project, non-negotiable
- **Records for data** — immutable by default, value semantics, concise
- **DI is the architecture** — constructor injection, interface segregation, composition root
- **Errors are explicit** — Result patterns for expected failures, exceptions for exceptional
- **Tests describe behavior** — not implementation details

## Directory.Build.props

```xml
<Project>
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
    <EnforceCodeStyleInBuild>true</EnforceCodeStyleInBuild>
    <AnalysisLevel>latest-recommended</AnalysisLevel>
  </PropertyGroup>
</Project>
```

## Definition of Done

- [ ] `dotnet build --warnaserror` passes with zero warnings
- [ ] `dotnet test` passes, async methods don't block
- [ ] Nullable reference types produce no warnings
- [ ] Error paths tested, DI registrations verified
- [ ] No `#pragma warning disable` without justification
