feat: add message channel pattern support#295
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 2m 32s ⏱️ Results for commit b526cd4. |
There was a problem hiding this comment.
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>inPatternKit.Corewith bounded/unbounded behavior and backpressure options. - Adds
[GenerateMessageChannel]attribute +MessageChannelGeneratorwith 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); |
| 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)); |
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 #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
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 #289.
What changed
MessageChannel<TPayload>runtime pattern with unbounded and bounded channel behavior.[GenerateMessageChannel]source generator support with diagnostics and attribute coverage.IServiceCollectionregistration and aggregateAddPatternKitExamples()integration.Local validation
dotnet build src\PatternKit.Core\PatternKit.Core.csproj -f netstandard2.0 /p:UseSharedCompilation=falsedotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net8.0 /p:UseSharedCompilation=falsedotnet build src\PatternKit.Core\PatternKit.Core.csproj -f net10.0 /p:UseSharedCompilation=falsedotnet build src\PatternKit.Generators.Abstractions\PatternKit.Generators.Abstractions.csproj /p:UseSharedCompilation=falsedotnet build src\PatternKit.Generators\PatternKit.Generators.csproj /p:UseSharedCompilation=falsedotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~MessageChannelTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsedotnet test test\PatternKit.Tests\PatternKit.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~MessageChannelTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsedotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net8.0 --no-restore --filter "FullyQualifiedName~MessageChannelGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsedotnet test test\PatternKit.Generators.Tests\PatternKit.Generators.Tests.csproj -f net10.0 --no-restore --filter "FullyQualifiedName~MessageChannelGeneratorTests|FullyQualifiedName~AbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falsegit diff --checkLocal 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.