protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { await base.InitializeAsync(cancellationToken, progress).ConfigureAwait(true); await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); 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()) { RegisterEditorFactory(editorFactory); } RegisterLanguageService(typeof(TLanguageService), async ct => { await JoinableTaskFactory.SwitchToMainThreadAsync(ct); // Create the language service, tell it to set itself up, then store it in a field // so we can notify it that it's time to clean up. _languageService = CreateLanguageService(); _languageService.Setup(); return(_languageService.ComAggregate); }); // Okay, this is also a bit strange. We need to get our Interop dll into our process, // but we're in the GAC. Ask the base Roslyn Package to load, and it will take care of // it for us. // * NOTE * workspace should never be created before loading roslyn package since roslyn package // installs a service roslyn visual studio workspace requires shell.LoadPackage(Guids.RoslynPackageId, out var setupPackage); _miscellaneousFilesWorkspace = this.ComponentModel.GetService <MiscellaneousFilesWorkspace>(); if (_miscellaneousFilesWorkspace != null) { // make sure solution crawler start once everything has been setup. _miscellaneousFilesWorkspace.StartSolutionCrawler(); } RegisterMiscellaneousFilesWorkspaceInformation(_miscellaneousFilesWorkspace); this.Workspace = this.CreateWorkspace(); if (await IsInIdeModeAsync(this.Workspace, cancellationToken).ConfigureAwait(true)) { // make sure solution crawler start once everything has been setup. // this also should be started before any of workspace events start firing this.Workspace.StartSolutionCrawler(); // start remote host EnableRemoteHostClientService(); } LoadComponentsInUIContextOnceSolutionFullyLoadedAsync(cancellationToken).Forget(); }
protected override void Initialize() { base.Initialize(); foreach (var editorFactory in CreateEditorFactories()) { RegisterEditorFactory(editorFactory); } RegisterLanguageService(typeof(TLanguageService), () => { // Create the language service, tell it to set itself up, then store it in a field // so we can notify it that it's time to clean up. _languageService = CreateLanguageService(); _languageService.Setup(); return(_languageService.ComAggregate); }); var shell = (IVsShell)this.GetService(typeof(SVsShell)); // Okay, this is also a bit strange. We need to get our Interop dll into our process, // but we're in the GAC. Ask the base Roslyn Package to load, and it will take care of // it for us. // * NOTE * workspace should never be created before loading roslyn package since roslyn package // installs a service roslyn visual studio workspace requires shell.LoadPackage(Guids.RoslynPackageId, out var setupPackage); _miscellaneousFilesWorkspace = this.ComponentModel.GetService <MiscellaneousFilesWorkspace>(); if (_miscellaneousFilesWorkspace != null) { // make sure solution crawler start once everything has been setup. _miscellaneousFilesWorkspace.StartSolutionCrawler(); } RegisterMiscellaneousFilesWorkspaceInformation(_miscellaneousFilesWorkspace); this.Workspace = this.CreateWorkspace(); if (IsInIdeMode(this.Workspace)) { // make sure solution crawler start once everything has been setup. // this also should be started before any of workspace events start firing this.Workspace.StartSolutionCrawler(); // start remote host EnableRemoteHostClientService(); Workspace.AdviseSolutionEvents((IVsSolution)GetService(typeof(SVsSolution))); } // Ensure services that must be created on the UI thread have been. HACK_AbstractCreateServicesOnUiThread.CreateServicesOnUIThread(ComponentModel, RoslynLanguageName); LoadComponentsInUIContextOnceSolutionFullyLoaded(); }
protected override void Initialize() { base.Initialize(); // Assume that we are being initialized on the UI thread at this point. var defaultForegroundThreadData = ForegroundThreadData.CreateDefault(defaultKind: ForcedByPackageInitialize); ForegroundThreadAffinitizedObject.CurrentForegroundThreadData = defaultForegroundThreadData; _foregroundObject = new ForegroundThreadAffinitizedObject(defaultForegroundThreadData); foreach (var editorFactory in CreateEditorFactories()) { RegisterEditorFactory(editorFactory); } RegisterLanguageService(typeof(TLanguageService), () => { // Create the language service, tell it to set itself up, then store it in a field // so we can notify it that it's time to clean up. _languageService = CreateLanguageService(); _languageService.Setup(); return(_languageService.ComAggregate); }); // Okay, this is also a bit strange. We need to get our Interop dll into our process, // but we're in the GAC. Ask the base Roslyn Package to load, and it will take care of // it for us. // * NOTE * workspace should never be created before loading roslyn package since roslyn package // installs a service roslyn visual studio workspace requires IVsPackage setupPackage; var shell = (IVsShell)this.GetService(typeof(SVsShell)); shell.LoadPackage(Guids.RoslynPackageId, out setupPackage); _miscellaneousFilesWorkspace = this.ComponentModel.GetService <MiscellaneousFilesWorkspace>(); if (_miscellaneousFilesWorkspace != null) { // make sure solution crawler start once everything has been setup. _miscellaneousFilesWorkspace.StartSolutionCrawler(); } RegisterMiscellaneousFilesWorkspaceInformation(_miscellaneousFilesWorkspace); this.Workspace = this.CreateWorkspace(); if (this.Workspace != null) { // make sure solution crawler start once everything has been setup. // this also should be started before any of workspace events start firing this.Workspace.StartSolutionCrawler(); } // Ensure services that must be created on the UI thread have been. HACK_AbstractCreateServicesOnUiThread.CreateServicesOnUIThread(ComponentModel, RoslynLanguageName); }