提交 e185f963 编写于 作者: S Sam Harwell

Check for null after GetServiceAsync

上级 20cb7aee
......@@ -6,6 +6,7 @@
using System.Reflection;
using System.Threading;
using EnvDTE;
using Microsoft;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Task = System.Threading.Tasks.Task;
......@@ -26,6 +27,7 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
var reg = (ILocalRegistry2)await GetServiceAsync(typeof(SLocalRegistry)).ConfigureAwait(true);
cancellationToken.ThrowIfCancellationRequested();
Assumes.Present(reg);
var packagePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
......
......@@ -46,6 +46,8 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
var shell = (IVsShell)await GetServiceAsync(typeof(SVsShell)).ConfigureAwait(true);
var solution = (IVsSolution)await GetServiceAsync(typeof(SVsSolution)).ConfigureAwait(true);
cancellationToken.ThrowIfCancellationRequested();
Assumes.Present(shell);
Assumes.Present(solution);
foreach (var editorFactory in CreateEditorFactories())
{
......
......@@ -48,6 +48,7 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
var componentModel = (IComponentModel)await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(true);
cancellationToken.ThrowIfCancellationRequested();
Assumes.Present(componentModel);
FatalError.Handler = FailFast.OnFatalException;
FatalError.NonFatalHandler = WatsonReporter.Report;
......
......@@ -38,6 +38,9 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
_componentModel = (IComponentModel)await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(true);
var menuCommandService = (OleMenuCommandService)await GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(true);
cancellationToken.ThrowIfCancellationRequested();
Assumes.Present(shell);
Assumes.Present(_componentModel);
Assumes.Present(menuCommandService);
// Load the Roslyn package so that its FatalError handlers are hooked up.
shell.LoadPackage(Guids.RoslynPackageId, out var roslynPackage);
......
......@@ -5,6 +5,7 @@
using System.ComponentModel.Design;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft;
using Microsoft.CodeAnalysis.Options;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.LanguageServices;
......@@ -85,6 +86,9 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
var componentModel = (IComponentModel)await GetServiceAsync(typeof(SComponentModel)).ConfigureAwait(true);
var menuCommandService = (IMenuCommandService)await GetServiceAsync(typeof(IMenuCommandService)).ConfigureAwait(true);
cancellationToken.ThrowIfCancellationRequested();
Assumes.Present(componentModel);
Assumes.Present(menuCommandService);
var workspace = componentModel.GetService<VisualStudioWorkspace>();
_forceLowMemoryMode = new ForceLowMemoryMode(workspace.Services.GetService<IOptionService>());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册