- Achieve documentation and discoverability parity across Visitor variants (sync/async, result/action).
- Strengthen test coverage with concurrency and async scenarios beyond correctness.
- Provide DI/composition recipes for production usage and reuse.
- Establish baseline performance via microbenchmarks and identify optimizations.
- Explore developer ergonomics (source generators/analyzers) for large hierarchies.
- Completed
- Sync
Visitor<TBase, TResult>andActionVisitor<TBase>APIs + XML docs. - Async
AsyncVisitor<TBase, TResult>andAsyncActionVisitor<TBase>APIs + XML docs. - Core tests for sync/async visitors (dispatch, defaults, TryVisit, cancellation).
- Real‑world POS example (
VisitorDemo) and expanded docs (overview, async, guide, examples, FAQ, troubleshooting, alternatives). - TOC and index updated; Visitor listed as implemented.
- Sync
- Gaps
- No dedicated page for
AsyncActionVisitor<TBase>(referenced but not first‑class page). - No concurrency stress tests (multi‑threaded/parallel visit).
- No microbenchmarks (Visitor vs switch/pattern matching vs dictionary mapping).
- Missing DI/composition recipes in docs with
IServiceCollectionexamples. - No Visitor source generator/analyzers to optimize or lint usage patterns.
- No dedicated page for
- Documentation Parity & DI Recipes
- Add dedicated page:
docs/patterns/behavioral/visitor/asyncactionvisitor.md - Add “Composition & DI” sections to:
docs/patterns/behavioral/visitor/visitor.mddocs/patterns/behavioral/visitor/asyncvisitor.md- Show
IServiceCollectionregistration and singleton reuse patterns.
- Update TOC: add AsyncActionVisitor page under Visitor.
- DoD: Docfx builds; pages link to tests and examples; discoverable from Visitor hub.
- Concurrency Tests (Smoke + Deterministic)
- Files (proposed):
test/PatternKit.Tests/Behavioral/VisitorConcurrencyTests.cstest/PatternKit.Tests/Behavioral/AsyncVisitorConcurrencyTests.cs
- Scenarios:
- Parallel
Visit/VisitAsyncacross mixed node arrays; counters validate counts; no exceptions. - Ensure default path participates correctly under concurrency.
- Parallel
- DoD: Tests pass deterministically on all TFMs.
- Microbenchmarks (Baseline Performance)
- Project:
benchmarks/PatternKit.Benchmarks(net8.0, net9.0) - Scenarios (per N registrations; skewed/mixed/fallback hit patterns):
- Visitor vs
switch/pattern matching vsDictionary<Type, ...>mapping. - Result and action variants; sync stubs; async stubs (completed ValueTasks).
- Visitor vs
- DoD: Benchmarks run locally; readme captures summary and guidance.
- Async Example Enrichment
- Extend POS example with an async receipt enrichment (e.g., brand lookup or external call) using
AsyncVisitor<TBase, string>. - Add cancellation and timeout example; include in docs/examples.
- DoD: Example compiles, is referenced from async docs, and covered by a small test.
- Developer Ergonomics (Optional but Valuable)
- Visitor Source Generator
- New attribute:
GenerateVisitorAttribute(name, base type, result/action kind). - Emit sealed visitor with optimized type fast‑paths and builder scaffolding.
- New attribute:
- Analyzers (Roslyn)
- Warn on missing
.Default(...)when callers use.Visit(...)(risk of runtime throw). - Warn when a base type registration appears before a subtype (shadowing risk).
- Warn on missing
- DoD: Generators/analyzers ship under
PatternKit.Generators; tests cover typical cases.
- Build/Test:
dotnet build PatternKit.slnx -c Release,dotnet test PatternKit.slnx -c Release - Docs:
docfx docs/docfx.json - Style: keep “first‑match‑wins” terminology; register specific types before base types; prefer idempotent actions.
- Docs parity + DI recipes (fast win, improves onboarding)
- Concurrency tests (confidence in production usage)
- Microbenchmarks (data to guide ordering/structure guidance)
- Async example enrichment (better story for I/O‑bound real‑world cases)
- Generators/analyzers (ergonomics and safety for larger teams)