///////////////////////////////////////////////////////////////////////////// // Overridden Package Implementation #region Package Members /// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(true); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); 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>()); // Add our command handlers for menu (commands must exist in the .vsct file) if (menuCommandService is OleMenuCommandService mcs) { // Create the command for the tool window CommandID toolwndCommandID = new CommandID(GuidList.guidVisualStudioDiagnosticsWindowCmdSet, (int)PkgCmdIDList.CmdIDRoslynDiagnosticWindow); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand(menuToolWin); } }
///////////////////////////////////////////////////////////////////////////// // Overridden Package Implementation #region Package Members /// <summary> /// Initialization of the package; this method is called right after the package is sited, so this is the place /// where you can put all the initialization code that rely on services provided by VisualStudio. /// </summary> protected override void Initialize() { base.Initialize(); var componentModel = (IComponentModel)GetService(typeof(SComponentModel)); var workspace = componentModel.GetService <VisualStudioWorkspace>(); _forceLowMemoryMode = new ForceLowMemoryMode(workspace.Services.GetService <IOptionService>()); // Add our command handlers for menu (commands must exist in the .vsct file) if (GetService(typeof(IMenuCommandService)) is OleMenuCommandService mcs) { // Create the command for the tool window CommandID toolwndCommandID = new CommandID(GuidList.guidVisualStudioDiagnosticsWindowCmdSet, (int)PkgCmdIDList.CmdIDRoslynDiagnosticWindow); MenuCommand menuToolWin = new MenuCommand(ShowToolWindow, toolwndCommandID); mcs.AddCommand(menuToolWin); } }