Skip to content

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: -

@davidfowl davidfowl requested review from eerhardt and maryamariyan May 2, 2021 08:34
- 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.

6 participants