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

Implement service-injection mechanism for patch/point releases #7550

Merged
merged 1 commit into from
Feb 3, 2017

Conversation

ajcvickers
Copy link
Contributor

Issue #7465

This change introduces a new class ServiceCollectionMap that is used by providers and by our service-adding methods. The new class builds a map from service type to indexes of the ServiceDescriptors in the list for the given type. This allows all the TryAdd calls that we make to work without scanning the list every time.

In addition, this type has a method for re-writing services to do property injection when we need to add a service dependency without breaking a constructor in a patch or point release. This is used by making a call at the end of our service registrations like so:

   ...
   .TryAddScoped<IResultOperatorHandler, ResultOperatorHandler>()
   .DoPatchInjection<IValueGeneratorSelector>();

Also, ReplaceService code has been updated to ensure that service-injection is also run on any replaced services, since these services may also inherit from our base classes.

Issue #7465

This change introduces a new class ServiceCollectionMap that is used by providers and by our service-adding methods. The new class builds a map from service type to indexes of the ServiceDescriptors in the list for the given type. This allows all the TryAdd calls that we make to work without scanning the list every time.

In addition, this type has a method for re-writing services to do property injection when we need to add a service dependency without breaking a constructor in a patch or point release. This is used by making a call at the end of our service registrations like so:

```C#
   ...
   .TryAddScoped<IResultOperatorHandler, ResultOperatorHandler>()
   .DoPatchInjection<IValueGeneratorSelector>();
```

Also, ReplaceService code has been updated to ensure that service-injection is also run on any replaced services, since these services may also inherit from our base classes.
@ajcvickers ajcvickers merged commit 4112c26 into dev Feb 3, 2017
@smitpatel smitpatel deleted the RewriteMe0201 branch February 3, 2017 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants