feat: add CQRS dispatcher example#217
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 53s ⏱️ Results for commit fdceddc. ♻️ This comment has been updated with latest results. |
🔍 PR Validation ResultsVersion: `` ✅ Validation Steps
📊 ArtifactsDry-run artifacts have been uploaded and will be available for 7 days. This comment was automatically generated by the PR validation workflow. |
There was a problem hiding this comment.
Pull request overview
Adds a new “CQRS Dispatcher” production-shaped example to PatternKit that demonstrates CQRS command/query separation via both the fluent Mediator API and a source-generated ProductionDispatcher, along with DI registration and documentation.
Changes:
- Introduces a new CQRS example (
CqrsPatternExample) with fluent and source-generated execution paths plus anIServiceCollection“bolt-on” (AddSourceGeneratedCqrsServices). - Registers the CQRS example in the example DI extension set and validates it via new TinyBDD/xUnit tests.
- Updates the example/pattern catalogs and docs TOC to include the new CQRS Dispatcher documentation page.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Examples.Tests/Messaging/CqrsPatternExampleTests.cs | Adds TinyBDD scenarios covering fluent and source-generated CQRS paths plus DI importability. |
| test/PatternKit.Examples.Tests/DependencyInjection/PatternKitExampleDependencyInjectionTests.cs | Ensures the CQRS example resolves and runs when importing all examples via DI. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Repoints CQRS pattern coverage entry to the new CQRS dispatcher example docs/source/tests. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds the “CQRS Dispatcher” entry to the example catalog for validation and docs alignment. |
| src/PatternKit.Examples/Messaging/CqrsPatternExample.cs | Implements the new CQRS example (fluent + source-generated) and DI registration helper. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Registers the CQRS example into AddPatternKitExamples() and exposes AddCqrsDispatcherExample(). |
| docs/guides/pattern-coverage.md | Updates CQRS coverage row to reflect current generator support. |
| docs/examples/toc.yml | Adds CQRS Dispatcher page to the examples TOC. |
| docs/examples/cqrs-dispatcher.md | New documentation page describing registration and both CQRS execution paths. |
Comments suppressed due to low confidence (1)
src/PatternKit.Examples/Messaging/CqrsPatternExample.cs:55
createdis nullable fromSend<CreateCqrsOrder, CqrsOrder>(), but it’s dereferenced here (created.Id) without a null check. After validatingcreatedis non-null once, use the non-null value consistently to avoid nullable warnings and potential NREs.
var readModel = await mediator.Send<GetCqrsOrder, CqrsOrder?>(new GetCqrsOrder(created.Id), cancellationToken);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| cancellationToken); | ||
|
|
||
| await mediator.Publish(new CqrsOrderCreated(created!.Id), cancellationToken); |
Code Coverage |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #217 +/- ##
==========================================
+ Coverage 91.98% 96.67% +4.69%
==========================================
Files 255 256 +1
Lines 24024 24117 +93
Branches 3270 3274 +4
==========================================
+ Hits 22099 23316 +1217
+ Misses 859 801 -58
+ Partials 1066 0 -1066
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Summary
Validation