FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Make maxResolutionDepth configurable in Container by spencerdearman · Pull Request #591 · Swinject/Swinject · GitHub

Make maxResolutionDepth configurable in Container - #591

Open
spencerdearman wants to merge 1 commit into
Swinject:masterfrom
spencerdearman:master
Open

Make maxResolutionDepth configurable in Container#591
spencerdearman wants to merge 1 commit into
Swinject:masterfrom
spencerdearman:master

Conversation

Copy link
Copy Markdown

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL