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

fix(simpleinjector): key registrations by contract and stop dropping Register by glennawatson · Pull Request #1670 · reactiveui/splat · GitHub

fix(simpleinjector): key registrations by contract and stop dropping Register - #1670

Merged
ChrisPulman merged 1 commit into
mainfrom
fix/simpleinjector-contracts
Aug 2, 2026
Merged

fix(simpleinjector): key registrations by contract and stop dropping Register#1670
ChrisPulman merged 1 commit into
mainfrom
fix/simpleinjector-contracts

Conversation

Copy link
Copy Markdown
Contributor

What kind of change does this PR introduce?

Bug fix.

What is the new behavior?

  • Contracts are honored across the adapter. A contract registration answers only lookups for the same contract, never shadows the contract-less registration, and two contracts for one service type stay distinct.
  • Register on the resolver takes effect instead of doing nothing, so a registration made after the locator is wired up applies, or reports Simple Injector's own error once the container has been locked by a resolution.

What is the current behavior?

  • Every contract overload discarded its contract and behaved as the contract-less call, so registering two implementations under different contracts silently returned whichever one won. Closes Bug: The simple injector DI container isn't practical #240.
  • The resolver's Register was an empty method, so a registration made after the resolver was wired up vanished with no error.
  • The initializer's non-generic lookups threw when asked for a type that was never registered, rather than reporting no service.

What might this PR break?

  • Register on the resolver now registers. Code that called it expecting nothing to happen will now add a registration, and calling it after the first resolution surfaces the container's locked-container exception rather than being silently ignored.
  • A lookup passing a contract no longer falls back to the contract-less registration, so a caller that relied on that fallback will now get nothing.

Checklist

  • I have read the Contribute guide
  • Tests have been added or updated (for bug fixes / features)
  • Docs have been added or updated (for bug fixes / features)
  • Changes target the main branch
  • PR title follows Conventional Commits

Additional information

Simple Injector has no keyed registrations, so contracts are held in a table beside the container and are deliberately not injectable by the container itself; this is documented in the class remarks and the package readme. The container-locking behaviour the design depends on was verified directly rather than assumed. 412 tests pass across the seven target frameworks.

…Register

- Hold contract registrations in a table beside the container, since Simple
  Injector has no keyed registrations. A contract registration now only answers
  a lookup for the same contract, never shadows the contract-less registration,
  and two contracts for one service type stay distinct.
- Carry the initializer's contract registrations across to the resolver when
  the container is wired up.
- Make the resolver's Register append into the container instead of silently
  doing nothing, so a registration made after the locator is wired up (a logger,
  for instance) takes effect - or fails loudly with Simple Injector's own
  exception once the container has been locked by a resolution.
- Report the collection registrations this resolver made from HasRegistration;
  Simple Injector does not surface them until the container is locked.
- Return null/empty from the initializer's non-generic lookups when a type is
  unregistered instead of throwing.

Fixes #240

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.65%. Comparing base (b1d3f14) to head (809c3ae).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1670      +/-   ##
==========================================
+ Coverage   97.60%   97.65%   +0.05%     
==========================================
  Files         127      128       +1     
  Lines        6757     6911     +154     
  Branches     1025     1071      +46     
==========================================
+ Hits         6595     6749     +154     
  Misses         91       91              
  Partials       71       71              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

ChrisPulman merged commit 9e63cc0 into main Aug 2, 2026
13 checks passed
ChrisPulman deleted the fix/simpleinjector-contracts branch August 2, 2026 10:03

Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions Bot locked as resolved and limited conversation to collaborators Aug 17, 2026
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: The simple injector DI container isn't practical

2 participants


Back | FazBrowse Home | New Git URL