autofac/Autofac — pull request #542 by alexandrnikitin (2014-06-30 10:09:33+00:00)
Title: Fix for #475 (Parent lifetime scopes not properly propagating registrations to child scopes)

Hi all,

The #475 is quite complicated and tricky bug and I need your help here :sweat:.
I'll do my best to explain what and why it happened.

Basically the buggy flow (see unit test) is the following:
1. For each new nested lifetimescope we add new ```ExternalRegistrySource``` to registration sources.
2. When we resolve a service we iterate through all ```ExternalRegistrySource```s from most nested to parent. If we find registrations for the service we return them.
3. Plus we return all registrations for the services from the found registrations **from current ```ExternalRegistrySource```**. It was made within #282
3. When we resolve ```IServiceA``` from ```scope3``` in the unit test,
- we didn't find a registration in ```scope3```
- we found a registration in ```scope2``` (as it was resolved there)
- we try to find registrations for ```IServiceCommon``` (service of the found registration), no such regs in current scope, moving to its parent
- we found them in the root lifetimescope, and create new registrations for them, which includes ```ServiceB1``` for ```IServiceB```, which would be the default one in ```scope3``` as we preserve defaults in registration sources.

The new flow creates registrations only for the requested service.