Skip to content

#602 Zero build warnings across the engine, profiler and test projects + TreatWarningsAsErrors - #603

Merged
nockawa merged 2 commits into
mainfrom
fix/no-more-warnings
Jul 30, 2026
Merged

nockawa merged 2 commits into
mainfrom
fix/no-more-warnings

Conversation

@nockawa

@nockawa nockawa commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Closes #602.

The Typhon.Engine.Tests build closure carried 86 warnings with nothing gating them. The only guard was a hand-maintained WarningsAsErrors list of doc-comment codes (CS1570–CS1735) on two csprojs — which by construction could not catch anything outside that list. CS0419 lives in CS04xx, so 47 instances accumulated unnoticed.

Project Before After Gated
Typhon.Engine 47 0 ✅
Typhon.Engine.Tests 35 0 ✅
Typhon.Profiler 3 0 ✅
Typhon.Workbench.Fixtures 1 0 ✅
Total 86 0

Each of the four now carries <TreatWarningsAsErrors>true</TreatWarningsAsErrors>, replacing the doc-comment-only allow-list.

Three findings that were not just noise

CS0436 was an architectural leak. TraceEventGenerator synthesized its attribute surface via RegisterPostInitializationOutput, which injects into every project referencing the generator as an analyzer — all of which also reference Typhon.Engine, which exports the same types. Six projects were compiling ~130 lines of injected attribute source they had no use for, on every build. Declared once as real source in Profiler/public/TraceEventAttributes.cs and dropped the post-init block; the generator resolves [TraceEvent] against it directly, since real source is always visible to generators. Verified with EmitCompilerGeneratedFiles that it still emits all 410 producer files and no longer emits TraceEventAttributes.g.cs.

CA2014 ×11 was a real latent stack risk. stackalloc inside loops of 200–10 000 iterations. localloc is not released until the method returns, so SpatialPerfTests grew the stack by ~480 KB per run against a 1 MB default. Every size was loop-invariant and every element rewritten per iteration, so the buffers hoist without behaviour change. Two of them also sat inside the Stopwatch region — those benchmarks were timing a per-iteration stack bump.

CS0279 ×2 hid a boxed enumerator. ViewBase.GetEnumerator() is internal (it returns the internal HashMap<long>.Enumerator) and the foreach collection pattern requires public, so a bare foreach over an EcsView<T> silently fell back to IEnumerable<long> — boxed enumerator, interface dispatch per element. Switched to the public allocation-free GetEntityEnumerator(). This trap is still live in Typhon.Benchmark (ParallelDispatchBenchmark.cs:200) and is open to any consumer.

The rest

  • CS0419 ×50 — ambiguous cref, fixed by naming the overload the prose actually means, chosen by reading the call site. Four sites needed ref readonly in the cref (.NET 9 changed Interlocked.Read / Volatile.Read to take ref readonly; plain ref fails to resolve). Four references are to an overload set, which C# cannot cref — those use <c> rather than pointing at an arbitrary member.
  • One real doc bug — ArchetypeClusterState.cs:600 claimed SetDirty tags wake requests via DormancyReporter. Neither overload does; the shared MarkEntityDirty helper does. Retargeted.
  • CS0114 — DormancyTests.TearDown hid TestBase.TearDown. I suspected the base cleanup was being skipped (leaked engines, undeleted database bundles), checked empirically by running the fixture and inspecting %TEMP%\Typhon.Tests\DormancyTests — it was not skipped, NUnit invokes both. Converted to the suite's override + base.TearDown() convention anyway; ordering unchanged.
  • CS0108 — TraceRingObserver.Name re-declared what ResourceNode.Name already returns (the base ctor is passed the identical string). Deleted.
  • CS0219 — vestigial ticksToRun const; that loop is bounded by attempt count.
  • TYPHON009 — narrow pragma at the one line whose own comment reads "Deliberately NO MarkSlotDirty — that's the bug pattern under test".
  • CS0649 ×17 — file-scoped pragma in five fixtures whose component payload fields are written through spans, never by C# assignment. Same rationale and pragma as the engine's own InstantEvents.cs.

Second commit — Dependabot alerts 23 / 24 / 25

All three were transitive dev-dependencies of the Workbench SPA, so nothing reached a Typhon user.

Alert Package Was Now
#23 js-yaml 4.2.0 4.3.0
#24 fast-uri 3.1.3 3.1.4
#25 postcss 8.5.16 8.5.25

js-yaml was the awkward one: the top-level copy was already 4.3.0, and the vulnerable copy was a second one nested at node_modules/orval/node_modules/js-yaml, because orval 8.20.0 pins js-yaml to exactly 4.2.0 — no npm update could move it. orval 8.23.0 has moved its pin to 4.3.0 and our range is ^8.7.0, so bumping orval collapsed the nested copy entirely. No overrides entry needed. package.json untouched; the lockfile is net smaller.

Verification

  • Debug and Release: 0 Warning(s) 0 Error(s) for all four gated projects
  • Full engine suite: 4076 passed / 0 failed / 51 skipped — unchanged from baseline
  • dotnet pack clean
  • SPA: typecheck, lint, vite build, and 1584 vitest tests / 176 files all pass
  • Zero vulnerable copies of the three npm packages remain in the lockfile

Follow-ups (deliberately out of scope)

  • Typhon.Benchmark — 30 warnings (28 CA2014 same pattern, 1 CS0279 same view trap, 1 SYSLIB0054)
  • Typhon.CompetitiveBenchmark — NU1903, SQLitePCLRaw.lib.e_sqlite3 2.1.11 has a known high-severity advisory. Must be bumped before that project can be gated, because TreatWarningsAsErrors also promotes NuGet advisory warnings.
  • npm audit still reports 11 high, unchanged here — largely one advisory (brace-expansion DoS) surfacing through the eslint 8.x chain plus vite-plugin-checker → vscode-languageclient. Every fix is semver-major (eslint 10, vite-plugin-checker 0.14). GitHub has auto-dismissed the brace-expansion alert.
  • Six dependency projects are already at zero but not gated. Worth a Directory.Build.props default rather than per-csproj repetition.
  • Unrelated and pre-existing: dotnet build Typhon.slnx --no-incremental fails on Typhon.Workbench over a missing SPA bundle in wwwroot (the "bundles only via dotnet publish" quirk). Untouched by this PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs

nockawa and others added 2 commits July 30, 2026 16:41
…s, gated with TreatWarningsAsErrors

The Typhon.Engine.Tests build closure carried 86 warnings with nothing gating them. The only guard was a hand-maintained WarningsAsErrors list of doc-comment codes (CS1570-CS1735) on two csprojs, which by construction could not catch anything outside that list — CS0419 sits in CS04xx and 47 instances accumulated unnoticed.

Engine.Tests closure: 86 -> 0. Typhon.Engine (47), Typhon.Engine.Tests (35), Typhon.Profiler (3) and Typhon.Workbench.Fixtures (1) now build clean in Debug and Release and each carries TreatWarningsAsErrors, replacing the doc-comment-only allow-list.

CS0419 x50 (engine + profiler): ambiguous cref, fixed by naming the overload the prose actually means, picked by reading the call site rather than guessing. Four sites needed `ref readonly` in the cref — .NET 9 changed Interlocked.Read and Volatile.Read to take ref readonly, and plain `ref` fails to resolve. Four references are to an overload *set* (ClaimSlotInCell "both overloads", CompoundSystem.Add with three overloads); C# cannot cref an overload group, so those use <c> rather than pointing at an arbitrary member. ArchetypeClusterState.cs:600 claimed SetDirty tags wake requests via DormancyReporter — neither overload does, the shared MarkEntityDirty helper does; retargeted.

CS0436 x2: TraceEventGenerator synthesized its attribute surface via RegisterPostInitializationOutput, which injects into every project referencing the generator as an analyzer — all of which also reference Typhon.Engine, which exports the same types. Declared once as real source in Profiler/public/TraceEventAttributes.cs and dropped the post-init block; the generator resolves [TraceEvent] against it directly, since real source is always visible to generators. Verified it still emits all 410 producer files. Also updated the stale rationale comments in Typhon.Engine.csproj and GlobalUsings.cs that cited CS0436 as unavoidable.

CA2014 x11: stackalloc inside loops of 200-10000 iterations. localloc is not released until the method returns, so SpatialPerfTests grew the stack by ~480 KB per run. Every size was loop-invariant and every element rewritten per iteration, so the buffers hoist without behaviour change; two of them also sat inside the timed region of a benchmark.

CS0279 x2: ViewBase.GetEnumerator() is internal and the foreach collection pattern requires public, so a bare foreach over an EcsView<T> silently fell back to IEnumerable<long> — a boxed enumerator with interface dispatch per element. Switched to the public allocation-free GetEntityEnumerator().

CS0114: DormancyTests.TearDown hid TestBase.TearDown instead of overriding it. Checked empirically whether the base cleanup was being skipped (it was not — NUnit invokes both), then converted to the suite's override + base.TearDown() convention. CS0108: TraceRingObserver.Name re-declared what ResourceNode.Name already returns, the base ctor being passed the identical string; deleted. CS0219: vestigial ticksToRun const, that loop is bounded by attempt count. TYPHON009: narrow pragma at the one line whose own comment reads "Deliberately NO MarkSlotDirty — that's the bug pattern under test". CS0649 x17: file-scoped pragma in five fixtures whose component payload fields are written through spans, never by C# assignment, matching the engine's own precedent in InstantEvents.cs.

Full suite 4076 passed / 0 failed / 51 skipped, unchanged from baseline. dotnet pack clean.

Note for whoever gates more projects: TreatWarningsAsErrors also promotes NuGet advisory warnings. Typhon.CompetitiveBenchmark currently reports NU1903 for SQLitePCLRaw.lib.e_sqlite3 2.1.11 and must be bumped before it can be gated.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs
…2cp-r559-cp3m, GHSA-v2hh-gcrm-f6hx, GHSA-r28c-9q8g-f849)

All three were transitive dev-dependencies, so nothing reached a Typhon user — they run at build time in the toolchain. Alerts 23/24/25.

fast-uri 3.1.3 -> 3.1.4 (host confusion via literal backslash authority delimiter) and postcss 8.5.16 -> 8.5.25 (path traversal in sourceMappingURL auto-loading) were both in-range patch bumps.

js-yaml was the awkward one: the top-level copy was already 4.3.0, and the vulnerable copy was a second one nested at node_modules/orval/node_modules/js-yaml, because orval 8.20.0 pins js-yaml to exactly 4.2.0 — no npm update could move it. orval 8.23.0 has moved its pin to 4.3.0 and our range is ^8.7.0, so bumping orval collapsed the nested copy entirely. No overrides entry needed.

package.json untouched, every bump was already inside an existing range. Lockfile is net smaller since the duplicate js-yaml tree is gone. Verified: typecheck, lint, vite build, and 1584 vitest tests across 176 files all pass; zero vulnerable copies of the three packages remain in the lock.

npm audit still reports 11 high, unchanged by this commit. They are largely one advisory (brace-expansion DoS) surfacing through the eslint 8.x chain plus vite-plugin-checker -> vscode-languageclient, and every fix is semver-major (eslint 10, vite-plugin-checker 0.14). GitHub has auto-dismissed the brace-expansion alert. That upgrade is a separate piece of work.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs
@nockawa
nockawa merged commit 1f9ee65 into main Jul 30, 2026
15 checks passed
@nockawa
nockawa deleted the fix/no-more-warnings branch July 30, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zero build warnings + TreatWarningsAsErrors for the engine, profiler and test projects

1 participant