-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Goal
Raise code quality bar and improve runtime diagnosability by enabling nullable reference types, adding analyzers, enforcing warnings-as-errors, and instrumenting structured logging + tracing for critical game flows.
Motivation
- Earlier detection of null bugs & API misuse
- Consistent style / code hygiene reduces PR review friction
- Observability (logs + traces) accelerates debugging of gameplay issues, latency, hot paths
Quality Gate Enhancements
- Enable
<Nullable>enable</Nullable>in every csproj - Add
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>(optionally configurable via Directory.Build.props) - Add Microsoft.CodeAnalysis.NetAnalyzers (latest stable) with rule level medium severity; include editorconfig baseline if noise high
- Add StyleCop.Analyzers (optional) or rely on .editorconfig for minimal style safety
- Configure CI (GitHub Actions future) to run
dotnet build+ filtered tests
Observability Additions
- Structured logging (Microsoft.Extensions.Logging) in GameService: events for GameStarted, GuessSubmitted, GameCompleted with contextual properties (GameId, AttemptIndex, WordLength, Result)
- Exception logging with reduced noise (log domain validation at Information or Debug, unexpected at Error)
- OpenTelemetry instrumentation (if Aspire not already auto-wiring):
- Add ActivitySource
Codele.Gameplay - Span per guess evaluation with attributes:
codele.game.id,codele.guess.length,codele.guess.result(win/continue)
- Add ActivitySource
- Optional metrics (if instrumentation libs added later): counter
codele.guesses.total, histogramcodele.game.duration.seconds
Implementation Plan
- Create/modify
Directory.Build.propsto centrally enable Nullable + WarningsAsErrors; reference analyzers package - Add
.editorconfigwith key rules (nullable, IDE, formatting) - Update each project csproj to remove redundant settings; add analyzers package if not global
- Introduce
Instrumentationstatic class exposing ActivitySource - Inject ActivitySource into services (or use static) & wrap guess evaluation in activity
- Add structured logging statements (Ensure no PII / target word withheld until game completes; only log masked hash before completion)
- Add unit test asserting logger called for GameCompleted (can use a fake logger) – lightweight
- Update README with new quality gates + how to suppress intentionally (pragma + justification)
Acceptance Criteria
- Build fails on new nullable warnings introduced intentionally
- Activity exported (can be verified via debug logging or future OTLP exporter)
- Logging shows contextual properties per guess in local run
- README documents process
Out of Scope
- Full metrics pipeline export
- External log shipping config
Risk & Mitigation
- Analyzer noise -> Keep initial rules moderate; create baseline suppression file if needed
Definition of Done
Merged PR with green tests, updated docs, analyzers active (visible in IDE), and logged gameplay events.
Estimated Effort
Small-Medium (3-4h depending on analyzer tuning).
Depends on: Issue #8 (for domain service centralization makes instrumentation cleaner).
Metadata
Metadata
Assignees
Labels
No labels