Skip to content

feat: add message channel pattern support#295

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

feat: add message channel pattern support#295
JerrettDavis merged 1 commit into
mainfrom
feat/message-channel-pattern

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #289.

What changed

  • Adds the fluent MessageChannel<TPayload> runtime pattern with unbounded and bounded channel behavior.
  • Adds [GenerateMessageChannel] source generator support with diagnostics and attribute coverage.
  • Adds a production-shaped inventory message channel example with IServiceCollection registration and aggregate AddPatternKitExamples() integration.
  • Adds 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 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 --no-restore --filter "FullyQualifiedName~MessageChannelTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~MessageChannelTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~MessageChannelGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • dotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~MessageChannelGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=false
  • git diff --check

Local full examples build is blocked by the existing compiler/analyzer mismatch (CS9057) that prevents unrelated generated example types from being produced; hosted CI remains the full matrix gate.

@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   2m 32s ⏱️
881 tests 881 ✅ 0 💤 0 ❌
886 runs  886 ✅ 0 💤 0 ❌

Results for commit b526cd4.

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 “Message Channel” enterprise integration pattern slice across runtime, source generation, examples, tests, and documentation, integrating it into the production-readiness catalogs and DI aggregation (AddPatternKitExamples()).

Changes:

  • Introduces MessageChannel<TPayload> in PatternKit.Core with bounded/unbounded behavior and backpressure options.
  • Adds [GenerateMessageChannel] attribute + MessageChannelGenerator with initial diagnostics and generator tests.
  • Adds an inventory-oriented example (fluent + generated + DI) and wires it into the pattern/example catalogs and docs TOCs.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
test/PatternKit.Tests/Messaging/Channels/MessageChannelTests.cs Runtime tests for ordering, bounded capacity, backpressure behavior, and builder validation.
test/PatternKit.Generators.Tests/MessageChannelGeneratorTests.cs Generator smoke test (factory emitted + compilation succeeds) and diagnostics assertions.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Ensures the new attribute is included in attribute coverage and default/property behavior checks.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates catalog expectations to include “Message Channel” and count changes.
test/PatternKit.Examples.Tests/Messaging/InventoryMessageChannelExampleTests.cs Validates fluent vs generated behavior and DI import surfaces.
src/PatternKit.Generators/Messaging/MessageChannelGenerator.cs Implements the incremental generator and diagnostics for message channel factories.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Declares new generator diagnostic IDs for release tracking.
src/PatternKit.Generators.Abstractions/Messaging/MessageChannelAttributes.cs Adds [GenerateMessageChannel] attribute definition and configurable properties.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds Message Channel to the pattern coverage catalog entries.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds “Inventory Message Channel” to the example catalog.
src/PatternKit.Examples/Messaging/InventoryMessageChannelExample.cs Adds inventory message channel example, generated host type, and DI registration extension.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Wires the inventory message channel example into AddPatternKitExamples().
src/PatternKit.Core/Messaging/Channels/MessageChannel.cs Adds the in-memory typed message channel runtime implementation and result models.
docs/patterns/toc.yml Adds “Message Channel” to the patterns TOC.
docs/patterns/messaging/message-channel.md Adds runtime usage documentation for the pattern.
docs/guides/pattern-coverage.md Updates pattern coverage matrix to include Message Channel.
docs/generators/toc.yml Adds Message Channel generator doc to generators TOC.
docs/generators/message-channel.md Adds generator usage docs + diagnostics list.
docs/generators/index.md Adds Message Channel to the generators index table.
docs/examples/toc.yml Adds the inventory message channel example to examples TOC.
docs/examples/inventory-message-channel.md Adds documentation for the DI-importable inventory example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

public InventoryChannelSummary TryProcessNext()
{
var result = channel.TryReceive();
return new(true, result.Message?.Payload.Sku, result.Count, null);
Comment on lines +49 to +53
var factoryName = GetNamedString(attribute, "FactoryName") ?? "Create";
var channelName = GetNamedString(attribute, "ChannelName") ?? "message-channel";
var backpressure = GetNamedString(attribute, "BackpressurePolicy") ?? "Reject";

context.AddSource($"{type.Name}.MessageChannel.g.cs", SourceText.From(GenerateSource(type, payloadType, factoryName, channelName, capacity, backpressure), Encoding.UTF8));
@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 01:32:48
  Coverage date: 05/22/2026 - 01:31:08 - 05/22/2026 - 01:32:38
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1158
  Files: 492
  Line coverage: 94.9%
  Covered lines: 34386
  Uncovered lines: 1842
  Coverable lines: 36228
  Total lines: 80420
  Branch coverage: 76.5% (10034 of 13102)
  Covered branches: 10034
  Total branches: 13102
  Method coverage: 96.4% (6557 of 6797)
  Full method coverage: 88.5% (6022 of 6797)
  Covered methods: 6557
  Fully covered methods: 6022
  Total methods: 6797

PatternKit.Core                                                                                                    96.3%
  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.12195% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.05%. Comparing base (c82279a) to head (b526cd4).

Files with missing lines Patch % Lines
...tternKit.Core/Messaging/Channels/MessageChannel.cs 87.27% 7 Missing ⚠️
...it.Generators/Messaging/MessageChannelGenerator.cs 98.14% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #295      +/-   ##
==========================================
+ Coverage   90.43%   96.05%   +5.61%     
==========================================
  Files         400      404       +4     
  Lines       34658    34822     +164     
  Branches     4894     4916      +22     
==========================================
+ Hits        31344    33449    +2105     
+ Misses       1473     1373     -100     
+ Partials     1841        0    -1841     
Flag Coverage Δ
unittests 96.05% <95.12%> (+5.61%) ⬆️

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 4e8e7ad into main May 22, 2026
13 checks passed
@JerrettDavis JerrettDavis deleted the feat/message-channel-pattern branch May 22, 2026 01:37
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 Message Channel enterprise integration pattern

2 participants