diff --git a/src/GitHub.VisualStudio.16/CompositionServices.cs b/src/GitHub.VisualStudio.16/CompositionServices.cs index 44cec8b4e..168be3958 100644 --- a/src/GitHub.VisualStudio.16/CompositionServices.cs +++ b/src/GitHub.VisualStudio.16/CompositionServices.cs @@ -85,23 +85,14 @@ namespace GitHub.VisualStudio var gitHubServiceProvider = new MyGitHubServiceProvider(compositionContainer); compositionContainer.ComposeExportedValue(gitHubServiceProvider); + Services.UnitTestServiceProvider = gitHubServiceProvider; // Use gitHubServiceProvider as global provider var loginManager = CreateLoginManager(compositionContainer); compositionContainer.ComposeExportedValue(loginManager); - // HACK: Stop ViewLocator from attempting to fetch a global service - var viewViewModelFactory = compositionContainer.GetExportedValue(); - InitializeViewLocator(viewViewModelFactory); - return compositionContainer; } - static void InitializeViewLocator(IViewViewModelFactory viewViewModelFactory) - { - var factoryProviderFiled = typeof(ViewLocator).GetField("factoryProvider", BindingFlags.Static | BindingFlags.NonPublic); - factoryProviderFiled.SetValue(null, viewViewModelFactory); - } - static LoginManager CreateLoginManager(CompositionContainer compositionContainer) { var keychain = compositionContainer.GetExportedValue(); @@ -192,6 +183,11 @@ namespace GitHub.VisualStudio public object GetService(Type serviceType) { + if (serviceType == typeof(IGitHubServiceProvider)) + { + return this; + } + return serviceProvider.GetService(serviceType); }