[release/6.0-preview6] Fix the slot calculation for multiple services #54503
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.
Backport of #54462 to release/6.0-preview6
/cc @davidfowl
Customer Impact
By default customers using DI in .NET 5 could be broken in very bad ways if any dependency in their application (including library dependencies) inject an
IEnumerable<T>
with more than 5 services into their constructor. They'll end up with the wrong set of dependencies. We've already had 2 customers report this on the new .NET 5 preview. This happens in development mode only by default since that's when the service validation feature is on.This is a regression in preview5.
Testing
Added explicit tests for this scenario up to 6 services (from 1 to 6). Also added tests that verify the slot calculation (which is an internal detail that caused this to break).
Risk
Low/None.