Closed dtkujawski closed 3 years ago
Hi @dtkujawski, while it seems kind of odd it's actually expected behavior but there are work arounds. Let me explain why it doesn't work first.
You can add .ProcessAttributes()
to the end of your fluent call if it's a one off. Or you can add an IActivationStrategyInspector
and do it automatically. I've added a test case here as an example of how to do it.
@ipjohnson, that worked perfectly. Thank you very much!
This is a bit tricky to explain with words, but I think the code makes it easier to see. For reference, take the following interfaces and classes for this example (as simplified as I could boil everything down):
In a scenario where I register Child/IChild in the container and then get an instance of Parent directly, everything is wired up just fine:
But, if I were to also put Parent/IParent in the container and then call Locate the DI would not resolve and the Child property would be null:
Even in the case where I register the class directly (not the IParent interface, but the Parent type) it still fails:
Is this expected behavior?
NOTE: If I add a constructor-based DI to the Parent class, everything works fine.