2
Vote

Exclude CommonServiceLocator library from the MVVM Light dependecies

description

MVVM Light Toolkit has a dependency to CommonServiceLocator library.

But Service locator pattern is considered by many as an anti-pattern:
The main issue, among others, is that it makes the class' dependencies hidden.

I agree that sometimes it is unavoidable, but not in case of MVVM Light Toolkit. I don't think there is any good reason why you should force MVVM Light users to depend on CommonServiceLocator library.

I would suggest to use an approach to which the Autofac developers came to -- create a separate package (called MvvmLightCommonServiceLocatorSupport or MvvmLight.Extras.CommonServiceLocator for example) that will contain an adapter class for SimpleIoc and IServiceLocator. Then users who need CommonServiceLocator library integration will be able to use that package if they need to.

Thanks.

comments