public Task OnProjectFactoryCompletedAsync() { // The project factory is completing. // Subscribe to project data. Ensure the project doesn't unload during subscription. return(_tasksService.LoadedProjectAsync(AddInitialSubscriptionsAsync).Task); Task AddInitialSubscriptionsAsync() { // This host object subscribes to configured project evaluation data for its own purposes. SubscribeToConfiguredProjectEvaluation( _activeConfiguredProjectSubscriptionService, OnActiveConfiguredProjectEvaluatedAsync); // Each of the host's subscribers are initialized. foreach (IDependencyCrossTargetSubscriber subscriber in Subscribers) { subscriber.InitializeSubscriber(this, _activeConfiguredProjectSubscriptionService); } return(Task.CompletedTask); } async Task OnActiveConfiguredProjectEvaluatedAsync(IProjectVersionedValue <IProjectSubscriptionUpdate> e) { if (IsDisposing || IsDisposed) { return; } await EnsureInitializedAsync(); await OnConfiguredProjectEvaluatedAsync(e); } }
protected async Task AddInitialSubscriptionsAsync() { await _tasksService.LoadedProjectAsync(async() => { SubscribeToConfiguredProject(_activeConfiguredProjectSubscriptionService, new ActionBlock <IProjectVersionedValue <IProjectSubscriptionUpdate> >(e => OnProjectChangedAsync(e, RuleHandlerType.Evaluation))); foreach (var subscriber in Subscribers) { await subscriber.Value.InitializeSubscriberAsync(this, _activeConfiguredProjectSubscriptionService) .ConfigureAwait(false); } }); }
protected async Task AddInitialSubscriptionsAsync() { await _tasksService.LoadedProjectAsync(async() => { SubscribeToConfiguredProject(_activeConfiguredProjectSubscriptionService, e => OnProjectChangedAsync(e, RuleHandlerType.Evaluation)); foreach (Lazy <ICrossTargetSubscriber> subscriber in Subscribers) { await subscriber.Value.InitializeSubscriberAsync(this, _activeConfiguredProjectSubscriptionService) .ConfigureAwait(false); } }); }
private async Task OnProjectChangedAsync( IProjectSubscriptionUpdate projectUpdate, IProjectCatalogSnapshot catalogSnapshot, IProjectCapabilitiesSnapshot capabilities, ConfiguredProject configuredProject, RuleHandlerType handlerType) { if (IsDisposing || IsDisposed) { return; } await _tasksService.LoadedProjectAsync(async() => { if (_tasksService.UnloadCancellationToken.IsCancellationRequested) { return; } using (ProjectCapabilitiesContext.CreateIsolatedContext(configuredProject, capabilities)) { await HandleAsync(projectUpdate, catalogSnapshot, handlerType); } }); }
private async Task OnProjectChangedCoreAsync(IProjectVersionedValue <IProjectSubscriptionUpdate> e, RuleHandlerType handlerType) { if (IsDisposing || IsDisposed) { return; } await _tasksService.LoadedProjectAsync(async() => { await HandleAsync(e, handlerType).ConfigureAwait(false); }); // If "TargetFrameworks" property has changed, we need to refresh the project context and subscriptions. if (HasTargetFrameworksChanged(e)) { await UpdateProjectContextAndSubscriptionsAsync().ConfigureAwait(false); } }
private Task AddInitialSubscriptionsAsync() { JoinableTask joinableTask = _tasksService.LoadedProjectAsync(() => { SubscribeToConfiguredProject( _activeConfiguredProjectSubscriptionService, e => OnProjectChangedAsync(e)); // evaluation foreach (IDependencyCrossTargetSubscriber subscriber in Subscribers) { subscriber.InitializeSubscriber(this, _activeConfiguredProjectSubscriptionService); } return(Task.CompletedTask); }); return(joinableTask.Task); }
private async Task OnProjectChangedAsync(Tuple <IProjectSubscriptionUpdate, IProjectSharedFoldersSnapshot, IProjectCatalogSnapshot> e) { if (IsDisposing || IsDisposed) { return; } EnsureInitialized(); await _tasksService.LoadedProjectAsync(() => { _tasksService.UnloadCancellationToken.ThrowIfCancellationRequested(); return(HandleAsync(e)); }); }
private async Task OnProjectChangedCoreAsync(IProjectVersionedValue <IProjectSubscriptionUpdate> e, RuleHandlerType handlerType) { // TODO: https://github.com/dotnet/roslyn-project-system/issues/353 await _commonServices.ThreadingService.SwitchToUIThread(); await _tasksService.LoadedProjectAsync(async() => { await HandleAsync(e, handlerType).ConfigureAwait(false); }); // If "TargetFrameworks" property has changed, we need to refresh the project context and subscriptions. if (HasTargetFrameworksChanged(e)) { await UpdateProjectContextAndSubscriptionsAsync().ConfigureAwait(false); } }
private async Task OnProjectChangedAsync( IProjectVersionedValue <Tuple <IProjectSubscriptionUpdate, IProjectCatalogSnapshot> > e, RuleHandlerType handlerType) { if (IsDisposing || IsDisposed) { return; } await _tasksService.LoadedProjectAsync(async() => { if (_tasksService.UnloadCancellationToken.IsCancellationRequested) { return; } await HandleAsync(e, handlerType).ConfigureAwait(false); }); }
private async Task OnProjectChangedAsync( IProjectVersionedValue <Tuple <IProjectSubscriptionUpdate, IProjectSharedFoldersSnapshot, IProjectCatalogSnapshot> > e) { if (IsDisposing || IsDisposed) { return; } EnsureInitialized(); await _tasksService.LoadedProjectAsync(async() => { if (_tasksService.UnloadCancellationToken.IsCancellationRequested) { return; } await HandleAsync(e); }); }
private async Task OnProjectChangedAsync( IProjectVersionedValue <Tuple <IProjectSubscriptionUpdate, IProjectCatalogSnapshot, IProjectCapabilitiesSnapshot> > e, ConfiguredProject configuredProject, RuleHandlerType handlerType) { if (IsDisposing || IsDisposed) { return; } await _tasksService.LoadedProjectAsync(async() => { if (_tasksService.UnloadCancellationToken.IsCancellationRequested) { return; } using (ProjectCapabilitiesContext.CreateIsolatedContext(configuredProject, e.Value.Item3)) { await HandleAsync(e, handlerType).ConfigureAwait(false); } }); }
#pragma warning disable RS0030 // Do not use LoadedProjectAsync (this is the replacement) public Task LoadedProjectAsync(Func <Task> action) { JoinableTask joinable = _tasksService.LoadedProjectAsync(action); return(joinable.Task); }