feat: add lazy load pattern#495
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
Adds a new Lazy Load application-architecture pattern to PatternKit, including a runtime primitive (LazyLoad<TValue>), a source generator ([GenerateLazyLoad] + LazyLoadGenerator), DI registration helpers, an importable example, docs/catalog updates, and benchmark coverage wiring.
Changes:
- Introduces
LazyLoad<TValue>runtime API with caching, TTL, invalidation, cancellation, and single-flight behavior. - Adds
[GenerateLazyLoad]attribute + Roslyn incremental generator with diagnostics and generator test coverage. - Integrates Lazy Load into hosting extensions, production-readiness catalogs, docs/TOCs, examples, and BenchmarkDotNet coverage matrix.
Reviewed changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/PatternKit.Tests/Application/LazyLoading/LazyLoadTests.cs | Adds TinyBDD runtime coverage for caching, TTL, invalidation, and cancellation behaviors. |
| test/PatternKit.Hosting.Extensions.Tests/DependencyInjection/PatternKitServiceCollectionExtensionsTests.cs | Extends hosting extension tests to validate AddPatternKitLazyLoad registration and argument validation. |
| test/PatternKit.Generators.Tests/LazyLoadGeneratorTests.cs | Adds generator scenarios covering source output and diagnostics. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitPatternCatalogTests.cs | Updates catalog assertions to include the new Lazy Load pattern. |
| test/PatternKit.Examples.Tests/ProductionReadiness/PatternKitBenchmarkCoverageTests.cs | Updates expected benchmark coverage matrix totals for the new pattern/routes. |
| test/PatternKit.Examples.Tests/LazyLoadDemo/CustomerProfileLazyLoadDemoTests.cs | Adds example validation for fluent + generated lazy load and DI import. |
| src/PatternKit.Hosting.Extensions/DependencyInjection/PatternKitServiceCollectionExtensions.cs | Adds AddPatternKitLazyLoad<TValue> DI registration helper. |
| src/PatternKit.Generators/LazyLoading/LazyLoadGenerator.cs | Introduces the Lazy Load incremental generator + PKLL diagnostics. |
| src/PatternKit.Generators/AnalyzerReleases.Unshipped.md | Registers new PKLL analyzer IDs in release notes. |
| src/PatternKit.Generators.Abstractions/LazyLoading/LazyLoadAttributes.cs | Adds [GenerateLazyLoad] attribute for source generation. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitPatternCatalog.cs | Adds Lazy Load to the production-readiness pattern catalog. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitHostingIntegrationCatalog.cs | Adds Lazy Load hosting integration entry for AddPatternKitLazyLoad<TValue>. |
| src/PatternKit.Examples/ProductionReadiness/PatternKitExampleCatalog.cs | Adds the new importable Lazy Load example to the example catalog. |
| src/PatternKit.Examples/LazyLoadDemo/CustomerProfileLazyLoadDemo.cs | Adds a real-world example demonstrating fluent + generated lazy load and DI composition. |
| src/PatternKit.Examples/DependencyInjection/PatternKitExampleServiceCollectionExtensions.cs | Wires the Lazy Load example into the examples DI registration surface. |
| src/PatternKit.Core/Application/LazyLoading/LazyLoad.cs | Adds the core runtime primitive (LazyLoad<TValue>) and result type. |
| README.md | Updates pattern counts/tables to include Lazy Load. |
| docs/patterns/toc.yml | Adds Lazy Load to the patterns TOC. |
| docs/patterns/application/lazy-load.md | Adds the Lazy Load pattern guide page. |
| docs/index.md | Updates pattern counts/tables on the docs landing page. |
| docs/guides/hosting-extensions.md | Documents the new AddPatternKitLazyLoad<TValue> hosting extension. |
| docs/guides/benchmark-results.md | Extends benchmark results/coverage matrix to include Lazy Load. |
| docs/generators/toc.yml | Adds Lazy Load to the generators TOC. |
| docs/generators/lazy-load.md | Adds generator documentation and diagnostics list for Lazy Load. |
| docs/generators/index.md | Adds Lazy Load to the generator index tables and examples. |
| docs/examples/toc.yml | Adds the new Lazy Load example to the examples TOC. |
| docs/examples/index.md | Adds Lazy Load example summary to the examples landing page. |
| docs/examples/customer-profile-lazy-load.md | Adds the Lazy Load demo documentation page. |
| benchmarks/PatternKit.Benchmarks/Application/LazyLoadBenchmarks.cs | Adds BenchmarkDotNet coverage for fluent vs generated lazy load construction/execution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Test Results 12 files 12 suites 11m 46s ⏱️ Results for commit eee67c8. ♻️ This comment has been updated with latest results. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #495 +/- ##
==========================================
- Coverage 97.41% 97.40% -0.02%
==========================================
Files 591 595 +4
Lines 48386 48648 +262
Branches 3124 34 -3090
==========================================
+ Hits 47137 47384 +247
- Misses 1249 1264 +15
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. |
f7c1429 to
eee67c8
Compare
Code Coverage |
Closes #487.
Summary
Validation