Add regression tests for enumerable resolution with mixed open/closed generics#124326
Add regression tests for enumerable resolution with mixed open/closed generics#124326
Conversation
…gistrations Co-authored-by: rosebyte <14963300+rosebyte@users.noreply.github.com>
Co-authored-by: rosebyte <14963300+rosebyte@users.noreply.github.com>
|
@copilot please invoke the code-review skill and post the analysis/results as a comment on this PR |
🤖 Copilot Code Review — PR (commits faff47a, e30f09c)Holistic AssessmentMotivation: The PR claims to address a reported issue where Approach: Adding regression tests is valuable, but the PR lacks investigation into whether there's an actual bug. The tests verify current behavior but don't demonstrate that a problem was fixed or validate that the behavior is correct by design. Summary: Detailed Findings
|
Description
Reported issue claimed
GetServices<T>()inconsistently resolves services when mixing closed generic registrations (IService<int> -> Impl) with open generic registrations (IService<> -> GenericImpl<>), particularly whenGetService<T>()is called first.Tests confirm the behavior works correctly. Added regression coverage for this scenario.
Changes
ServiceProviderContainerTests:EnumerableResolutionIncludesOpenGenericRegisteredAfterClosedGeneric- validatesGetServicefollowed byGetServicesreturns both registrationsEnumerableResolutionWithoutSingleServiceCallIncludesOpenGeneric- validates directGetServicescall returns both registrationsExample scenario now covered:
All 1372 DI tests pass. No code changes required - existing implementation handles this correctly.
Original prompt
This section details on the original issue you should resolve
<issue_title>Enumerable dependencies resolving not consistent when open generic is used (area-Extensions-DependencyInjection)</issue_title>
<issue_description>
Description
Enumerable dependencies are not resolved consistently when open generic services are registered later.
Ex:
Setup
Registration
Resolving
To Reproduce
sample repo to reproduce the bug https://github.com/skclusive/EnumerableCallSiteBugConsole
Configuration
.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.7.21379.14
Commit: 22d70b47bc
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22000
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.7.21379.14\
Host (useful for support):
Version: 6.0.0-preview.7.21377.19
Commit: 91ba017
.NET SDKs installed:
5.0.301 [C:\Program Files\dotnet\sdk]
5.0.400 [C:\Program Files\dotnet\sdk]
6.0.100-preview.7.21379.14 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-preview.7.21378.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-preview.7.21377.19 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.18 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-preview.7.21378.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Regression?
Other information
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.