feat: add event notification pattern#313
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 17s ⏱️ Results for commit f2d6221. |
🔍 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 #313 +/- ##
==========================================
+ Coverage 90.20% 95.95% +5.74%
==========================================
Files 440 444 +4
Lines 36677 36964 +287
Branches 5201 5248 +47
==========================================
+ Hits 33086 35470 +2384
+ Misses 1586 1494 -92
+ Partials 2005 0 -2005
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:
|
Code Coverage |
There was a problem hiding this comment.
Pull request overview
Adds a new Event Notification pattern to PatternKit, including a fluent runtime API, a Roslyn incremental generator for factory creation, an importable DI example, and documentation/catalog coverage. The PR description also states it closes #309, but the linked issue is for Gateway Aggregation, so the closure/issue reference appears inconsistent with the delivered feature set.
Changes:
- Introduces
EventNotification<TEvent, TKey>runtime API with publish/skip/failure results and fluent builder configuration. - Adds
[GenerateEventNotification]generator + supporting attributes, diagnostics, and generator tests. - Adds “Order Event Notification” example (DI registration + tests) and updates docs/tocs/catalogs to include the new pattern.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/EnterpriseIntegration/EventNotification/EventNotificationTests.cs | Runtime API tests for metadata, skipping, and validation behavior |
| test/PatternKit.Generators.Tests/EventNotificationGeneratorTests.cs | Verifies generator output and generator diagnostics |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Adds coverage for new generator abstraction attributes |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog expectations for new pattern entry |
| test/PatternKit.Examples.Tests/EventNotificationDemo/OrderEventNotificationDemoTests.cs | Validates fluent vs generated example paths and DI import |
| src/PatternKit.Generators/EventNotification/EventNotificationGenerator.cs | New incremental generator that produces event notification factories |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new generator diagnostic IDs (PKEN00x) |
| src/PatternKit.Generators.Abstractions/EnterpriseIntegration/EventNotificationAttributes.cs | Adds [GenerateEventNotification] and selector/metadata attributes |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Registers the new pattern in the production readiness catalog |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Registers the new “Order Event Notification” example descriptor |
| src/PatternKit.Examples/EventNotificationDemo/OrderEventNotificationDemo.cs | Adds the example implementation and IServiceCollection integration |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the new example into AddPatternKitExamples() |
| src/PatternKit.Core/EnterpriseIntegration/EventNotification/EventNotification.cs | Adds the runtime EventNotification API and result types |
| docs/patterns/toc.yml | Adds Event Notification to patterns TOC |
| docs/patterns/messaging/README.md | Adds Event Notification section entry |
| docs/patterns/messaging/event-notification.md | New pattern documentation page |
| docs/guides/pattern-coverage.md | Adds pattern coverage row for Event Notification |
| docs/generators/toc.yml | Adds generator doc TOC entry |
| docs/generators/index.md | Adds Event Notification generator to index and examples list |
| docs/generators/event-notification.md | New generator documentation page |
| docs/examples/toc.yml | Adds example TOC entry |
| docs/examples/order-event-notification.md | New example documentation page |
| docs/examples/index.md | Adds example summary entry |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private static MetadataMember[] MetadataMembers(INamedTypeSymbol type) | ||
| => type.GetMembers().OfType<IMethodSymbol>() | ||
| .Select(method => new | ||
| { | ||
| Method = method, | ||
| Attribute = method.GetAttributes().FirstOrDefault(attr => attr.AttributeClass?.ToDisplayString() == MetadataAttributeName) | ||
| }) | ||
| .Where(static item => item.Attribute is not null) | ||
| .Select(static item => new MetadataMember((string)item.Attribute!.ConstructorArguments[0].Value!, item.Method)) | ||
| .ToArray(); |
| var correlations = MembersWith(type, CorrelationAttributeName); | ||
| var rules = MembersWith(type, RuleAttributeName); | ||
| var metadata = MetadataMembers(type); | ||
| var duplicate = metadata.GroupBy(static item => item.Name, StringComparer.OrdinalIgnoreCase).FirstOrDefault(static group => group.Count() > 1); | ||
| if (duplicate is not null) | ||
| { | ||
| context.ReportDiagnostic(Diagnostic.Create(DuplicateMetadata, node.Identifier.GetLocation(), duplicate.Key)); | ||
| return; | ||
| } |
| public static class NotificationHost; | ||
| """), | ||
| Compile(""" | ||
| using PatternKit.Generators.EventNotification; | ||
| [GenerateEventNotification(typeof(string), typeof(string))] | ||
| public static partial class NotificationHost; |
| Pattern("Event Notification", PatternFamily.EnterpriseIntegration, | ||
| "docs/patterns/messaging/event-notification.md", | ||
| "src/PatternKit.Core/EnterpriseIntegration/EventNotification/EventNotification.cs", | ||
| "test/PatternKit.Tests/EnterpriseIntegration/EventNotification/EventNotificationTests.cs", | ||
| "docs/generators/event-notification.md", | ||
| "src/PatternKit.Generators/EventNotification/EventNotificationGenerator.cs", | ||
| "test/PatternKit.Generators.Tests/EventNotificationGeneratorTests.cs", | ||
| null, | ||
| "docs/examples/order-event-notification.md", | ||
| "src/PatternKit.Examples/EventNotificationDemo/OrderEventNotificationDemo.cs", | ||
| "test/PatternKit.Examples.Tests/EventNotificationDemo/OrderEventNotificationDemoTests.cs", | ||
| ["fluent compact notification", "generated notification factory", "DI-importable order notification example"]), |
| if (result.Failed) | ||
| throw new InvalidOperationException("Order notification could not be created.", result.Exception); | ||
|
|
||
| var summary = new OrderNotificationSummary(result.NotificationName, result.Key!, result.CorrelationId, result.Metadata["source"]); |
Closes #309
Summary
Local validation
EventNotificationGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTestsNote: local full examples build still hits the existing CS9057 compiler/analyzer mismatch; hosted CI validates examples/docs.