Open nesteruk opened 12 years ago
I really like this idea. In fact, I want to believe that Agent Mulder could become the "missing link" in the tooling to work with IoC better - analysis for component registration, quickfixes for registration issues and indeed - the "refactor to container", as you propose. I'll put this in the milestone Mirabile Futurum, because it is where it currently belongs :)
BTW, I just remembered something: the container itself is injectable. This could cause certain complications because different components could inject, say, IUnityContainer
and then add extra registrations on top or, for example, explicitly Resolve()
on it.
This isn't a recommended use pattern, however, so perhaps some extra refactorings could be available for this too.
I wonder if somehow ReSharper's value analysis (origin, destination) can be useful for this. I never used this feature myself...
I think the whole point of IoC support is to do this and, furthermore, to do this en masse. What I mean is that instead of
new Foo()
you could give options to refactor it to eithercontainer.Resolve<Foo>()
or -- and this is tricky -- to haveFoo
injected into the containing class.Having a refactoring, you could easily do a Code Cleanup module that could perform this change on the whole solution. The net result would be epic: anyone who's just starting with IoC can refactor their whole codebase to use IoC in just one click.
That's my dream IoC feature, anyway.