Feature/26 fluent create template pattern#56
Conversation
- Add abstract TemplateMethod<TContext, TResult> with optional synchronization and before/after hooks - Add fluent Template<TContext, TResult> with Before/After/OnError/Synchronized and Execute/TryExecute - Add examples: subclassing demo (DataProcessor) and fluent demo (TemplateFluentDemo) - Add tests: TemplateMethodTests and TemplateFluentTests for correctness, concurrency, and error handling - Add docs for pattern and demo; update Behavioral patterns ToC and Examples index Build: PASS (multi-target) Tests: PASS (840/840)
There was a problem hiding this comment.
Pull Request Overview
This PR introduces Template Method pattern implementations with both inheritance-based and fluent composition APIs. The implementation provides structured algorithm skeletons with customizable hooks for before/after operations, error handling, and optional synchronization.
- Adds four new template classes:
TemplateMethod<TContext,TResult>,AsyncTemplateMethod<TContext,TResult>,Template<TContext,TResult>, andAsyncTemplate<TContext,TResult> - Provides comprehensive test coverage for both sync and async variants with thread safety and error handling scenarios
- Includes example implementations and documentation demonstrating practical usage patterns
Reviewed Changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/PatternKit.Core/Behavioral/Template/TemplateMethod.cs | Base class for inheritance-based template method with sync execution |
| src/PatternKit.Core/Behavioral/Template/AsyncTemplateMethod.cs | Base class for inheritance-based async template method with cancellation support |
| src/PatternKit.Core/Behavioral/Template/Template.cs | Fluent builder for composable sync template with multicast hooks |
| src/PatternKit.Core/Behavioral/Template/AsyncTemplate.cs | Fluent builder for composable async template with array-based hook storage |
| test/PatternKit.Tests/Behavioral/TemplateMethodTests.cs | Test coverage for sync template method base class |
| test/PatternKit.Tests/Behavioral/TemplateFluentTests.cs | Test coverage for fluent sync template builder |
| test/PatternKit.Tests/Behavioral/AsyncTemplateMethodTests.cs | Test coverage for async template method base class |
| test/PatternKit.Tests/Behavioral/AsyncTemplateFluentTests.cs | Test coverage for fluent async template builder |
| Multiple test files | Cleanup of unused using statements |
| Multiple example files | Demo implementations showing practical usage patterns |
| Documentation files | Pattern documentation and usage examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #56 +/- ##
==========================================
+ Coverage 77.19% 83.31% +6.11%
==========================================
Files 64 71 +7
Lines 4741 4951 +210
Branches 744 773 +29
==========================================
+ Hits 3660 4125 +465
+ Misses 827 826 -1
+ Partials 254 0 -254
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:
|
Code Coverage |
No description provided.