feat: add Strangler Fig pattern#318
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 2m 27s ⏱️ Results for commit 19b3a25. |
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 #318 +/- ##
==========================================
+ Coverage 90.07% 95.88% +5.81%
==========================================
Files 448 452 +4
Lines 37254 37512 +258
Branches 5290 5330 +40
==========================================
+ Hits 33555 35970 +2415
+ Misses 1637 1542 -95
+ Partials 2062 0 -2062
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:
|
There was a problem hiding this comment.
Pull request overview
Adds Strangler Fig as a first-class PatternKit pattern, including a fluent runtime router, a Roslyn source generator + diagnostics (PKSF001–PKSF004), and an end-to-end checkout migration example that integrates with DI and ASP.NET Core minimal APIs. This expands the Cloud Architecture catalog with a new incremental legacy-to-modern migration capability.
Changes:
- Introduces
StranglerFig<TRequest,TResponse>runtime (decision/result model + fluent builder) for routing requests to legacy vs modern handlers. - Adds
GenerateStranglerFiggenerator/attributes with diagnostics PKSF001–PKSF004 and generator/unit test coverage. - Adds a checkout migration example (fluent + generated), DI registration, endpoint mapping, and updates docs + production readiness catalogs.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Cloud/StranglerFig/StranglerFigTests.cs | Runtime behavior tests for modern vs legacy routing and configuration validation. |
| test/PatternKit.Generators.Tests/StranglerFigGeneratorTests.cs | Generator tests for factory generation and PKSF diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Ensures Strangler Fig attributes are included in the abstractions coverage suite. |
| test/PatternKit.Examples.Tests/StranglerFigDemo/CheckoutStranglerFigDemoTests.cs | Example tests covering fluent routing, DI import, and catalog assertions. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates expected pattern list/counts to include Strangler Fig. |
| src/PatternKit.Generators/StranglerFig/StranglerFigGenerator.cs | Incremental generator emitting Strangler Fig factory + diagnostics PKSF001–PKSF004. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new analyzer/generator diagnostic IDs (PKSF001–PKSF004). |
| src/PatternKit.Generators.Abstractions/Cloud/StranglerFigAttributes.cs | Adds generator attributes: [GenerateStranglerFig], [StranglerFigRoute], [StranglerFigLegacy], [StranglerFigModern]. |
| src/PatternKit.Examples/StranglerFigDemo/CheckoutStranglerFigDemo.cs | Adds checkout Strangler Fig example with fluent + generated routes, DI extension, and endpoint mapping. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Catalogs Strangler Fig pattern (docs/source/tests/generator/example paths + highlights). |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds “Checkout Strangler Fig Migration” example descriptor and integration surfaces. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Adds DI-importable CheckoutStranglerFigExample and wires it into AddPatternKitExamples(). |
| src/PatternKit.Core/Cloud/StranglerFig/StranglerFig.cs | Implements the Strangler Fig runtime router, decisions, and results. |
| docs/patterns/toc.yml | Adds Strangler Fig to the patterns TOC. |
| docs/patterns/cloud/strangler-fig.md | Documents the Strangler Fig runtime usage and generator/DI entrypoints. |
| docs/guides/pattern-coverage.md | Adds Strangler Fig to the pattern coverage guide table. |
| docs/generators/toc.yml | Adds Strangler Fig generator doc to generators TOC. |
| docs/generators/strangler-fig.md | Documents generator usage and diagnostics PKSF001–PKSF004. |
| docs/generators/index.md | Adds Strangler Fig to the generator index + quick reference snippet. |
| docs/examples/toc.yml | Adds checkout Strangler Fig example to examples TOC. |
| docs/examples/index.md | Adds checkout Strangler Fig example to examples index list. |
| docs/examples/checkout-strangler-fig.md | Documents the checkout Strangler Fig example usage (DI + runner). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| foreach (var route in _routes) | ||
| { | ||
| if (route.Matches(request)) | ||
| return StranglerFigResult<TResponse>.From(Name, StranglerFigDecision.Modern(route.Name), _modern(request)); | ||
| } | ||
|
|
||
| return StranglerFigResult<TResponse>.From(Name, StranglerFigDecision.Legacy(), _legacy(request)); | ||
| } |
| { | ||
| ScenarioExpect.Empty(result.Diagnostics); | ||
| var source = ScenarioExpect.Single(result.GeneratedSources); | ||
| ScenarioExpect.Contains("Build()", source); |
Summary
Closes #310
Validation
StranglerFigGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falseStranglerFigGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falseStranglerFigGeneratorTests|FullyQualifiedNameAbstractionsAttributeCoverageTests" /p:BuildProjectReferences=false /p:UseSharedCompilation=falseNote: local full examples build remains blocked by the known CS9057 analyzer/compiler mismatch; hosted CI is authoritative for the full examples/docs pass.