You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[deep-review] A9: Build hygiene gaps — no analyzers on Tray/Shared, no dotnet format, no Debug.Assert, 12 ThrowIfNull sites #362
Five build-hygiene defaults that every modern .NET reference app has are missing from this repo:
EnableNETAnalyzers is set only on OpenClaw.CommandPalette (src/OpenClaw.CommandPalette/Directory.Build.props:7). Not on OpenClaw.Shared, not on OpenClaw.Tray.WinUI, not on the CLIs. This was flagged in DEVELOPMENT.md:662 as a known gap.
TreatWarningsAsErrors is set only on test projects (tests/Directory.Build.props:13). Production code can land with warnings.
No dotnet format --verify-no-changes step in CI. ci.yml has no formatter check.
Zero Debug.Assert in src/. Invariants are documented in comments instead of enforced at runtime in Debug builds.
Only 12 ArgumentNullException.ThrowIfNull sites across the entire src/ tree. Most public methods don't null-check their parameters.
Where
Analyzer config: Directory.Build.props at repo root (sets NuGetAuditMode only); add <EnableNETAnalyzers> and <AnalysisLevel>recommended</AnalysisLevel> here for repo-wide effect.
Format check: extend .github/workflows/ci.ymltest job.
Why it matters
These are the cheapest possible safety nets, and they're absent. Concrete consequences observed in this review:
App.xaml.cs grew 11% during the docs period (4148 → 4617 lines) with no warning anywhere.
The 106 empty try/catch blocks would have been flagged by CA1031 if analyzers were on.
The 527 inline TryGetProperty walks would have been flagged by a custom analyzer if anyone wrote one.
Subtle nullability bugs in JSON helpers (A5) survive because nullable annotations aren't enforced.
Proposed fix
Land in one PR (low risk):
Move EnableNETAnalyzers=true, AnalysisLevel=recommended, EnforceCodeStyleInBuild=true into the root Directory.Build.props. Expect ~50-200 warnings the first time. Convert them to errors in a follow-up PR after triaging.
Add a CI step: dotnet format --verify-no-changes --no-restore against src/. Auto-format any straggler files first.
Land an .editorconfig if one doesn't exist; pick reasonable defaults.
Add a Guard static class with Guard.NotNull(arg, nameof(arg)) etc. Migrate the most-touched public entry points first (WindowsNodeClient, OpenClawGatewayClient, capability constructors).
Sprinkle Debug.Assert on documented invariants — e.g., the single-threaded-receive-loop assertion in WebSocketClientBase.
Each step is independently shippable.
Severity
Medium — process gap; downstream cause of many other findings.
Closing during the post-refactor deep-review cleanup. Analyzer/build hygiene is consolidated into #372; the stale analyzer PR was closed rather than left to rot. This keeps the signal while reducing stale one-off issue noise.
Activity
eng: enable .NET analyzers (Recommended) for Shared, Tray, and CLIs
shanselman commentedon May 18, 2026
Closing during the post-refactor deep-review cleanup. Analyzer/build hygiene is consolidated into #372; the stale analyzer PR was closed rather than left to rot. This keeps the signal while reducing stale one-off issue noise.