feat: add service layer pattern support#259
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 43s ⏱️ Results for commit e05cdf5. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #259 +/- ##
==========================================
+ Coverage 90.72% 96.13% +5.40%
==========================================
Files 332 336 +4
Lines 30328 30619 +291
Branches 4245 4292 +47
==========================================
+ Hits 27516 29436 +1920
+ Misses 1254 1183 -71
+ Partials 1558 0 -1558
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:
|
🔍 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. |
There was a problem hiding this comment.
Pull request overview
Adds first-class Service Layer support to PatternKit, including a fluent runtime API for defining application operations, a Roslyn source generator for factory emission from attributed declarations, and full documentation + example + test coverage.
Changes:
- Introduces
IServiceOperation<TRequest,TResponse>,ServiceLayerOperation<TRequest,TResponse>, rules, and result/status types inPatternKit.Application.ServiceLayer. - Adds
GenerateServiceLayerOperation+ServiceLayerRule/ServiceLayerHandlerattributes and an incremental generator that emits operation factories (with diagnostics + generator tests). - Adds a production-shaped example (fluent + generated paths), updates DI example catalog integration, and wires the pattern into docs/catalog coverage.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Application/ServiceLayer/ServiceLayerTests.cs | Adds TinyBDD runtime tests for Service Layer success, rejection, failure, and argument validation. |
| test/PatternKit.Generators.Tests/ServiceLayerGeneratorTests.cs | Adds generator tests asserting emitted factory source and diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Extends attribute coverage to include new Service Layer generator attributes. |
| test/PatternKit.Examples.Tests/ServiceLayerDemo/CustomerServiceLayerDemoTests.cs | Adds example tests for fluent vs generated execution and DI importability. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog expectations to include “Service Layer”. |
| test/PatternKit.Examples.Tests/DependencyInjection/PatternKitExampleDependencyInjectionTests.cs | Ensures the Service Layer example can be resolved and executed via the examples DI bundle. |
| src/PatternKit.Generators/ServiceLayer/ServiceLayerOperationGenerator.cs | Implements Service Layer incremental generator + diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new generator diagnostic IDs (PKSL001–PKSL005). |
| src/PatternKit.Generators.Abstractions/ServiceLayer/ServiceLayerAttributes.cs | Adds generator-facing attributes for declaring operations, rules, and handlers. |
| src/PatternKit.Examples/ServiceLayerDemo/CustomerServiceLayerDemo.cs | Adds the Service Layer demo (fluent + generated) and IServiceCollection registration. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds Service Layer to the pattern catalog with docs/tests/example pointers. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds a “Customer Service Layer Pattern” example descriptor. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Registers the Service Layer example in the unified examples DI extension. |
| src/PatternKit.Core/Application/ServiceLayer/ServiceLayer.cs | Adds the Service Layer runtime abstraction, builder, result types, and status enum. |
| docs/patterns/toc.yml | Adds Service Layer to patterns TOC. |
| docs/patterns/application/service-layer.md | Adds user-facing Service Layer pattern documentation. |
| docs/guides/pattern-coverage.md | Adds Service Layer to pattern coverage guide. |
| docs/generators/toc.yml | Adds Service Layer generator docs to generator TOC. |
| docs/generators/service-layer.md | Adds generator documentation + diagnostics list. |
| docs/generators/index.md | Adds Service Layer to the generator index table. |
| docs/examples/toc.yml | Adds the customer Service Layer example doc to examples TOC. |
| docs/examples/customer-service-layer-pattern.md | Adds the Service Layer example walkthrough doc. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (string.IsNullOrWhiteSpace(operationName)) | ||
| operationName = type.Name; | ||
|
|
||
| context.AddSource($"{type.Name}.ServiceLayer.g.cs", SourceText.From( | ||
| GenerateSource(type, requestType, responseType, handler.Name, rules.OrderBy(static rule => rule.Order).ToArray(), factoryName, operationName!), | ||
| Encoding.UTF8)); |
Code Coverage |
Closes #254.\n\nAdds the Service Layer application architecture pattern with fluent runtime support, source-generated operation factories, TinyBDD runtime/generator/example coverage, production-shaped IServiceCollection integration, and docs/catalog entries.