Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 107a8b2

Browse files
committed
Do not export IServiceProvider
Fixes #137
1 parent b2456d8 commit 107a8b2

File tree

7 files changed

+9
-12
lines changed

7 files changed

+9
-12
lines changed

src/GitHub.App/Models/ConnectionRepositoryHostMap.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
using System;
2-
using System.ComponentModel.Composition;
3-
using GitHub.Extensions;
1+
using System.ComponentModel.Composition;
42
using GitHub.Models;
3+
using GitHub.Services;
54

65
namespace GitHub.ViewModels
76
{
@@ -10,7 +9,7 @@ namespace GitHub.ViewModels
109
public class ConnectionRepositoryHostMap : IConnectionRepositoryHostMap
1110
{
1211
[ImportingConstructor]
13-
public ConnectionRepositoryHostMap(IServiceProvider provider, IRepositoryHosts hosts)
12+
public ConnectionRepositoryHostMap(IUIProvider provider, IRepositoryHosts hosts)
1413
: this(provider.GetService<IConnection>(), hosts)
1514
{
1615
}

src/GitHub.App/ViewModels/LoginControlViewModel.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public class LoginControlViewModel : BaseViewModel, ILoginControlViewModel
1414
{
1515
[ImportingConstructor]
1616
public LoginControlViewModel(
17-
IServiceProvider serviceProvider,
1817
IRepositoryHosts hosts,
1918
ILoginToGitHubViewModel loginToGitHubViewModel,
2019
ILoginToGitHubForEnterpriseViewModel loginToGitHubEnterpriseViewModel)

src/GitHub.Exports/Services/IUIProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66

77
namespace GitHub.Services
88
{
9-
public interface IUIProvider
9+
public interface IUIProvider : IServiceProvider
1010
{
1111
ExportProvider ExportProvider { get; }
1212
IServiceProvider GitServiceProvider { get; set; }
13-
object GetService(Type t);
1413
T GetService<T>();
1514
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1004:GenericMethodsShouldProvideTypeParameter")]
1615
Ret GetService<T, Ret>() where Ret : class;

src/GitHub.Exports/Services/VSServices.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public class VSServices : IVSServices
4343
readonly IServiceProvider serviceProvider;
4444

4545
[ImportingConstructor]
46-
public VSServices(IServiceProvider serviceProvider)
46+
public VSServices(IUIProvider serviceProvider)
4747
{
4848
this.serviceProvider = serviceProvider;
4949
}

src/GitHub.UI.Reactive/Validation/ReactiveValidatableObject.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System.Reflection;
1010
using ReactiveUI;
1111
using NullGuard;
12+
using GitHub.Services;
1213

1314
namespace GitHub.Validation
1415
{
@@ -22,7 +23,7 @@ public class ReactiveValidatableObject : ReactiveObject, IDataErrorInfo
2223
readonly Dictionary<string, bool> enabledProperties = new Dictionary<string, bool>();
2324
bool validationEnabled = true;
2425

25-
public ReactiveValidatableObject([AllowNull]IServiceProvider serviceProvider)
26+
public ReactiveValidatableObject([AllowNull]IUIProvider serviceProvider)
2627
{
2728
validatedProperties = typeValidatorsMap.GetOrAdd(GetType(), GetValidatedProperties);
2829
this.serviceProvider = serviceProvider; // This is allowed to be null.

src/GitHub.VisualStudio/Services/UIProvider.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
namespace GitHub.VisualStudio
2323
{
2424
[Export(typeof(IUIProvider))]
25-
[Export(typeof(IServiceProvider))]
2625
[PartCreationPolicy(CreationPolicy.Shared)]
27-
public class UIProvider : IServiceProvider, IUIProvider, IDisposable
26+
public class UIProvider : IUIProvider, IDisposable
2827
{
2928
static readonly Logger log = LogManager.GetCurrentClassLogger();
3029
CompositeDisposable disposables = new CompositeDisposable();

src/UnitTests/GitHub.Exports/VSServicesTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public class TheCloneMethod : TestBaseClass
1313
[InlineData(false, CloneOptions.None)]
1414
public void CallsCloneOnVsProvidedCloneService(bool recurseSubmodules, CloneOptions expectedCloneOptions)
1515
{
16-
var provider = Substitute.For<IServiceProvider>();
16+
var provider = Substitute.For<IUIProvider>();
1717
var gitRepositoriesExt = Substitute.For<IGitRepositoriesExt>();
1818
provider.GetService(typeof(IGitRepositoriesExt)).Returns(gitRepositoriesExt);
1919
var vsServices = new VSServices(provider);

0 commit comments

Comments
 (0)