Skip to content

feat(decorator): implemented the decorator pattern.#49

Merged
JerrettDavis merged 1 commit intomainfrom
feature/19-fluent-implement-decorator-pattern
Oct 7, 2025
Merged

feat(decorator): implemented the decorator pattern.#49
JerrettDavis merged 1 commit intomainfrom
feature/19-fluent-implement-decorator-pattern

Conversation

@JerrettDavis
Copy link
Copy Markdown
Owner

No description provided.

@JerrettDavis JerrettDavis requested a review from Copilot October 7, 2025 03:47
@JerrettDavis JerrettDavis self-assigned this Oct 7, 2025
@JerrettDavis JerrettDavis added the enhancement New feature or request label Oct 7, 2025
@JerrettDavis JerrettDavis linked an issue Oct 7, 2025 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements the decorator pattern for PatternKit, providing a fluent, allocation-light way to wrap components with layered behavior enhancements. The implementation supports before/after transformations and around wrappers for cross-cutting concerns like logging, caching, and validation.

Key changes:

  • Core Decorator<TIn, TOut> implementation with fluent builder API
  • Comprehensive Point of Sale example demonstrating real-world usage
  • Full test coverage with TinyBDD scenarios

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/PatternKit.Core/Structural/Decorator/Decorator.cs Core decorator implementation with fluent builder pattern
src/PatternKit.Examples/PointOfSale/ Complete Point of Sale example demonstrating decorator composition
test/PatternKit.Tests/Structural/Decorator/DecoratorTests.cs Comprehensive test suite covering all decorator scenarios
test/PatternKit.Examples.Tests/PointOfSale/PaymentProcessorTests.cs Integration tests for Point of Sale example
docs/patterns/structural/decorator/ Complete documentation including examples and API reference
src/PatternKit.Generators/packages.lock.json Updated dependency lockfile for additional target frameworks
README.md Updated to include decorator pattern examples and table

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 7, 2025

Code Coverage

Summary
  Generated on: 10/07/2025 - 03:48:46
  Coverage date: 10/07/2025 - 03:48:35 - 10/07/2025 - 03:48:43
  Parser: MultiReport (6x Cobertura)
  Assemblies: 3
  Classes: 138
  Files: 52
  Line coverage: 81.5%
  Covered lines: 2742
  Uncovered lines: 620
  Coverable lines: 3362
  Total lines: 10095
  Branch coverage: 72.8% (935 of 1284)
  Covered branches: 935
  Total branches: 1284
  Method coverage: 88.5% (738 of 833)
  Full method coverage: 82.1% (684 of 833)
  Covered methods: 738
  Fully covered methods: 684
  Total methods: 833

PatternKit.Core                                                                  85.8%
  PatternKit.Behavioral.Chain.ActionChain<T>                                     84.7%
  PatternKit.Behavioral.Chain.ResultChain<T1, T2>                                 100%
  PatternKit.Behavioral.Command.Command<T>                                       54.9%
  PatternKit.Behavioral.Iterator.AsyncFlow<T>                                     100%
  PatternKit.Behavioral.Iterator.AsyncFlowExtensions                              100%
  PatternKit.Behavioral.Iterator.AsyncReplayBuffer<T>                              75%
  PatternKit.Behavioral.Iterator.Flow<T>                                         94.4%
  PatternKit.Behavioral.Iterator.FlowExtensions                                  21.4%
  PatternKit.Behavioral.Iterator.ReplayableSequence<T>                           80.7%
  PatternKit.Behavioral.Iterator.ReplayableSequenceExtensions                     100%
  PatternKit.Behavioral.Iterator.SharedAsyncFlow<T>                               100%
  PatternKit.Behavioral.Iterator.SharedFlow<T>                                   63.1%
  PatternKit.Behavioral.Iterator.WindowSequence                                  92.3%
  PatternKit.Behavioral.Mediator.Mediator                                        88.2%
  PatternKit.Behavioral.Mediator.MediatorHelpers                                   50%
  PatternKit.Behavioral.Mediator.TaskExtensions                                     0%
  PatternKit.Behavioral.Strategy.ActionStrategy<T>                                 97%
  PatternKit.Behavioral.Strategy.AsyncStrategy<T1, T2>                           93.5%
  PatternKit.Behavioral.Strategy.Strategy<T1, T2>                                 100%
  PatternKit.Behavioral.Strategy.TryStrategy<T1, T2>                             95.8%
  PatternKit.Common.Option<T>                                                      80%
  PatternKit.Common.Throw                                                          80%
  PatternKit.Common.TryHandlerExtensions                                         33.3%
  PatternKit.Creational.Builder.BranchBuilder<T1, T2>                             100%
  PatternKit.Creational.Builder.BuilderExtensions                                 100%
  PatternKit.Creational.Builder.ChainBuilder<T>                                   100%
  PatternKit.Creational.Builder.Composer<T1, T2>                                  100%
  PatternKit.Creational.Builder.MutableBuilder<T>                                 100%
  PatternKit.Creational.Factory.Factory<T1, T2>                                  76.9%
  PatternKit.Creational.Factory.Factory<T1, T2, T3>                              76.9%
  PatternKit.Creational.Prototype.Prototype<T>                                    100%
  PatternKit.Creational.Prototype.Prototype<T1, T2>                                90%
  PatternKit.Creational.Singleton.Singleton<T>                                   96.5%
  PatternKit.Structural.Adapter.Adapter<T1, T2>                                  82.2%
  PatternKit.Structural.Bridge.Bridge<T1, T2, T3>                                77.5%
  PatternKit.Structural.Composite.Composite<T1, T2>                              97.3%
  PatternKit.Structural.Decorator.Decorator<T1, T2>                              97.6%

PatternKit.Examples                                                              78.3%
  PatternKit.Examples.ApiGateway.Demo                                            97.8%
  PatternKit.Examples.ApiGateway.MiniRouter                                      96.6%
  PatternKit.Examples.ApiGateway.Request                                           75%
  PatternKit.Examples.ApiGateway.Response                                         100%
  PatternKit.Examples.ApiGateway.Responses                                        100%
  PatternKit.Examples.Chain.AuthLoggingDemo                                      95.2%
  PatternKit.Examples.Chain.CardProcessors                                        100%
  PatternKit.Examples.Chain.CardTenderStrategy                                      0%
  PatternKit.Examples.Chain.CashTenderStrategy                                      0%
  PatternKit.Examples.Chain.ChainStage                                            100%
  PatternKit.Examples.Chain.CharityRoundUpRule                                     20%
  PatternKit.Examples.Chain.ConfigDriven.Bundle1OffEach                          14.2%
  PatternKit.Examples.Chain.ConfigDriven.CardTender                              72.2%
  PatternKit.Examples.Chain.ConfigDriven.Cash2Pct                                16.6%
  PatternKit.Examples.Chain.ConfigDriven.CashTender                              90.9%
  PatternKit.Examples.Chain.ConfigDriven.CharityRoundUp                           100%
  PatternKit.Examples.Chain.ConfigDriven.ConfigDrivenPipelineBuilderExtensions   94.2%
  PatternKit.Examples.Chain.ConfigDriven.ConfigDrivenPipelineDemo                 100%
  PatternKit.Examples.Chain.ConfigDriven.Loyalty5Pct                               20%
  PatternKit.Examples.Chain.ConfigDriven.NickelCashOnly                          77.7%
  PatternKit.Examples.Chain.ConfigDriven.PipelineOptions                          100%
  PatternKit.Examples.Chain.Customer                                              100%
  PatternKit.Examples.Chain.DeviceBus                                             100%
  PatternKit.Examples.Chain.GenericProcessor                                      100%
  PatternKit.Examples.Chain.HttpRequest                                           100%
  PatternKit.Examples.Chain.IRoundingRule                                         100%
  PatternKit.Examples.Chain.LineItem                                              100%
  PatternKit.Examples.Chain.MediatedTransactionPipelineDemo                       100%
  PatternKit.Examples.Chain.NickelCashOnlyRule                                    100%
  PatternKit.Examples.Chain.NoopCharityTracker                                      0%
  PatternKit.Examples.Chain.RoundingPipeline                                      100%
  PatternKit.Examples.Chain.Tender                                                100%
  PatternKit.Examples.Chain.TenderRouterFactory                                  91.3%
  PatternKit.Examples.Chain.TransactionContext                                    100%
  PatternKit.Examples.Chain.TransactionPipeline                                   100%
  PatternKit.Examples.Chain.TransactionPipelineBuilder                           92.3%
  PatternKit.Examples.Chain.TxResult                                              100%
  PatternKit.Examples.Generators.IntParser                                         60%
  PatternKit.Examples.Generators.OrderRouter                                     95.2%
  PatternKit.Examples.Generators.ScoreLabeler                                     100%
  PatternKit.Examples.MediatorDemo.AppMediator                                    100%
  PatternKit.Examples.MediatorDemo.AuditLogHandler                                100%
  PatternKit.Examples.MediatorDemo.BoxHelper                                       25%
  PatternKit.Examples.MediatorDemo.CountUpCmd                                     100%
  PatternKit.Examples.MediatorDemo.CountUpHandler                                 100%
  PatternKit.Examples.MediatorDemo.EchoCmd                                        100%
  PatternKit.Examples.MediatorDemo.EchoHandler                                    100%
  PatternKit.Examples.MediatorDemo.LoggingBehavior<T1, T2>                        100%
  PatternKit.Examples.MediatorDemo.MediatorAssemblyScanner                        100%
  PatternKit.Examples.MediatorDemo.MediatorDemoSink                               100%
  PatternKit.Examples.MediatorDemo.MediatorRegistry                               100%
  PatternKit.Examples.MediatorDemo.PingCmd                                        100%
  PatternKit.Examples.MediatorDemo.PingHandler                                    100%
  PatternKit.Examples.MediatorDemo.ServiceCollectionExtensions                   83.3%
  PatternKit.Examples.MediatorDemo.SumCmd                                         100%
  PatternKit.Examples.MediatorDemo.SumCmdBehavior                                 100%
  PatternKit.Examples.MediatorDemo.SumHandler                                     100%
  PatternKit.Examples.MediatorDemo.UserCreated                                    100%
  PatternKit.Examples.MediatorDemo.WelcomeEmailHandler                            100%
  PatternKit.Examples.PointOfSale.CustomerInfo                                    100%
  PatternKit.Examples.PointOfSale.Demo                                              0%
  PatternKit.Examples.PointOfSale.OrderLineItem                                   100%
  PatternKit.Examples.PointOfSale.PaymentProcessorDemo                           94.8%
  PatternKit.Examples.PointOfSale.PaymentReceipt                                  100%
  PatternKit.Examples.PointOfSale.PromotionConfig                                 100%
  PatternKit.Examples.PointOfSale.PurchaseOrder                                   100%
  PatternKit.Examples.PointOfSale.ReceiptLineItem                                 100%
  PatternKit.Examples.PointOfSale.StoreLocation                                   100%
  PatternKit.Examples.Pricing.ApiPricingSource                                    100%
  PatternKit.Examples.Pricing.CharityRoundUpRule                                  100%
  PatternKit.Examples.Pricing.Coupon                                              100%
  PatternKit.Examples.Pricing.DbPricingSource                                     100%
  PatternKit.Examples.Pricing.DefaultSourceRouting                               83.3%
  PatternKit.Examples.Pricing.FilePricingSource                                   100%
  PatternKit.Examples.Pricing.LineItem                                            100%
  PatternKit.Examples.Pricing.Location                                            100%
  PatternKit.Examples.Pricing.LoyaltyMembership                                   100%
  PatternKit.Examples.Pricing.NickelCashOnlyRule                                  100%
  PatternKit.Examples.Pricing.PercentLoyaltyRule                                  100%
  PatternKit.Examples.Pricing.PricingContext                                      100%
  PatternKit.Examples.Pricing.PricingDemo                                        56.7%
  PatternKit.Examples.Pricing.PricingPipeline                                     100%
  PatternKit.Examples.Pricing.PricingPipelineBuilder                              100%
  PatternKit.Examples.Pricing.PricingResult                                       100%
  PatternKit.Examples.Pricing.RegionCategoryTaxPolicy                             100%
  PatternKit.Examples.Pricing.Sku                                                85.7%
  PatternKit.Examples.Pricing.SourceRouter                                       92.3%
  PatternKit.Examples.Singleton.DeviceRegistry                                    100%
  PatternKit.Examples.Singleton.PosAppState                                       100%
  PatternKit.Examples.Singleton.PosAppStateDemo                                   100%
  PatternKit.Examples.Singleton.PricingCache                                      100%
  PatternKit.Examples.Singleton.StoreConfig                                       100%
  PatternKit.Examples.Strategies.Coercion.Coercer<T>                             83.3%
  PatternKit.Examples.Strategies.Coercion.CoercerExtensions                       100%
  PatternKit.Examples.Strategies.Composed.ChannelPolicy                           100%
  PatternKit.Examples.Strategies.Composed.ChannelPolicyFactory                    100%
  PatternKit.Examples.Strategies.Composed.ComposedStrategies                     94.2%
  PatternKit.Examples.Strategies.Composed.SendContext                             100%
  PatternKit.Examples.Strategies.Composed.SendResult                              100%

PatternKit.Generators                                                            88.2%
  PatternKit.Generators.GenerateStrategyAttribute                                   0%
  PatternKit.Generators.StrategyGenerator                                        93.9%

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Oct 7, 2025

Codecov Report

❌ Patch coverage is 54.74576% with 267 lines in your changes missing coverage. Please review.
✅ Project coverage is 83.27%. Comparing base (6881aad) to head (95f5522).
⚠️ Report is 88 commits behind head on main.

Files with missing lines Patch % Lines
src/PatternKit.Examples/PointOfSale/Demo.cs 4.51% 254 Missing ⚠️
...rnKit.Examples/PointOfSale/PaymentProcessorDemo.cs 94.89% 12 Missing ⚠️
.../PatternKit.Core/Structural/Decorator/Decorator.cs 97.67% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #49      +/-   ##
==========================================
+ Coverage   81.96%   83.27%   +1.30%     
==========================================
  Files          42       46       +4     
  Lines        2662     3252     +590     
  Branches      446      497      +51     
==========================================
+ Hits         2182     2708     +526     
- Misses        322      544     +222     
+ Partials      158        0     -158     
Flag Coverage Δ
unittests 83.27% <54.74%> (+1.30%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JerrettDavis JerrettDavis merged commit 799d863 into main Oct 7, 2025
4 checks passed
@JerrettDavis JerrettDavis deleted the feature/19-fluent-implement-decorator-pattern branch October 7, 2025 03:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fluent: Implement Decorator Pattern

3 participants