Replace service registration in ASP.NET Core built-in DI container? : <p>Let us consider a service registration in <code>Startup.ConfigureServices</code>:</p>

<pre><code>public void ConfigureServices(IServiceCollection services)
{
    services.AddTransient&lt;IFoo, FooA&gt;();
}
</code></pre>

<p>Is it possible to change <code>IFoo</code> registration to <code>FooB</code> after <code>AddTransient</code> has been called? It can be helpful for testing purposes (for example, in <code>TestStartup</code> subclass) or if our access to codebase is limited.</p>

<p>If we register another <code>IFoo</code> implementation:</p>

<pre><code>services.AddTransient&lt;IFoo, FooA&gt;();
services.AddTransient&lt;IFoo, FooB&gt;();
</code></pre>

<p>Then <code>GetService&lt;IFoo&gt;</code> returns <code>FooB</code> instead of <code>FooA</code>:</p>

<pre><code>IFoo service = services.BuildServiceProvider().GetService&lt;IFoo&gt;();
Assert.True(service is FooB);
</code></pre>

<p>However, <code>GetServices&lt;IFoo&gt;</code> successfully returns both implementations (and the same for <code>GetService&lt;IEnumerable&lt;IFoo&gt;&gt;</code>):</p>

<pre><code>var list = services.BuildServiceProvider().GetServices&lt;IFoo&gt;().ToList();
Assert.Equal(2, list.Count);
</code></pre>

<p>There is <code>Remove(ServiceDescriptor)</code> method in <code>IServiceCollection</code> contract. What should I do with <code>ServiceDescriptor</code> to modify a service registration?</p>
