Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues with caching in the wrong slot #52168

Merged
merged 2 commits into from
May 3, 2021
Merged

Conversation

davidfowl
Copy link
Member

@davidfowl davidfowl commented May 2, 2021

  • When using ValidateOnBuild we build the callsite for each ServiceDescriptor but using the wrong slot. This didn't matter before but it breaks service overrides.
  • Run the spec tests with ValidateOnBuild set to true when it doesn't throw.
var services = new ServiceCollection();

services.AddTransient<IFoo, Foo1>();
services.AddTransient<IFoo, Foo2>();

var sp = services.BuildServiceProvider(new ServiceProviderOptions
{
    ValidateOnBuild = true
});

Console.WriteLine(sp.GetRequiredService<IFoo>());

interface IFoo { }
class Foo1 : IFoo { }
class Foo2 : IFoo { }

This should print Foo2, it was printing Foo1 when ValidateOnBuild was true.

Currently blocking dotnet/aspnetcore#32315

- When using ValidateOnBuild we build the callsite for each ServiceDescriptor but using the wrong slot. This didn't matter before but it breaks service overrides.
- Run the spec tests with ValidateOnBuild set to true when it doesn't throw.
@ghost
Copy link

ghost commented May 2, 2021

Tagging subscribers to this area: @eerhardt, @maryamariyan
See info in area-owners.md if you want to be subscribed.

Issue Details
  • When using ValidateOnBuild we build the callsite for each ServiceDescriptor but using the wrong slot. This didn't matter before but it breaks service overrides.
  • Run the spec tests with ValidateOnBuild set to true when it doesn't throw.

Currently blocking dotnet/aspnetcore#32315

Author: davidfowl
Assignees: -
Labels:

area-Extensions-DependencyInjection

Milestone: -

- Those are the ones that ValidateOnBuild throws
@eerhardt eerhardt merged commit bb2d2c4 into main May 3, 2021
@eerhardt eerhardt deleted the davidfowl/fix-issues branch May 3, 2021 14:54
@karelz karelz added this to the 6.0.0 milestone May 20, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Jun 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants