Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Refactor new statement to container user #16

Open
nesteruk opened this Issue · 3 comments

2 participants

@nesteruk

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 either container.Resolve<Foo>() or -- and this is tricky -- to have Foo 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.

@hmemcpy
Owner

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 :)

@nesteruk

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.

@hmemcpy
Owner

I wonder if somehow ReSharper's value analysis (origin, destination) can be useful for this. I never used this feature myself...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.