title: Autofac generic decorator is duplicating components
body: <p>I have found what I think may be a bug in Autofac, but I wanted to see if anybody had a possible solution or workaround so I can make this work.</p>
  
  <p>Basically I have set up a generic decorator, which works fine. The problem is that as soon as I call <code>BeginLifetimeScope()</code> with a configuration delegate, it erroneously resolves multiple components of the same type. If I don't use a configuration delegate with <code>BeginLifetimeScope()</code>, then it works correctly. Unfortunately, I need to add additional dependencies to my child scope, so not using a configuration delegate is not an option.</p>
  
  <p>Here is an example that demostrates the problem:</p>
  
  <pre><code>var builder = new ContainerBuilder();
  builder.RegisterType&lt;Dependency&gt;()
      .Named&lt;IDependency&lt;object&gt;&gt;("service");
  builder.RegisterGenericDecorator(
      typeof(Decorator&lt;&gt;), typeof(IDependency&lt;&gt;), "service", "decorated");
  var container = builder.Build();
  
  // Returns 1
  var scope1 = container.BeginLifetimeScope();
  Console.WriteLine(
      scope1.ResolveNamed&lt;IEnumerable&lt;IDependency&lt;object&gt;&gt;&gt;("decorated").Count());
  
  // Returns 2 - notice the configAction doesn't even have to do anything
  var scope2 = container.BeginLifetimeScope(r =&gt; { });
  Console.WriteLine(
      scope2.ResolveNamed&lt;IEnumerable&lt;IDependency&lt;object&gt;&gt;&gt;("decorated").Count());
  </code></pre>
  
  <p>And here are my fake types:</p>
  
  <pre><code>interface IDependency&lt;T&gt; { }
  
  class Dependency : IDependency&lt;object&gt; { }
  
  class Decorator&lt;T&gt; : IDependency&lt;T&gt; {}
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>