fix: isolate POS DI singleton from demo counters#205
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Test Results 1 files 1 suites 1m 23s ⏱️ Results for commit e24fc6b. |
🔍 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. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #205 +/- ##
==========================================
+ Coverage 91.78% 96.59% +4.81%
==========================================
Files 253 254 +1
Lines 23251 23498 +247
Branches 3265 3269 +4
==========================================
+ Hits 21341 22698 +1357
+ Misses 847 800 -47
+ Partials 1063 0 -1063
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 |
There was a problem hiding this comment.
Pull request overview
This PR updates the PatternKit Examples DI registration for the POS App State singleton to avoid reusing PosAppStateDemo.BuildLazy(), which mutates the demo’s static FactoryCalls counter and can race under parallel test execution.
Changes:
- Replace DI registration that called
PosAppStateDemo.BuildLazy()with a localSingleton<PosAppState>builder that doesn’t touch demo counters. - Keep the same init steps (pricing prewarm + device connect) within the DI example registration.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| services.AddSingleton(_ => Singleton<PosAppState> | ||
| .Create(static () => new PosAppState | ||
| { | ||
| Config = StoreConfig.Load(), | ||
| Pricing = new PricingCache(), | ||
| Devices = new DeviceRegistry() | ||
| }) | ||
| .Init(static state => state.Pricing.Prewarm(["SKU-1", "SKU-2", "SKU-3"])) | ||
| .Init(static state => state.Devices.ConnectAll()) | ||
| .Build()); |
| services.AddSingleton(_ => Singleton<PosAppState> | ||
| .Create(static () => new PosAppState | ||
| { |
The example DI registration for POS app state previously reused PosAppStateDemo.BuildLazy(), which mutates the demo's static FactoryCalls counter. In main release CI, that can race with the POS singleton TinyBDD scenario under parallel test execution. This change keeps the DI example production-style and counter-free by registering an equivalent local singleton factory and init hooks.