.NET / C# solution. Replace the bracketed bits with your project's details.
- .NET 8.0 (LTS) SDK, C# 12, nullable reference types enabled.
- Build/test:
dotnetCLI 8.0.x. Tests: xUnit. Format:dotnet format.
dotnet restore # restore NuGet packages
cp .env.example .env # local config; never commit .envdotnet run --project src/Api # run the API project
dotnet build -c Release # build
dotnet test # run all tests
dotnet test --filter FullyQualifiedName~OrderServiceTests # one test class
dotnet format # apply formatting + analyzers
dotnet format --verify-no-changes # format check (used in CI)src/Api/— entry-point web/API project (Program.cs, controllers).src/<Domain>/— domain & application class libraries.tests/<Project>.Tests/— xUnit test projects, one persrcproject.*.sln,Directory.Build.props— solution and shared MSBuild settings.appsettings.json,.env.example— config templates (no secrets).
- Nullable is on: treat warnings as errors; do not sprinkle
!null-forgiving. - Use
async/awaitend-to-end; suffix async methods withAsync. - Prefer records for DTOs; keep services injected via the DI container.
Example — an async service method:
public sealed class OrderService(IOrderRepository repo)
{
public async Task<Order> GetAsync(long id, CancellationToken ct)
{
return await repo.FindAsync(id, ct)
?? throw new OrderNotFoundException(id);
}
}- Test projects named
*.Tests; mirror the namespace under test. - A change is done when
dotnet format --verify-no-changesanddotnet testpass. - Add a failing test first, then make it pass (TDD).
- Branch from
main:git switch -c feat/<short-name>. - Conventional Commits (
feat:,fix:,chore:). - Before pushing:
dotnet format --verify-no-changes && dotnet build -c Release && dotnet test. - PR description: one-line summary + the test command you ran.
- Always: read
.env.example/appsettings.jsonfor config keys. - Always: edit project source under
src/and add tests undertests/. - Always: add a new EF Core migration (
dotnet ef migrations add) for schema changes. - Always: fix the root cause when an analyzer flags code.
- Ask first: before adding NuGet packages or changing
.csprojTargetFramework. - Ask first: before editing an already-applied migration's
Up/Down. - Never commit secrets,
.env, orappsettings.*.jsonwith real values. - Never suppress analyzer warnings with
#pragma warning disableto pass CI.
- Project/layer layout:
docs/architecture.md.