Skip to content

[deep-review] A9: Build hygiene gaps — no analyzers on Tray/Shared, no dotnet format, no Debug.Assert, 12 ThrowIfNull sites #362

Closed

Description

@codemonkeychris

Summary

Five build-hygiene defaults that every modern .NET reference app has are missing from this repo:

  1. 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.

  2. TreatWarningsAsErrors is set only on test projects (tests/Directory.Build.props:13). Production code can land with warnings.

  3. No dotnet format --verify-no-changes step in CI. ci.yml has no formatter check.

  4. Zero Debug.Assert in src/. Invariants are documented in comments instead of enforced at runtime in Debug builds.

  5. 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.yml test 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):

  1. 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.
  2. Add a CI step: dotnet format --verify-no-changes --no-restore against src/. Auto-format any straggler files first.
  3. Land an .editorconfig if one doesn't exist; pick reasonable defaults.
  4. Add a Guard static class with Guard.NotNull(arg, nameof(arg)) etc. Migrate the most-touched public entry points first (WindowsNodeClient, OpenClawGatewayClient, capability constructors).
  5. 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.

Activity

  1. added
    enhancement
    on May 14, 2026
  2. shanselman commented on May 18, 2026

    @shanselman
    Collaborator

    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.

  3. locked as resolved and limited conversation to collaborators on May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions