-
-
Notifications
You must be signed in to change notification settings - Fork 846
AutoActivate()
should not hide a component's default service
#1451
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
AutoActivate()
should not hide a component's default service
#1451
Conversation
…on the target component's first service being unique to that component
@@ -43,12 +43,15 @@ public IEnumerable<Service> Services | |||
{ | |||
get | |||
{ | |||
if (_defaultServiceOverridden) | |||
if (!_defaultServiceOverridden && !_services.Contains(_defaultService)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the declared type of _services
above so that it's clear this is not an O(N)
operation.
AutoActivate()
should not hide a component's default service
Not sure why AppVeyor is reporting this as non-mergeable; is that just a policy-driven thing, or is there some kind of conflict lurking? (Hoping I targeted the right branch?) |
// https://github.com/autofac/Autofac/issues/1102 | ||
// Single instance registrations with any custom activation phases (i.e. activation handlers) need to be auto-activated, | ||
// so that other behavior (such as OnRelease) that expects 'normal' object lifetime behavior works as expected. | ||
rb.RegistrationData.AddService(new AutoActivateService()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This simplification wasn't possible prior to the other fix, as it would have broken default service logic.
// so that other behavior (such as OnRelease) that expects 'normal' object lifetime behavior works as expected. | ||
if (rb.ResolvePipeline.Middleware.Any(s => s.Phase == PipelinePhase.Activation)) | ||
{ | ||
var autoStartService = rb.RegistrationData.Services.First(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The bug here is due to the possibility that there are multiple registrations for this service; resolving it won't guarantee that we end up with the same component (and in fact, some unrelated random thing could end up unexpectedly activated :-))
I'm not sure why it's saying that, but I'm on holiday until next week so I won't be able to figure it out until then. It... should just build. 🤷♂️ |
I've poked around on this trying to figure out why AppVeyor won't merge this properly and I've not found anything helpful. I'll just test it locally and call it good. I think the changes are fine. I want to move to GitHub Actions anyway, so it's not worth fighting too hard with the AppVeyor issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I verified the changes on my local machine rather than fighting AppVeyor. It all builds and tests out correctly. I'll see if I can get this merged and get a 0.0.1 release out the door shortly.
Great - thanks! 👍 |
Fixes #1450.