protected override void Dispose(bool disposing) { base.Dispose(disposing); AcuminatorLogger?.Dispose(); _outOfProcessSettingsUpdater?.Dispose(); VS.Events.SolutionEvents.OnAfterBackgroundSolutionLoadComplete -= SolutionEvents_OnAfterBackgroundSolutionLoadComplete; if (_vsWorkspace != null) { _vsWorkspace.WorkspaceChanged -= Workspace_WorkspaceChanged; _vsWorkspace = null; } }
protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { // When initialized asynchronously, the current thread may be a background thread at this point. // Do any initialization that requires the UI thread after switching to the UI thread await base.InitializeAsync(cancellationToken, progress); if (Zombied) { return; } await JoinableTaskFactory.SwitchToMainThreadAsync(); var progressData = new ServiceProgressData(VSIXResource.PackageLoad_WaitMessage, VSIXResource.PackageLoad_InitCodeAnalysisSettings, currentStep: 1, TotalLoadSteps); progress?.Report(progressData); _vsWorkspace = await this.GetVSWorkspaceAsync(); await InitializeCodeAnalysisSettingsAsync(); progressData = new ServiceProgressData(VSIXResource.PackageLoad_WaitMessage, VSIXResource.PackageLoad_InitLogger, currentStep: 2, TotalLoadSteps); progress?.Report(progressData); InitializeLogger(); cancellationToken.ThrowIfCancellationRequested(); await InitializeCommandsAsync(); progressData = new ServiceProgressData(VSIXResource.PackageLoad_WaitMessage, VSIXResource.PackageLoad_InitCommands, currentStep: 3, TotalLoadSteps); progress?.Report(progressData); SubscribeOnEvents(); cancellationToken.ThrowIfCancellationRequested(); bool isSolutionOpen = await IsSolutionLoadedAsync(); if (isSolutionOpen) { SetupSuppressionManager(); } progressData = new ServiceProgressData(VSIXResource.PackageLoad_WaitMessage, VSIXResource.PackageLoad_Done, currentStep: 4, TotalLoadSteps); progress?.Report(progressData); }
protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); var componentModel = (IComponentModel)GetGlobalService(typeof(SComponentModel)); workspace = componentModel.GetService <Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace>(); this.dte = (DTE)(await GetServiceAsync(typeof(DTE))); windowEvents = dte.Events.WindowEvents; documentEvents = dte.Events.DocumentEvents; windowEvents.WindowActivated += WindowEvents_WindowActivated; documentEvents.DocumentSaved += DocumentEvents_DocumentSaved; ActiveDocumentChanged(dte.ActiveDocument); }
private void SolutionEvents_OnAfterBackgroundSolutionLoadComplete() { SetupSuppressionManager(); if (_vsWorkspace == null) { JoinableTaskFactory.Run(async() => { await JoinableTaskFactory.SwitchToMainThreadAsync(); _vsWorkspace = await this.GetVSWorkspaceAsync(); SubscribeOnWorkspaceEvents(); InitializeOutOfProcessSettingsSharing(); }); } }
private void InitializeSolutionMonitor() { Microsoft.VisualStudio.ComponentModelHost.IComponentModel componentModel = (Microsoft.VisualStudio.ComponentModelHost.IComponentModel)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(Microsoft.VisualStudio.ComponentModelHost.SComponentModel)); this.workspace = componentModel.GetService<Microsoft.VisualStudio.LanguageServices.VisualStudioWorkspace>(); this.workspace.WorkspaceChanged += Workspace_WorkspaceChanged; this.dte2.Events.WindowEvents.WindowActivated += WindowEvents_WindowActivated; }