Move onlyIfAvailable received dependencies into SafeDIParameters (simple)#241
Merged
Conversation
4 tasks
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #241 +/- ##
==========================================
+ Coverage 99.91% 99.98% +0.06%
==========================================
Files 41 41
Lines 5772 5796 +24
==========================================
+ Hits 5767 5795 +28
+ Misses 5 1 -4
🚀 New features to boost your workflow:
|
…arameters @received(onlyIfAvailable: true) dependencies are now plain optional properties on SafeDIParameters (defaulting to nil) instead of top-level mock() parameters. This keeps the mock() signature focused on required dependencies while placing optional availability-gated values alongside the rest of the SafeDI configuration. - ScopeGenerator: split onlyIfAvailable entries out of flatReceivedParameters into onlyIfAvailableSafeDIParameterEntries; generate them as SafeDIParameters stored properties with = nil defaults; bind them as locals before tree bindings - DependencyTreeGenerator: add promotedLabelAndTypes dedup set in createMockRootScopeGenerator to prevent duplicate promotions - Include onlyIfAvailable labels in flat parameter disambiguation to avoid shadowing conflicts between flat params and SafeDIParameters locals - Documentation: add Manual section on onlyIfAvailable properties in mocks - Update all affected test expectations Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f5d1b66 to
77f5884
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@Received(onlyIfAvailable: true)dependencies from child/grandchild scopes no longer leak to the rootmock()signature as top-level optional parametersType? = nil) onSafeDIParametersnil, the dependency is absent; when provided (e.g.,.mock()), the value is used directly@Receivedand anonlyIfAvailable@Receivedexisted for the same label+typeAlternative: See #242 for a tree-threading version that uses
SafeDIMockConfiguration?instead of plain optional values, enabling subtree override through config structs.Test plan
🤖 Generated with Claude Code