Skip to content

feat: add channel adapter pattern support#298

Merged
JerrettDavis merged 1 commit into
mainfrom
feat/channel-adapter-pattern
May 22, 2026
Merged

feat: add channel adapter pattern support#298
JerrettDavis merged 1 commit into
mainfrom
feat/channel-adapter-pattern

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #292.

Summary

  • Adds ChannelAdapter runtime support for bidirectional external DTO to PatternKit message channel integration.
  • Adds [GenerateChannelAdapter], [ChannelAdapterInbound], and [ChannelAdapterOutbound] source generator support with diagnostics.
  • Adds a DI-ready ERP channel adapter example, docs, catalog entries, and TinyBDD coverage.

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 net10.0 /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 --no-restore --filter "FullyQualifiedName~ChannelAdapterTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~ChannelAdapterTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedNameChannelAdapterGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedNameChannelAdapterGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • git diff --check

Local examples build remains blocked by the existing analyzer/compiler mismatch (CS9057) and generated demo types; hosted CI remains authoritative for examples/docs.

@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

745 tests   745 ✅  33s ⏱️
  1 suites    0 💤
  1 files      0 ❌

Results for commit 16bddf9.

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 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/outbound MessageChannel<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.

Comment on lines +41 to +45
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);
}
Comment on lines +6 to +12
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();
Comment on lines +112 to +113
sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine();
sb.AppendLine("{");
@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 02:48:58
  Coverage date: 05/22/2026 - 02:47:44 - 05/22/2026 - 02:48:48
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1200
  Files: 507
  Line coverage: 94.9%
  Covered lines: 34947
  Uncovered lines: 1878
  Coverable lines: 36825
  Total lines: 81647
  Branch coverage: 76.5% (10202 of 13324)
  Covered branches: 10202
  Total branches: 13324
  Method coverage: 96.3% (6705 of 6957)
  Full method coverage: 88.5% (6161 of 6957)
  Covered methods: 6705
  Fully covered methods: 6161
  Total methods: 6957

PatternKit.Core                                                                                                    96.1%
  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%

@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 95.68966% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.03%. Comparing base (eb08291) to head (16bddf9).

Files with missing lines Patch % Lines
...tternKit.Core/Messaging/Adapters/ChannelAdapter.cs 87.27% 7 Missing ⚠️
...Kit.Examples/Messaging/ErpChannelAdapterExample.cs 96.15% 2 Missing ⚠️
...it.Generators/Messaging/ChannelAdapterGenerator.cs 98.87% 1 Missing ⚠️
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     
Flag Coverage Δ
unittests 96.03% <95.68%> (+5.66%) ⬆️

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.

@JerrettDavis JerrettDavis merged commit 9f92751 into main May 22, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feat/channel-adapter-pattern branch May 22, 2026 02:52
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 Channel Adapter enterprise integration pattern

2 participants