feat: add channel adapter pattern support#298
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results745 tests 745 ✅ 33s ⏱️ Results for commit 16bddf9. |
There was a problem hiding this comment.
Pull request overview
Adds the Channel Adapter enterprise integration pattern to PatternKit, including runtime support, a Roslyn source generator + diagnostics, and a DI-ready ERP example with docs/catalog/test coverage.
Changes:
- Introduces
ChannelAdapter<TExternal, TPayload>runtime API for bridging external DTOs with inbound/outboundMessageChannel<TPayload>. - Adds
[GenerateChannelAdapter]+[ChannelAdapterInbound]/[ChannelAdapterOutbound]generator support, diagnostics, and generator tests. - Adds ERP channel adapter example, catalog entries, and documentation updates across patterns/generators/examples.
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Messaging/Adapters/ChannelAdapterTests.cs | TinyBDD coverage for fluent runtime adapter behavior + basic builder validation. |
| test/PatternKit.Generators.Tests/ChannelAdapterGeneratorTests.cs | Verifies factory generation and generator diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Adds coverage for new generator attributes and their defaults/guards. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates expected catalog pattern list/count to include Channel Adapter. |
| test/PatternKit.Examples.Tests/Messaging/ErpChannelAdapterExampleTests.cs | Validates fluent vs generated adapter parity and DI import paths. |
| src/PatternKit.Generators/Messaging/ChannelAdapterGenerator.cs | Implements incremental generator for channel adapter factory generation + diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new generator diagnostic IDs for release notes. |
| src/PatternKit.Generators.Abstractions/Messaging/ChannelAdapterAttributes.cs | Adds generator attribute definitions for channel adapter generation. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Registers Channel Adapter pattern slice and its linked assets. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds ERP Channel Adapter example catalog descriptor. |
| src/PatternKit.Examples/Messaging/ErpChannelAdapterExample.cs | Adds ERP channel adapter fluent + generated example and DI registrations. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires ERP Channel Adapter example into AddPatternKitExamples(). |
| src/PatternKit.Core/Messaging/Adapters/ChannelAdapter.cs | Adds runtime ChannelAdapter<TExternal, TPayload> + result types. |
| docs/patterns/toc.yml | Adds Channel Adapter to patterns TOC. |
| docs/patterns/messaging/README.md | Adds Channel Adapter entry to messaging pattern index. |
| docs/patterns/messaging/channel-adapter.md | Adds Channel Adapter pattern documentation page. |
| docs/guides/pattern-coverage.md | Adds Channel Adapter row to coverage table. |
| docs/generators/toc.yml | Adds Channel Adapter generator page to generators TOC. |
| docs/generators/index.md | Adds Channel Adapter to generator index table. |
| docs/generators/channel-adapter.md | Adds Channel Adapter generator documentation page + diagnostics list. |
| docs/examples/toc.yml | Adds ERP Channel Adapter to examples TOC. |
| docs/examples/index.md | Adds ERP Channel Adapter to examples index list. |
| docs/examples/erp-channel-adapter.md | Adds ERP Channel Adapter example documentation page. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return ChannelAdapterOutboundResult<TExternal>.Empty(Name, received.ChannelName); | ||
|
|
||
| var external = _outbound(received.Message!, context ?? MessageContext.From(received.Message!)); | ||
| return ChannelAdapterOutboundResult<TExternal>.Success(Name, received.ChannelName, external); | ||
| } |
| var adapter = ChannelAdapter<ErpOrderDocument, OrderIntegrationMessage> | ||
| .Create("erp-orders-adapter") | ||
| .ReceiveInto(inboundChannel) | ||
| .SendFrom(outboundChannel) | ||
| .MapInbound((document, context) => Message<OrderIntegrationMessage>.Create(command)) | ||
| .MapOutbound((message, context) => ToErpDocument(message.Payload)) | ||
| .Build(); |
| sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine(); | ||
| sb.AppendLine("{"); |
Code Coverage |
🔍 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 #298 +/- ##
==========================================
+ Coverage 90.36% 96.03% +5.66%
==========================================
Files 412 416 +4
Lines 35175 35407 +232
Branches 4973 5010 +37
==========================================
+ Hits 31786 34003 +2217
+ Misses 1506 1404 -102
+ Partials 1883 0 -1883
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:
|
Closes #292.
Summary
Validation
ChannelAdapterGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falseChannelAdapterGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falseLocal examples build remains blocked by the existing analyzer/compiler mismatch (CS9057) and generated demo types; hosted CI remains authoritative for examples/docs.