This PR changes the maxResolutionDepth property from a hardcoded fileprivate constant to a configurable stored property within the Container class.
Motivation
In the current implementation, the recursion limit for dependency resolution is fixed at 200. While this is sufficient for most use cases, complex dependency graphs in enterprise-scale architectures or machine-generated code can exceed this limit. When reached, the container triggers a fatalError that developers currently cannot circumvent without modifying the framework source. Making this limit configurable provides the necessary flexibility for large-scale applications while maintaining a safe default.
Changes
Converted maxResolutionDepth from a computed property in a Container extension to a stored property in the main Container class.
Updated internal and convenience initializers to accept maxResolutionDepth as an optional parameter with a default value of 200.
Updated documentation headers to reflect the new parameter.
Fixed a typo in the resetObjectScope documentation example.
Testing
Added testContainerUsesCustomMaxResolutionDepth to verify that custom limits are correctly assigned and respected.
Added testContainerDefaultsToStandardMaxResolutionDepth to ensure backward compatibility and verify the default limit remains 200.
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
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.
This PR changes the maxResolutionDepth property from a hardcoded fileprivate constant to a configurable stored property within the Container class.
Motivation
In the current implementation, the recursion limit for dependency resolution is fixed at 200. While this is sufficient for most use cases, complex dependency graphs in enterprise-scale architectures or machine-generated code can exceed this limit. When reached, the container triggers a fatalError that developers currently cannot circumvent without modifying the framework source. Making this limit configurable provides the necessary flexibility for large-scale applications while maintaining a safe default.
Changes
Testing