⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

feat(multibindings): Enable spanning injectors for Multibinder, MapBinder, and OptionalBinder#1925

Open
ralstonba wants to merge 1 commit intogoogle:masterfrom
ralstonba:pr/multibindings-cross-injector
Open

feat(multibindings): Enable spanning injectors for Multibinder, MapBinder, and OptionalBinder#1925
ralstonba wants to merge 1 commit intogoogle:masterfrom
ralstonba:pr/multibindings-cross-injector

Conversation

@ralstonba
Copy link

@ralstonba ralstonba commented Jan 24, 2026

This PR introduces a new 'contributor' API for Multibinder, MapBinder, and OptionalBinder, allowing PrivateModules to contribute bindings to an extension point defined in a parent injector.

The inability for PrivateModules to contribute to multibindings has come up multiple times with various workarounds being proposed:

This PR attempts to resolve this by adding a new API to contribute to existing multibindings across public and private modules without creating a new local binding within the PrivateModule

Key Changes:

  • Introduced newSetContributor, newMapContributor, and newOptionalContributor methods.
  • Added permitSpanInjectors() to handle automatic key exposure in PrivateModules.
  • Updated RealMultibinder, RealMapBinder, and RealOptionalBinder to support a non-binding container mode.
  • Added reproduction and verification tests: MultibindingsSpanningInjectorsTest and OptionalBinderSpanningInjectorsTest.

…nder, and OptionalBinder

This commit introduces a new 'contributor' API for Multibinder, MapBinder, and OptionalBinder, allowing PrivateModules to contribute bindings to an extension point defined in a parent injector.

Key Changes:
- Introduced , , and  methods.
- Added  to handle automatic key exposure in PrivateModules.
- Updated , , and  to support a non-binding container mode.
- Fixed  and  to correctly unwrap  instances from private injectors.
- Added reproduction and verification tests:  and .
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