提交 2e14de43 编写于 作者: S Sam Harwell

Rename GetService to avoid confusion

上级 0535a472
......@@ -114,7 +114,7 @@ private void InitializeCore()
return;
}
var vsShell = _serviceProvider.GetService<IVsShell, SVsShell>();
var vsShell = _serviceProvider.GetServiceTheWrongWay<IVsShell, SVsShell>();
var hr = vsShell.IsPackageInstalled(ReSharperPackageGuid, out var extensionEnabled);
if (ErrorHandler.Failed(hr))
{
......@@ -127,7 +127,7 @@ private void InitializeCore()
if (_resharperExtensionInstalledAndEnabled)
{
// We need to monitor for suspend/resume commands, so create and install the command target and the modal callback.
var priorityCommandTargetRegistrar = _serviceProvider.GetService<IVsRegisterPriorityCommandTarget, SVsRegisterPriorityCommandTarget>();
var priorityCommandTargetRegistrar = _serviceProvider.GetServiceTheWrongWay<IVsRegisterPriorityCommandTarget, SVsRegisterPriorityCommandTarget>();
hr = priorityCommandTargetRegistrar.RegisterPriorityCommandTarget(
dwReserved: 0 /* from docs must be 0 */,
pCmdTrgt: this,
......@@ -335,7 +335,7 @@ async Task EnsureOleCommandTargetAsync()
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
_oleCommandTarget = _serviceProvider.GetService<IOleCommandTarget, SUIHostCommandDispatcher>();
_oleCommandTarget = _serviceProvider.GetServiceTheWrongWay<IOleCommandTarget, SUIHostCommandDispatcher>();
}
}
......@@ -345,7 +345,7 @@ private void RestoreVsKeybindings()
if (_uiShell == null)
{
_uiShell = _serviceProvider.GetService<IVsUIShell, SVsUIShell>();
_uiShell = _serviceProvider.GetServiceTheWrongWay<IVsUIShell, SVsUIShell>();
}
ErrorHandler.ThrowOnFailure(_uiShell.PostExecCommand(
......@@ -432,7 +432,7 @@ private async Task ShutdownAsync()
if (_priorityCommandTargetCookie != VSConstants.VSCOOKIE_NIL)
{
var priorityCommandTargetRegistrar = _serviceProvider.GetService<IVsRegisterPriorityCommandTarget, SVsRegisterPriorityCommandTarget>();
var priorityCommandTargetRegistrar = _serviceProvider.GetServiceTheWrongWay<IVsRegisterPriorityCommandTarget, SVsRegisterPriorityCommandTarget>();
var cookie = _priorityCommandTargetCookie;
_priorityCommandTargetCookie = VSConstants.VSCOOKIE_NIL;
var hr = priorityCommandTargetRegistrar.UnregisterPriorityCommandTarget(cookie);
......
......@@ -1033,7 +1033,7 @@ private bool TryGetFrame(CodeAnalysis.TextDocument document, [NotNullWhen(return
// document using its ItemId. Thus, we must use OpenDocumentViaProject, which only
// depends on the file path.
var openDocumentService = ServiceProvider.GlobalProvider.GetService<IVsUIShellOpenDocument, SVsUIShellOpenDocument>();
var openDocumentService = ServiceProvider.GlobalProvider.GetServiceTheWrongWay<IVsUIShellOpenDocument, SVsUIShellOpenDocument>();
return ErrorHandler.Succeeded(openDocumentService.OpenDocumentViaProject(
document.FilePath,
VSConstants.LOGVIEWID.TextView_guid,
......@@ -1072,7 +1072,7 @@ public void CloseDocumentCore(DocumentId documentId)
var filePath = this.GetFilePath(documentId);
if (filePath != null)
{
var openDocumentService = ServiceProvider.GlobalProvider.GetService<IVsUIShellOpenDocument, SVsUIShellOpenDocument>();
var openDocumentService = ServiceProvider.GlobalProvider.GetServiceTheWrongWay<IVsUIShellOpenDocument, SVsUIShellOpenDocument>();
if (ErrorHandler.Succeeded(openDocumentService.IsDocumentOpen(null, 0, filePath, Guid.Empty, 0, out var uiHierarchy, null, out var frame, out var isOpen)))
{
// TODO: do we need save argument for CloseDocument?
......
......@@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Diagnostics;
namespace Microsoft.VisualStudio.LanguageServices.Utilities
{
......@@ -11,7 +12,7 @@ internal static class IServiceProviderExtensions
/// <summary>
/// Returns the specified interface from the service. This is useful when the service and interface differ
/// </summary>
public static TInterfaceType GetService<TInterfaceType, TServiceType>(this IServiceProvider sp)
public static TInterfaceType GetServiceTheWrongWay<TInterfaceType, TServiceType>(this IServiceProvider sp)
where TInterfaceType : class
where TServiceType : class
{
......@@ -22,6 +23,6 @@ internal static class IServiceProviderExtensions
/// Returns the specified service type from the service.
/// </summary>
public static TServiceType GetService<TServiceType>(this IServiceProvider sp) where TServiceType : class
=> sp.GetService<TServiceType, TServiceType>();
=> sp.GetServiceTheWrongWay<TServiceType, TServiceType>();
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册