Skip to content

Add DisableAutoDispose() to opt out of automatic IDisposable handling#146

Open
svermeulen wants to merge 1 commit into
gustavopsantos:mainfrom
svermeulen:disable-dispose-handling
Open

Add DisableAutoDispose() to opt out of automatic IDisposable handling#146
svermeulen wants to merge 1 commit into
gustavopsantos:mainfrom
svermeulen:disable-dispose-handling

Conversation

@svermeulen
Copy link
Copy Markdown

Description

Adds an opt-in ContainerBuilder.DisableAutoDispose() builder method. When set, the resulting container will not register resolved instances or registered values for automatic disposal.

Reflex's automatic IDisposable handling uses a fixed reverse-construction order (LIFO over a single stack). For projects that want to drive their own ordered shutdown sequence based on other criteria (eg. dependency-aware ordering, explicit attributes, etc.) the auto-dispose pass becomes a problem. Also, some projects need Dispose to happen earlier than it does for Container (eg. before scene unloads, since some dispose logic needs valid access to objects in unity scene.)

For these reasons this setting is extremely useful

Type of change

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

How Has This Been Tested?

Ran via Unity Test Runner. All tests passed (though GarbageCollectionTests were skipped since it was run in debug)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings
  • I have checked that Reflex.GettingStarted still runs nicely

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