From a4f37db594c6446498d657b5227b4a53a33182b5 Mon Sep 17 00:00:00 2001 From: VinPropane Date: Wed, 24 Jun 2026 20:46:27 -0400 Subject: [PATCH] NEO-146: restore test layout section in csharp-style guide Fix IDE0270 section that accidentally overwrote the test project layout heading. --- .cursor/rules/csharp-style.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.cursor/rules/csharp-style.md b/.cursor/rules/csharp-style.md index 9a9c298..641404f 100644 --- a/.cursor/rules/csharp-style.md +++ b/.cursor/rules/csharp-style.md @@ -135,7 +135,16 @@ var store = secondScope.ServiceProvider.GetRequiredService(); // - Use **`///` XML doc comments** on public APIs (types and members) when behavior or contracts are not obvious. - **Primary-constructor records:** include a **``** plus **``** for every constructor parameter (Roslynator RCS1139 / RCS1263). Do not leave orphaned `` lines without a summary on the type. -## Null checks (IDE0270) (`*.Tests`) +## Null checks (IDE0270) + +- Prefer **`?? throw`** over `if (x is null) { throw … }` when assigning a non-null local from a nullable expression. + +```csharp +var root = FindDockerComposeRoot() + ?? throw new InvalidOperationException("…"); +``` + +## Test project layout (`*.Tests`) - **Mirror the server project:** place test types under the same relative path as the production code they exercise (e.g. `NeonSprawl.Server/Game/PositionState/PositionStateApi.cs` → `NeonSprawl.Server.Tests/Game/PositionState/PositionStateApiTests.cs`). - Use a namespace that matches the folder tree under the test assembly root, e.g. `NeonSprawl.Server.Tests.Game.PositionState` for files in `Game/PositionState/`.