Skip to content

feat: add event notification pattern#313

Merged
JerrettDavis merged 1 commit into
mainfrom
feature/event-notification-309
May 22, 2026
Merged

feat: add event notification pattern#313
JerrettDavis merged 1 commit into
mainfrom
feature/event-notification-309

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #309

Summary

  • adds Event Notification runtime API and source generator
  • adds order notification demo with IServiceCollection integration
  • adds TinyBDD runtime, generator, example, catalog, and docs coverage

Local validation

  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f netstandard2.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net8.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net9.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net10.0 /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Generators.Abstractions\PatternKit.Generators.Abstractions.csproj /p:UseSharedCompilation=false
  • dotnet build src\PatternKit.Generators\PatternKit.Generators.csproj /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net8.0/net9.0/net10.0 --filter FullyQualifiedName~EventNotificationTests
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0/net9.0/net10.0 --filter FullyQualifiedNameEventNotificationGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests
  • git diff --check

Note: local full examples build still hits the existing CS9057 compiler/analyzer mismatch; hosted CI validates examples/docs.

Copilot AI review requested due to automatic review settings May 22, 2026 06:37
@github-actions
Copy link
Copy Markdown
Contributor

⚠️ Deprecation Warning: The deny-licenses option is deprecated for possible removal in the next major release. For more information, see issue 997.

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@github-actions
Copy link
Copy Markdown
Contributor

Test Results

  1 files    1 suites   1m 17s ⏱️
946 tests 946 ✅ 0 💤 0 ❌
951 runs  951 ✅ 0 💤 0 ❌

Results for commit f2d6221.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 PR Validation Results

Version: ``

✅ Validation Steps

  • Build solution
  • Run tests
  • Build documentation
  • Dry-run NuGet packaging

📊 Artifacts

Dry-run artifacts have been uploaded and will be available for 7 days.


This comment was automatically generated by the PR validation workflow.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 93.03136% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.95%. Comparing base (2845459) to head (f2d6221).

Files with missing lines Patch % Lines
...rs/EventNotification/EventNotificationGenerator.cs 92.30% 11 Missing ⚠️
...Integration/EventNotification/EventNotification.cs 91.89% 6 Missing ⚠️
...ventNotificationDemo/OrderEventNotificationDemo.cs 91.42% 3 Missing ⚠️
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     
Flag Coverage Δ
unittests 95.95% <93.03%> (+5.74%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 06:42:22
  Coverage date: 05/22/2026 - 06:40:27 - 05/22/2026 - 06:42:12
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1297
  Files: 542
  Line coverage: 94.8%
  Covered lines: 36436
  Uncovered lines: 1976
  Coverable lines: 38412
  Total lines: 84735
  Branch coverage: 76% (10617 of 13957)
  Covered branches: 10617
  Total branches: 13957
  Method coverage: 96.3% (7076 of 7343)
  Full method coverage: 88.4% (6498 of 7343)
  Covered methods: 7076
  Fully covered methods: 6498
  Total methods: 7343

PatternKit.Core                                                                                                       96%
  PatternKit.Application.AntiCorruption.AntiCorruptionLayer<T1, T2>                                                 90.4%
  PatternKit.Application.AntiCorruption.AntiCorruptionResult<T>                                                      100%
  PatternKit.Application.AuditLog.AuditLogAppendResult<T>                                                           85.7%
  PatternKit.Application.AuditLog.InMemoryAuditLog<T1, T2>                                                          95.4%
  PatternKit.Application.DataMapping.DataMapper<T1, T2>                                                             94.6%
  PatternKit.Application.DataMapping.DataMapperError                                                                  90%
  PatternKit.Application.DataMapping.DataMapperResult<T>                                                            84.6%
  PatternKit.Application.DomainEvents.DomainEventDispatcher<T>                                                      95.4%
  PatternKit.Application.DomainEvents.DomainEventDispatchResult                                                      100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.FeatureToggles.FeatureToggleDecision                                                       87.5%
  PatternKit.Application.FeatureToggles.FeatureToggleRule<T>                                                         100%
  PatternKit.Application.FeatureToggles.FeatureToggleSet<T>                                                         96.9%
  PatternKit.Application.IdentityMap.IdentityMap<T1, T2>                                                             100%
  PatternKit.Application.IdentityMap.IdentityMapResult<T>                                                           92.8%
  PatternKit.Application.MaterializedViews.MaterializedView<T1, T2>                                                 98.4%
  PatternKit.Application.Repository.InMemoryRepository<T1, T2>                                                      92.8%
  PatternKit.Application.Repository.RepositoryResult<T>                                                             93.3%
  PatternKit.Application.ServiceLayer.ServiceLayerOperation<T1, T2>                                                 96.7%
  PatternKit.Application.ServiceLayer.ServiceLayerResult<T>                                                         94.7%
  PatternKit.Application.ServiceLayer.ServiceLayerRule<T>                                                            100%
  PatternKit.Application.Specification.Specification<T>                                                              100%
  PatternKit.Application.Specification.SpecificationRegistry<T>                                                     93.3%
  PatternKit.Application.TableDataGateway.InMemoryTableDataGateway<T1, T2>                                            86%
  PatternKit.Application.TableDataGateway.TableGatewayResult<T>                                                     82.3%
  PatternKit.Application.TransactionScript.TransactionScript<T1, T2>                                                  97%
  PatternKit.Application.TransactionScript.TransactionScriptError                                                     90%
  PatternKit.Application.TransactionScript.TransactionScriptResult<T>                                                100%
  PatternKit.Application.UnitOfWork.UnitOfWork                                                                      90.9%
  PatternKit.Application.UnitOfWork.UnitOfWorkResult                                                                94.7%
  PatternKit.Application.UnitOfWork.UnitOfWorkRollbackResult                                                         100%
  PatternKit.Application.UnitOfWork.UnitOfWorkStep                                                                   100%
  PatternKit.Behavioral.Chain.ActionChain<T>                                                                         100%
  PatternKit.Behavioral.Chain.AsyncActionChain<T>                                                                    100%
  PatternKit.Behavioral.Chain.AsyncResultChain<T1, T2>                                                              97.7%
  PatternKit.Behavioral.Chain.ResultChain<T1, T2>                                                                    100%

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +122 to +131
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();
Comment on lines +79 to +87
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;
}
Comment on lines +55 to +60
public static class NotificationHost;
"""),
Compile("""
using PatternKit.Generators.EventNotification;
[GenerateEventNotification(typeof(string), typeof(string))]
public static partial class NotificationHost;
Comment on lines +496 to +507
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"]);
@JerrettDavis JerrettDavis merged commit cb4a93d into main May 22, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feature/event-notification-309 branch May 22, 2026 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Gateway Aggregation pattern

2 participants