Simplify Registration class API by removing the service type #345

Open
dotnetjunkie opened this Issue Dec 13, 2016 · 0 comments

Projects

None yet

1 participant

@dotnetjunkie
Collaborator
dotnetjunkie commented Dec 13, 2016 edited

From the early days on, Simple Injector tried to provide users with a flexible and extendible API. Throughout this process though, flexibility was created that seems to have no appropriate use case, and now has proven to be a limiting factor. These are especially the parts that accept a ServiceType and ImplementationType pair.

Affected API:

  • ILifestyleSelectionBehavior.SelectLifestyle(Type, Type). Supplying the service type to SelectLifestyle assumes that two calls to SelectLifestyle using the same implementation type could return a different lifestyle in case the service type is different, which is really weird and is actually something that we are trying to combat while implementing #219.
  • IConstructorResolutionBehavior.GetConstructor(Type, Type); This assumes that for the same implementation type a different constructor could be selected based on the service type. Such requirement is a clear case of bad application design; such class violates SRP. It's unlikely that there is any user of Simple Injector that is actually relying on this behavior.
  • Lifestyle.CreateRegistration<TService, TImplementation>(Container); The only reason that TService is included here is because of the two previously described calls.
  • Lifestyle.CreateRegistration(Type, Type, Container); same as above.
@dotnetjunkie dotnetjunkie added this to the v4 milestone Dec 13, 2016
@dotnetjunkie dotnetjunkie self-assigned this Dec 17, 2016
@dotnetjunkie dotnetjunkie added a commit that referenced this issue Dec 18, 2016
@dotnetjunkie dotnetjunkie Code and tests fixed.
There were still some bugs in the code that made tests fail, while some
tests where redundant or obsolete. fixes #345
a489772
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment