Skip to content

feat: add ports and adapters pattern#497

Merged
JerrettDavis merged 1 commit into
mainfrom
feature/ports-and-adapters-pattern-484
Jun 1, 2026
Merged

feat: add ports and adapters pattern#497
JerrettDavis merged 1 commit into
mainfrom
feature/ports-and-adapters-pattern-484

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Closes #484.\n\nAdds a Ports and Adapters / hexagonal architecture pattern with fluent runtime APIs, source generator, TinyBDD coverage, IServiceCollection-backed example, benchmark coverage, and docs/catalog updates.\n\nValidation run locally:\n- dotnet build PatternKit.slnx --configuration Release --no-restore -p:UseSharedCompilation=false\n- dotnet test test/PatternKit.Tests/PatternKit.Tests.csproj --configuration Release --framework net8.0 --no-build -p:TestTfmsInParallel=false -p:UseSharedCompilation=false\n- dotnet test test/PatternKit.Generators.Tests/PatternKit.Generators.Tests.csproj --configuration Release --framework net8.0 --no-build -p:TestTfmsInParallel=false -p:UseSharedCompilation=false\n- dotnet test test/PatternKit.Hosting.Extensions.Tests/PatternKit.Hosting.Extensions.Tests.csproj --configuration Release --framework net8.0 --no-build -p:TestTfmsInParallel=false -p:UseSharedCompilation=false\n- dotnet test test/PatternKit.Examples.Tests/PatternKit.Examples.Tests.csproj --configuration Release --framework net8.0 --no-build -p:TestTfmsInParallel=false -p:UseSharedCompilation=false\n- dotnet format PatternKit.slnx --verify-no-changes --verbosity minimal\n- docfx metadata docs/docfx.json; docfx build docs/docfx.json

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

⚠️ 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

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 first-class “Ports and Adapters” (hexagonal architecture) pattern across PatternKit’s runtime APIs, source generator, examples, benchmarks, and docs—integrating it into the production-readiness catalog/coverage gates.

Changes:

  • Introduces PortsAndAdaptersPipeline<...> fluent runtime API + TinyBDD runtime coverage.
  • Adds [GeneratePortsAndAdapters] abstractions and a Roslyn incremental generator + generator tests/diagnostics registration.
  • Integrates the new pattern into catalogs, docs navigation, examples (including IServiceCollection import), and BenchmarkDotNet coverage/docs counts.

Reviewed changes

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

Show a summary per file
File Description
src/PatternKit.Core/Application/PortsAndAdapters/PortsAndAdaptersPipeline.cs Adds the fluent runtime pipeline API and builder.
src/PatternKit.Generators.Abstractions/PortsAndAdapters/PortsAndAdaptersAttributes.cs Adds generator-facing attributes for ports/adapters declarations.
src/PatternKit.Generators/PortsAndAdapters/PortsAndAdaptersGenerator.cs Implements the incremental generator emitting pipeline factories + diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new analyzer diagnostic IDs (PKPA001–PKPA004).
test/PatternKit.Tests/Application/PortsAndAdapters/PortsAndAdaptersPipelineTests.cs TinyBDD runtime tests for fluent pipeline behavior + validation.
test/PatternKit.Generators.Tests/PortsAndAdaptersGeneratorTests.cs Validates generator output and diagnostics via Roslyn test harness.
src/PatternKit.Examples/PortsAndAdaptersDemo/OrderEntryPortsAndAdaptersDemo.cs Adds an importable example with fluent + generated paths and DI registration.
test/PatternKit.Examples.Tests/PortsAndAdaptersDemo/OrderEntryPortsAndAdaptersDemoTests.cs Tests the example for fluent/generated correctness and DI importability.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Wires the new example into the shared examples DI registration surface.
benchmarks/PatternKit.Benchmarks/Application/PortsAndAdaptersBenchmarks.cs Adds benchmark coverage for fluent vs generated construction/execution.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Adds Ports and Adapters to the production-readiness pattern catalog.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds the new demo to the example catalog.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates pattern list and family counts for the new pattern.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs Updates expected route-result totals and humanization for new benchmark class.
README.md Updates pattern counts and table to include Ports and Adapters.
docs/index.md Updates pattern counts and table to include Ports and Adapters.
docs/patterns/toc.yml Adds Ports and Adapters to patterns TOC.
docs/patterns/application/ports-and-adapters.md Adds pattern documentation page.
docs/generators/toc.yml Adds Ports and Adapters generator doc to TOC.
docs/generators/index.md Adds generator overview entry for Ports and Adapters.
docs/generators/ports-and-adapters.md Adds generator documentation page.
docs/examples/toc.yml Adds order-entry ports/adapters example to examples TOC.
docs/examples/index.md Adds ports/adapters example overview entry.
docs/examples/order-entry-ports-and-adapters.md Adds the example documentation page.
docs/guides/benchmark-results.md Updates benchmark results matrix entries and coverage totals.

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

Comment thread src/PatternKit.Generators/PortsAndAdapters/PortsAndAdaptersGenerator.cs Outdated
Comment thread src/PatternKit.Generators/PortsAndAdapters/PortsAndAdaptersGenerator.cs Outdated
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Test Results

    12 files      12 suites   11m 19s ⏱️
 4 160 tests  4 160 ✅ 0 💤 0 ❌
12 917 runs  12 917 ✅ 0 💤 0 ❌

Results for commit 3c7e15b.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

🔍 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.

@JerrettDavis JerrettDavis force-pushed the feature/ports-and-adapters-pattern-484 branch from 92ed2ed to 3c7e15b Compare June 1, 2026 11:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 1, 2026

Code Coverage

Summary
  Generated on: 06/01/2026 - 12:04:15
  Coverage date: 06/01/2026 - 12:02:29 - 06/01/2026 - 12:04:04
  Parser: MultiReport (8x Cobertura)
  Assemblies: 5
  Classes: 1787
  Files: 603
  Line coverage: 97.4%
  Covered lines: 47959
  Uncovered lines: 1279
  Coverable lines: 49238
  Total lines: 104519
  Branch coverage: 84.3% (15353 of 18205)
  Covered branches: 15353
  Total branches: 18205
  Method coverage: 97.3% (9343 of 9601)
  Full method coverage: 91.5% (8794 of 9601)
  Covered methods: 9343
  Fully covered methods: 8794
  Total methods: 9601

PatternKit.Core                                                                                                     96.1%
  PatternKit.Application.ActivityTracking.ActivityGateState                                                          100%
  PatternKit.Application.ActivityTracking.ActivityLease                                                              100%
  PatternKit.Application.ActivityTracking.ActivityRecord                                                             100%
  PatternKit.Application.ActivityTracking.ActivityTracker                                                            100%
  PatternKit.Application.Aggregates.AggregateCommandHandler<T1, T2, T3>                                              100%
  PatternKit.Application.Aggregates.AggregateCommandResult<T>                                                        100%
  PatternKit.Application.Aggregates.AggregateRoot<T1, T2>                                                            100%
  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.BoundedContexts.BoundedContextAdapter                                                       100%
  PatternKit.Application.BoundedContexts.BoundedContextCapability                                                   83.3%
  PatternKit.Application.BoundedContexts.BoundedContextDescriptor                                                   95.4%
  PatternKit.Application.ContextMaps.ContextMapDescriptor                                                           96.8%
  PatternKit.Application.ContextMaps.ContextMapRelationship                                                          100%
  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.DomainServices.DomainServiceOperation<T1, T2>                                               100%
  PatternKit.Application.DomainServices.DomainServiceRegistry<T1, T2>                                                100%
  PatternKit.Application.EventSourcing.EventStoreAppendResult                                                        100%
  PatternKit.Application.EventSourcing.InMemoryEventStore<T1, T2>                                                   97.9%
  PatternKit.Application.EventSourcing.StoredEvent<T1, T2>                                                            80%
  PatternKit.Application.EventualConsistency.EventualConsistencyEvaluation<T>                                       92.3%
  PatternKit.Application.EventualConsistency.EventualConsistencyMonitor<T>                                          97.2%
  PatternKit.Application.EventualConsistency.EventualConsistencyMonitorState<T>                                      100%
  PatternKit.Application.EventualConsistency.EventualConsistencyWatermarks<T>                                       96.7%
  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.LazyLoading.LazyLoad<T>                                                                    98.1%
  PatternKit.Application.LazyLoading.LazyLoadResult<T>                                                               100%
  PatternKit.Application.ManualTaskGates.ManualTaskGate<T>                                                          98.5%

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 1, 2026

Codecov Report

❌ Patch coverage is 97.76786% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.40%. Comparing base (fc97436) to head (3c7e15b).

Files with missing lines Patch % Lines
...tors/PortsAndAdapters/PortsAndAdaptersGenerator.cs 96.72% 4 Missing ⚠️
...sAndAdaptersDemo/OrderEntryPortsAndAdaptersDemo.cs 96.55% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             main     #497     +/-   ##
=========================================
  Coverage   97.40%   97.40%             
=========================================
  Files         599      603      +4     
  Lines       49014    49238    +224     
  Branches     3167       34   -3133     
=========================================
+ Hits        47742    47961    +219     
- Misses       1272     1277      +5     
Flag Coverage Δ
unittests 97.40% <97.76%> (+<0.01%) ⬆️

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 aa92ac9 into main Jun 1, 2026
12 checks passed
@JerrettDavis JerrettDavis deleted the feature/ports-and-adapters-pattern-484 branch June 1, 2026 12:11
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 Ports and Adapters architecture pattern

2 participants