Open jnm2 opened 4 years ago
Did you want to debug DefaultComponentActivator
to determine why the 2nd constructor is getting a higher score even though it has a non-satisfiable dependency.
I put a breakpoint in every method in DefaultComponentActivator and none was hit except the constructor. Specifically, none of the scoring logic in DefaultComponentActivator is in play for this repro. This is the call stack:
at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency() in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\Handlers\DefaultHandler.cs:line 74
at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\Handlers\DefaultHandler.cs:line 146
at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\Handlers\DefaultHandler.cs:line 97
at Castle.MicroKernel.Handlers.AbstractHandler.Resolve(CreationContext context) in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\Handlers\AbstractHandler.cs:line 181
at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, Arguments additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext) in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\DefaultKernel.cs:line 751
at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, Arguments arguments, IReleasePolicy policy, Boolean ignoreParentContext) in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\DefaultKernel_Resolve.cs:line 185
at Castle.MicroKernel.DefaultKernel.Resolve(Type service, Arguments arguments) in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\MicroKernel\DefaultKernel_Resolve.cs:line 112
at Castle.Windsor.WindsorContainer.Resolve[T]() in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor\Windsor\WindsorContainer.cs:line 596
at CastleTests.Activators.BestConstructorTestCase.Repro() in C:\Users\Joseph\Source\Repos\Windsor\src\Castle.Windsor.Tests\Activators\BestConstructorTestCase.cs:line 245
I'm guessing we have to get CanResolvePendingDependencies to start returning true
before DefaultComponentActivator gets to do anything:
The dependency model for ReproComponent has a missingDependencies
field with both parameters from the second constructor in it.
I'm guessing the determination of which constructor will be used has to happen before the handler begins counting down which dependencies are missing. Do you see any inherent design issues with making that happen?
See the description in the comments: