feat: add event-carried state transfer pattern#312
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 11s ⏱️ Results for commit 76edb19. |
🔍 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. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #312 +/- ##
==========================================
+ Coverage 90.24% 95.98% +5.74%
==========================================
Files 436 440 +4
Lines 36446 36677 +231
Branches 5167 5201 +34
==========================================
+ Hits 32889 35204 +2315
+ Misses 1573 1473 -100
+ Partials 1984 0 -1984
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:
|
There was a problem hiding this comment.
Pull request overview
Adds the Event-Carried State Transfer (ECST) pattern as a first-class PatternKit feature, including a fluent runtime API, a Roslyn incremental source generator, an inventory projection example with IServiceCollection integration, and accompanying test/docs/catalog coverage.
Changes:
- Introduces
EventCarriedStateTransfer<TEvent,TKey,TState>runtime API andEventCarriedStateTransferGeneratorwith diagnosticsPKECST001-003. - Adds runtime/generator/unit tests plus an inventory projection demo and DI registration hooks.
- Updates pattern/example catalogs and docs (TOCs, guides, generator docs, pattern docs, example docs) to include ECST.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/EnterpriseIntegration/EventCarriedStateTransfer/EventCarriedStateTransferTests.cs | Runtime API tests for success/failure/config validation. |
| test/PatternKit.Generators.Tests/EventCarriedStateTransferGeneratorTests.cs | Generator golden/diagnostics coverage via Roslyn test harness. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Validates new generator attributes defaults/null-guarding. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Ensures catalogs include ECST and updates family counts. |
| test/PatternKit.Examples.Tests/EventCarriedStateTransferDemo/InventoryEventCarriedStateTransferDemoTests.cs | Validates fluent vs generated demo behavior + DI importability. |
| src/PatternKit.Generators/EventCarriedStateTransfer/EventCarriedStateTransferGenerator.cs | New incremental generator implementation and diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new analyzer IDs for release tracking. |
| src/PatternKit.Generators.Abstractions/EnterpriseIntegration/EventCarriedStateTransferAttributes.cs | Adds [GenerateEventCarriedStateTransfer] + selector/mapper marker attributes. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds ECST to the pattern catalog with doc/source/test pointers. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds inventory ECST demo to the example catalog. |
| src/PatternKit.Examples/EventCarriedStateTransferDemo/InventoryEventCarriedStateTransferDemo.cs | New inventory projection example (fluent + generated + DI extension). |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires ECST demo into aggregate AddPatternKitExamples() registration. |
| src/PatternKit.Core/EnterpriseIntegration/EventCarriedStateTransfer/EventCarriedStateTransfer.cs | New ECST runtime API and result type. |
| docs/patterns/toc.yml | Adds ECST to patterns TOC. |
| docs/patterns/messaging/README.md | Adds ECST pattern landing entry. |
| docs/patterns/messaging/event-carried-state-transfer.md | New ECST pattern doc page. |
| docs/guides/pattern-coverage.md | Adds ECST row to coverage table. |
| docs/generators/toc.yml | Adds ECST generator doc to TOC. |
| docs/generators/index.md | Adds ECST to generator overview table and quick examples. |
| docs/generators/event-carried-state-transfer.md | New ECST generator doc page + diagnostics list. |
| docs/examples/toc.yml | Adds inventory ECST example to examples TOC. |
| docs/examples/inventory-event-carried-state-transfer.md | New inventory ECST example doc page. |
| docs/examples/index.md | Adds inventory ECST entry to examples index. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sb.Append(GetAccessibility(type.DeclaredAccessibility)).Append(' '); | ||
| if (type.IsStatic) | ||
| sb.Append("static "); | ||
| else if (type.IsAbstract && type.TypeKind == TypeKind.Class) | ||
| sb.Append("abstract "); | ||
| else if (type.IsSealed && type.TypeKind == TypeKind.Class) | ||
| sb.Append("sealed "); | ||
| sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine(); | ||
| sb.AppendLine("{"); |
| => Given("an inventory event", () => new InventoryAdjustedEvent("SKU-100", 12, "CHI-01", 4)) | ||
| .When("fluent and generated transfers project the event", evt => new | ||
| { | ||
| Fluent = InventoryEventCarriedStateTransferDemoRunner.RunFluent(), | ||
| Generated = BuildServiceProvider().GetRequiredService<InventoryEventCarriedStateTransferDemoRunner>().RunGenerated(evt) |
| public static InventoryProjectionSummary RunFluent() | ||
| { | ||
| var store = new InMemoryInventoryReadModelStore(); | ||
| var service = new InventoryProjectionService(InventoryStateTransfers.CreateFluent(), store); | ||
| return service.Project(new InventoryAdjustedEvent("SKU-100", 12, "CHI-01", 4)); |
| public void Upsert(string sku, long version, InventoryReadModel state) | ||
| => _summaries[sku] = new("inventory-state", sku, version, state.QuantityOnHand, state.Warehouse); | ||
|
|
Code Coverage |
Closes #308
Summary
Local validation
EventCarriedStateTransferGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTestsNote: local full examples build still hits the existing CS9057 compiler/analyzer mismatch; hosted CI validates examples/docs.