private async Task <Solution> PublishLatestSolutionAsync(CancellationToken cancellationToken) { // WORKAROUND: We don't yet have a way to wait for the rename changes to propagate // to Roslyn (tracked by https://github.com/dotnet/project-system/issues/3425), so // instead we wait for the IntelliSense stage to finish for the entire solution IVsOperationProgressStatusService operationProgressStatusService = await _operationProgressService.GetValueAsync(cancellationToken); IVsOperationProgressStageStatus stageStatus = operationProgressStatusService.GetStageStatus(CommonOperationProgressStageIds.Intellisense); await stageStatus.WaitForCompletionAsync().WithCancellation(cancellationToken); // The result of that wait, is basically a "new" published Solution, so grab it return(_workspace.CurrentSolution); }
/// <summary> /// Initializes a new instance of the <see cref="OperationProgressToolWindowControl"/> class. /// </summary> public OperationProgressToolWindowControl() { this.vsOperationProgressService = OperationProgressPackage.Instance.VsOperationProgressService; this.vsOperationProgressStatusService = OperationProgressPackage.Instance.VsOperationProgressStatusService; this.joinableTaskFactory = OperationProgressPackage.Instance.JoinableTaskFactory; this.InitializeComponent(); this.intelliSenseStageStatus = vsOperationProgressStatusService.GetStageStatus(CommonOperationProgressStageIds.Intellisense); this.intelliSenseStageStatus.InProgressChanged += IntelliSenseStatus_InProgressChanged; // Update the status textblock with the current value this.UpdateintelliSenseStatusTextBlock(intelliSenseStageStatus.Status); }
/// <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> /// <param name="cancellationToken">A cancellation token to monitor for initialization cancellation, which can occur when VS is shutting down.</param> /// <param name="progress">A provider for progress updates.</param> /// <returns>A task representing the async work of package initialization, or an already completed task if there is none. Do not return null from this method.</returns> protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress <ServiceProgressData> progress) { Instance = this; // 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 this.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); await OperationProgressToolWindowCommand.InitializeAsync(this); this.VsOperationProgressService = await this.GetServiceAsync(typeof(SVsOperationProgress)) as IVsOperationProgress; // Post Visual Studio 2019 Update 2, should use: // this.OperationProgressStatusService = await this.GetServiceAsync(typeof(SVsOperationProgressStatusService)) as IVsOperationProgressStatusService; // Version 16.1: this.VsOperationProgressStatusService = this.VsOperationProgressService as IVsOperationProgressStatusService; }
public DefaultRazorProjectChangePublisher( LSPEditorFeatureDetector lSPEditorFeatureDetector, ProjectConfigurationFilePathStore projectConfigurationFilePathStore, [Import(typeof(SVsServiceProvider))] IServiceProvider serviceProvider, RazorLogger logger) { if (lSPEditorFeatureDetector is null) { throw new ArgumentNullException(nameof(lSPEditorFeatureDetector)); } if (projectConfigurationFilePathStore is null) { throw new ArgumentNullException(nameof(projectConfigurationFilePathStore)); } if (logger is null) { throw new ArgumentNullException(nameof(logger)); } if (serviceProvider is null) { throw new ArgumentNullException(nameof(serviceProvider)); } _deferredPublishTasks = new Dictionary <string, Task>(FilePathComparer.Instance); _pendingProjectPublishes = new Dictionary <string, ProjectSnapshot>(FilePathComparer.Instance); _publishLock = new object(); _lspEditorFeatureDetector = lSPEditorFeatureDetector; _projectConfigurationFilePathStore = projectConfigurationFilePathStore; _logger = logger; _serializer.Converters.Add(TagHelperDescriptorJsonConverter.Instance); _serializer.Converters.Add(RazorConfigurationJsonConverter.Instance); _serializer.Converters.Add(CodeAnalysis.Razor.Workspaces.Serialization.ProjectSnapshotJsonConverter.Instance); if (serviceProvider.GetService(typeof(SVsOperationProgress)) is IVsOperationProgressStatusService service) { _operationProgressStatusService = service; } }