Skip to content

feat: add Gateway Routing pattern#319

Merged
JerrettDavis merged 1 commit into
mainfrom
feature/gateway-routing-315
May 22, 2026
Merged

feat: add Gateway Routing pattern#319
JerrettDavis merged 1 commit into
mainfrom
feature/gateway-routing-315

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

Summary

  • add Gateway Routing runtime with ordered route dispatch and fallback handling
  • add source generator attributes/generator with diagnostics PKGR001-PKGR005
  • add product gateway routing example with IServiceCollection and ASP.NET Core endpoint integration
  • document pattern, generator, example, and production readiness catalogs

Closes #315

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

Note: local full examples build remains blocked by the known CS9057 analyzer/compiler mismatch; hosted CI is authoritative for the full examples/docs pass.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2026

Test Results

  1 files    1 suites   2m 37s ⏱️
966 tests 966 ✅ 0 💤 0 ❌
971 runs  971 ✅ 0 💤 0 ❌

Results for commit 1a45c41.

♻️ This comment has been updated with latest results.

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 Gateway Routing pattern to PatternKit, including a fluent runtime router, a Roslyn incremental generator to emit router factories from attributes, and a documented/DI-importable example with catalog coverage.

Changes:

  • Introduces GatewayRouting<TRequest,TResponse> runtime with ordered route dispatch and fallback handling.
  • Adds [GenerateGatewayRouting] + route/handler/fallback attributes and a GatewayRoutingGenerator with diagnostics PKGR001PKGR005.
  • Adds tests, example integration (DI + ASP.NET Core minimal API mapping), and updates docs/catalog entries.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/PatternKit.Tests/Cloud/GatewayRouting/GatewayRoutingTests.cs Adds runtime behavior + validation coverage for dispatch/fallback/config errors.
test/PatternKit.Generators.Tests/GatewayRoutingGeneratorTests.cs Verifies generated factory output + diagnostics emission.
test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs Ensures new generator attributes are covered by attribute surface tests.
test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs Updates production readiness catalog expectations for new pattern.
test/PatternKit.Examples.Tests/GatewayRoutingDemo/ProductGatewayRoutingDemoTests.cs Tests fluent + generated example behavior and catalog registration.
src/PatternKit.Generators/GatewayRouting/GatewayRoutingGenerator.cs Implements new incremental generator and diagnostics.
src/PatternKit.Generators/AnalyzerReleases.Unshipped.md Registers new diagnostic IDs PKGR001–PKGR005.
src/PatternKit.Generators.Abstractions/Cloud/GatewayRoutingAttributes.cs Adds generator attribute types for Gateway Routing.
src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs Catalogs the pattern’s runtime/generator/docs/example/test artifacts.
src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs Adds the “Product Gateway Routing” example descriptor.
src/PatternKit.Examples/GatewayRoutingDemo/ProductGatewayRoutingDemo.cs Adds example: fluent router, generated router, DI extension, endpoint mapping.
src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs Adds DI import surface for the new example.
src/PatternKit.Core/Cloud/GatewayRouting/GatewayRouting.cs Adds Gateway Routing runtime implementation.
docs/patterns/toc.yml Adds Gateway Routing to patterns TOC.
docs/patterns/cloud/gateway-routing.md Documents the new pattern and runtime usage.
docs/guides/pattern-coverage.md Adds pattern coverage entry for Gateway Routing.
docs/generators/toc.yml Adds Gateway Routing to generator docs TOC.
docs/generators/index.md Adds generator index entry + quick reference snippet.
docs/generators/gateway-routing.md Documents generator usage + diagnostics list.
docs/examples/toc.yml Adds the Product Gateway Routing example to examples TOC.
docs/examples/product-gateway-routing.md Documents the example usage and integration surfaces.
docs/examples/index.md Adds the example to the examples index listing.

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

Comment on lines +130 to +139
private static NamedMember[] NamedMembers(INamedTypeSymbol type, string attributeName)
=> type.GetMembers().OfType<IMethodSymbol>()
.Select(method => new
{
Method = method,
Attribute = method.GetAttributes().FirstOrDefault(attr => attr.AttributeClass?.ToDisplayString() == attributeName)
})
.Where(static item => item.Attribute is not null)
.Select(item => new NamedMember((string)item.Attribute!.ConstructorArguments[0].Value!, item.Method, attributeName == RouteAttributeName ? MemberKind.Route : MemberKind.Handler))
.ToArray();
Comment on lines +141 to +150
private static FallbackMember[] MembersWith(INamedTypeSymbol type, string attributeName)
=> type.GetMembers().OfType<IMethodSymbol>()
.Select(method => new
{
Method = method,
Attribute = method.GetAttributes().FirstOrDefault(attr => attr.AttributeClass?.ToDisplayString() == attributeName)
})
.Where(static item => item.Attribute is not null)
.Select(static item => new FallbackMember(item.Attribute!.ConstructorArguments.Length == 0 ? "fallback" : (string)item.Attribute.ConstructorArguments[0].Value!, item.Method))
.ToArray();
Comment on lines +32 to +40
private static readonly DiagnosticDescriptor DuplicateRoute = new(
"PKGR004", "Gateway Routing route is duplicated",
"Gateway Routing route name '{0}' is duplicated",
"PatternKit.Generators.GatewayRouting", DiagnosticSeverity.Error, true);

private static readonly DiagnosticDescriptor MissingHandler = new(
"PKGR005", "Gateway Routing handler is missing",
"Gateway Routing route '{0}' must have exactly one matching handler",
"PatternKit.Generators.GatewayRouting", DiagnosticSeverity.Error, true);
Comment on lines +112 to +117
var pairs = routes.Select(route => new RoutePair(route.Name, route.Method, handlers.SingleOrDefault(handler => string.Equals(handler.Name, route.Name, StringComparison.OrdinalIgnoreCase))?.Method)).ToArray();
var missing = pairs.FirstOrDefault(pair => pair.Handler is null);
if (missing is not null)
{
context.ReportDiagnostic(Diagnostic.Create(MissingHandler, node.Identifier.GetLocation(), missing.Name));
return;
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 22, 2026

Codecov Report

❌ Patch coverage is 93.09091% with 19 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.86%. Comparing base (0483e40) to head (1a45c41).

Files with missing lines Patch % Lines
...nerators/GatewayRouting/GatewayRoutingGenerator.cs 94.00% 9 Missing ⚠️
...es/GatewayRoutingDemo/ProductGatewayRoutingDemo.cs 74.19% 8 Missing ⚠️
...ernKit.Core/Cloud/GatewayRouting/GatewayRouting.cs 96.22% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #319      +/-   ##
==========================================
+ Coverage   90.00%   95.86%   +5.86%     
==========================================
  Files         452      456       +4     
  Lines       37512    37785     +273     
  Branches     5330     5377      +47     
==========================================
+ Hits        33761    36223    +2462     
+ Misses       1663     1562     -101     
+ Partials     2088        0    -2088     
Flag Coverage Δ
unittests 95.86% <93.09%> (+5.86%) ⬆️

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 force-pushed the feature/gateway-routing-315 branch from 225c236 to 1a45c41 Compare May 22, 2026 14:08
@github-actions
Copy link
Copy Markdown
Contributor

Code Coverage

Summary
  Generated on: 05/22/2026 - 14:13:29
  Coverage date: 05/22/2026 - 14:11:44 - 05/22/2026 - 14:13:18
  Parser: MultiReport (9x Cobertura)
  Assemblies: 4
  Classes: 1352
  Files: 557
  Line coverage: 94.7%
  Covered lines: 37200
  Uncovered lines: 2050
  Coverable lines: 39250
  Total lines: 86358
  Branch coverage: 75.7% (10832 of 14294)
  Covered branches: 10832
  Total branches: 14294
  Method coverage: 96.2% (7272 of 7552)
  Full method coverage: 88.4% (6676 of 7552)
  Covered methods: 7272
  Fully covered methods: 6676
  Total methods: 7552

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

@JerrettDavis JerrettDavis merged commit ec6c95c into main May 22, 2026
12 checks passed
@JerrettDavis JerrettDavis deleted the feature/gateway-routing-315 branch May 22, 2026 14:19
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 Gateway Routing pattern

2 participants