feat: add specification pattern#226
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 2m 20s ⏱️ Results for commit 583d82c. |
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. |
There was a problem hiding this comment.
Pull request overview
Adds a new Specification pattern “slice” to PatternKit, including a fluent runtime API, a source generator for named registries, a DI-integrated example, and updates to docs/catalog coverage.
Changes:
- Introduces
Specification<T>/ISpecification<T>andSpecificationRegistry<T>for fluent rule composition and named rule lookup. - Adds
SpecificationGeneratorplus new abstractions attributes and generator tests/diagnostics registration. - Adds a loan-approval example (docs + code + DI wiring) and updates pattern/example catalogs and coverage tests.
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/Application/Specification/SpecificationTests.cs | TinyBDD coverage for fluent specs and registry behavior. |
| test/PatternKit.Generators.Tests/SpecificationGeneratorTests.cs | Validates generated registry output + generator diagnostics. |
| test/PatternKit.Generators.Tests/AbstractionsAttributeCoverageTests.cs | Adds specification attributes to attribute-usage coverage checks. |
| test/PatternKit.Examples.Tests/SpecificationDemo/LoanApprovalSpecificationDemoTests.cs | Ensures fluent vs generated registries match and DI wiring works. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates expected catalog entries/counts to include Specification. |
| test/PatternKit.Examples.Tests/DependencyInjection/PatternKitExampleDependencyInjectionTests.cs | Verifies the new example is DI-resolvable and runnable. |
| src/PatternKit.Generators/Specification/SpecificationGenerator.cs | New incremental generator producing SpecificationRegistry<T> factories. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers PKSPEC00x diagnostics in analyzer release notes. |
| src/PatternKit.Generators.Abstractions/Specification/SpecificationAttributes.cs | Adds [GenerateSpecificationRegistry] / [SpecificationRule] attributes. |
| src/PatternKit.Examples/SpecificationDemo/LoanApprovalSpecificationDemo.cs | Adds a production-style loan approval spec example (fluent + generated + DI). |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds Specification to the pattern coverage catalog. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds “Loan Approval Specifications” to the example catalog. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the new example into AddPatternKitExamples. |
| src/PatternKit.Core/Application/Specification/Specification.cs | Core implementation of specification + registry APIs. |
| docs/patterns/application/specification.md | New pattern documentation for fluent + generated paths. |
| docs/guides/pattern-coverage.md | Updates coverage guide table to include Specification. |
| docs/generators/toc.yml | Adds generator doc entry for Specification. |
| docs/generators/specification.md | New generator documentation for usage/rule shape/diagnostics. |
| docs/generators/index.md | Adds Specification to the generators index table. |
| docs/examples/toc.yml | Adds example doc entry for loan approval specs. |
| docs/examples/loan-approval-specifications.md | New end-to-end example documentation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| sb.AppendLine(); | ||
| } | ||
|
|
||
| sb.Append("partial ").Append(type.TypeKind == TypeKind.Struct ? "struct" : "class").Append(' ').Append(type.Name).AppendLine(); |
|
|
||
| private SpecificationRegistry(IReadOnlyDictionary<string, ISpecification<T>> specifications) | ||
| => _specifications = specifications; | ||
|
|
||
| /// <summary>Registered specification names.</summary> | ||
| public IReadOnlyCollection<string> Names => _specifications.Keys.ToArray(); |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
==========================================
+ Coverage 91.43% 96.52% +5.08%
==========================================
Files 272 276 +4
Lines 26029 26277 +248
Branches 3612 3651 +39
==========================================
+ Hits 23800 25363 +1563
+ Misses 978 914 -64
+ Partials 1251 0 -1251
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:
|
Adds a production-ready Specification pattern slice with fluent runtime composition, a source-generated registry path, DI integration, docs, catalog coverage, and TinyBDD tests.
Validation run locally:
Full test projects still rely on CI here because the local SDK rejects the repo's newer Roslyn analyzer build.