protected override async Task InitializeCoreAsync(CancellationToken cancellationToken) { _contextAccessor = await _workspaceProjectContextProvider.CreateProjectContextAsync(_project); if (_contextAccessor == null) { return; } _activeWorkspaceProjectContextTracker.RegisterContext(_contextAccessor.ContextId); _disposables = new DisposableBag(CancellationToken.None); _applyChangesToWorkspaceContext = _applyChangesToWorkspaceContextFactory.CreateExport(); _applyChangesToWorkspaceContext.Value.Initialize(_contextAccessor.Context); _disposables.AddDisposable(_applyChangesToWorkspaceContext); _evaluationProgressRegistration = _dataProgressTrackerService.RegisterForIntelliSense(_project, nameof(WorkspaceProjectContextHostInstance) + ".Evaluation"); _disposables.AddDisposable(_evaluationProgressRegistration); _projectBuildProgressRegistration = _dataProgressTrackerService.RegisterForIntelliSense(_project, nameof(WorkspaceProjectContextHostInstance) + ".ProjectBuild"); _disposables.AddDisposable(_projectBuildProgressRegistration); // We avoid suppressing version updates, so that progress tracker doesn't // think we're still "in progress" in the case of an empty change _disposables.AddDisposable(_projectSubscriptionService.ProjectRuleSource.SourceBlock.LinkToAsyncAction( target: e => OnProjectChangedAsync(e, evaluation: true), suppressVersionOnlyUpdates: false, ruleNames: _applyChangesToWorkspaceContext.Value.GetProjectEvaluationRules())); _disposables.AddDisposable(_projectSubscriptionService.ProjectBuildRuleSource.SourceBlock.LinkToAsyncAction( target: e => OnProjectChangedAsync(e, evaluation: false), suppressVersionOnlyUpdates: false, ruleNames: _applyChangesToWorkspaceContext.Value.GetProjectBuildRules())); }
protected override async Task InitializeCoreAsync(CancellationToken cancellationToken) { _contextAccessor = await _workspaceProjectContextProvider.CreateProjectContextAsync(_project); if (_contextAccessor == null) { return; } _activeWorkspaceProjectContextTracker.RegisterContext(_contextAccessor.ContextId); _applyChangesToWorkspaceContext = _applyChangesToWorkspaceContextFactory.CreateExport(); _applyChangesToWorkspaceContext.Value.Initialize(_contextAccessor.Context); _evaluationProgressRegistration = _dataProgressTrackerService.RegisterForIntelliSense(this, _project, nameof(WorkspaceProjectContextHostInstance) + ".Evaluation"); _projectBuildProgressRegistration = _dataProgressTrackerService.RegisterForIntelliSense(this, _project, nameof(WorkspaceProjectContextHostInstance) + ".ProjectBuild"); _sourceItemsProgressRegistration = _dataProgressTrackerService.RegisterForIntelliSense(this, _project, nameof(WorkspaceProjectContextHostInstance) + ".SourceItems"); _disposables = new DisposableBag { _applyChangesToWorkspaceContext, _evaluationProgressRegistration, _projectBuildProgressRegistration, _sourceItemsProgressRegistration, ProjectDataSources.SyncLinkTo( _activeConfiguredProjectProvider.ActiveConfiguredProjectBlock.SyncLinkOptions(), _projectSubscriptionService.ProjectRuleSource.SourceBlock.SyncLinkOptions(GetProjectEvaluationOptions()), target: DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <ValueTuple <ConfiguredProject, IProjectSubscriptionUpdate> > >(e => OnProjectChangedAsync(new ProjectChange(e), WorkspaceContextHandlerType.Evaluation), _project.UnconfiguredProject, ProjectFaultSeverity.LimitedFunctionality), linkOptions: DataflowOption.PropagateCompletion, cancellationToken: cancellationToken), ProjectDataSources.SyncLinkTo( _activeConfiguredProjectProvider.ActiveConfiguredProjectBlock.SyncLinkOptions(), _projectSubscriptionService.ProjectBuildRuleSource.SourceBlock.SyncLinkOptions(GetProjectBuildOptions()), _projectBuildSnapshotService.SourceBlock.SyncLinkOptions(), target: DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <ValueTuple <ConfiguredProject, IProjectSubscriptionUpdate, IProjectBuildSnapshot> > >(e => OnProjectChangedAsync(new ProjectChange(e), WorkspaceContextHandlerType.ProjectBuild), _project.UnconfiguredProject, ProjectFaultSeverity.LimitedFunctionality), linkOptions: DataflowOption.PropagateCompletion, cancellationToken: cancellationToken), ProjectDataSources.SyncLinkTo( _activeConfiguredProjectProvider.ActiveConfiguredProjectBlock.SyncLinkOptions(), _projectSubscriptionService.SourceItemsRuleSource.SourceBlock.SyncLinkOptions(), target: DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <ValueTuple <ConfiguredProject, IProjectSubscriptionUpdate> > >(e => OnProjectChangedAsync(new ProjectChange(e), WorkspaceContextHandlerType.SourceItems), _project.UnconfiguredProject, ProjectFaultSeverity.LimitedFunctionality), linkOptions: DataflowOption.PropagateCompletion, cancellationToken: cancellationToken), }; }
protected override async Task InitializeCoreAsync(CancellationToken cancellationToken) { _context = await _workspaceProjectContextProvider.CreateProjectContextAsync(_project); if (_context == null) { return; } _applyChangesToWorkspaceContext = _applyChangesToWorkspaceContextFactory.CreateExport(); _applyChangesToWorkspaceContext.Value.Initialize(_context); _subscriptions = new DisposableBag(CancellationToken.None); _subscriptions.AddDisposable(_projectSubscriptionService.ProjectRuleSource.SourceBlock.LinkToAsyncAction( target: e => OnProjectChangedAsync(e, evaluation: true), ruleNames: _applyChangesToWorkspaceContext.Value.GetProjectEvaluationRules())); _subscriptions.AddDisposable(_projectSubscriptionService.ProjectBuildRuleSource.SourceBlock.LinkToAsyncAction( target: e => OnProjectChangedAsync(e, evaluation: false), ruleNames: _applyChangesToWorkspaceContext.Value.GetProjectBuildRules())); }
protected override async Task InitializeCoreAsync(CancellationToken cancellationToken) { _contextAccessor = await _workspaceProjectContextProvider.CreateProjectContextAsync(_project); if (_contextAccessor == null) { return; } _activeWorkspaceProjectContextTracker.RegisterContext(_contextAccessor.ContextId); _applyChangesToWorkspaceContext = _applyChangesToWorkspaceContextFactory.CreateExport(); _applyChangesToWorkspaceContext.Value.Initialize(_contextAccessor.Context); _evaluationProgressRegistration = _dataProgressTrackerService.RegisterForIntelliSense(this, _project, nameof(WorkspaceProjectContextHostInstance) + ".Evaluation"); _projectBuildProgressRegistration = _dataProgressTrackerService.RegisterForIntelliSense(this, _project, nameof(WorkspaceProjectContextHostInstance) + ".ProjectBuild"); _disposables = new DisposableBag { _applyChangesToWorkspaceContext, _evaluationProgressRegistration, _projectBuildProgressRegistration, ProjectDataSources.SyncLinkTo( _activeConfiguredProjectProvider.ActiveConfiguredProjectBlock.SyncLinkOptions(), _projectSubscriptionService.ProjectRuleSource.SourceBlock.SyncLinkOptions(GetProjectEvaluationOptions()), _projectSubscriptionService.SourceItemsRuleSource.SourceBlock.SyncLinkOptions(), target: DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <(ConfiguredProject, IProjectSubscriptionUpdate, IProjectSubscriptionUpdate)> >( OnEvaluationUpdateAsync, _project.UnconfiguredProject, ProjectFaultSeverity.LimitedFunctionality), linkOptions: DataflowOption.PropagateCompletion, cancellationToken: cancellationToken), ProjectDataSources.SyncLinkTo( _activeConfiguredProjectProvider.ActiveConfiguredProjectBlock.SyncLinkOptions(), _projectSubscriptionService.ProjectBuildRuleSource.SourceBlock.SyncLinkOptions(GetProjectBuildOptions()), _commandLineArgumentsProvider.SourceBlock.SyncLinkOptions(), target: DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <(ConfiguredProject, IProjectSubscriptionUpdate, CommandLineArgumentsSnapshot)> >( OnBuildUpdateAsync, _project.UnconfiguredProject, ProjectFaultSeverity.LimitedFunctionality), linkOptions: DataflowOption.PropagateCompletion, cancellationToken: cancellationToken) }; return; StandardRuleDataflowLinkOptions GetProjectEvaluationOptions() { return(DataflowOption.WithRuleNames(_applyChangesToWorkspaceContext.Value.GetProjectEvaluationRules())); } StandardRuleDataflowLinkOptions GetProjectBuildOptions() { return(DataflowOption.WithRuleNames(_applyChangesToWorkspaceContext.Value.GetProjectBuildRules())); } Task OnEvaluationUpdateAsync(IProjectVersionedValue <(ConfiguredProject ActiveConfiguredProject, IProjectSubscriptionUpdate ProjectUpdate, IProjectSubscriptionUpdate SourceItemsUpdate)> e) { return(OnProjectChangedAsync( _evaluationProgressRegistration, e.Value.ActiveConfiguredProject, e, hasChange: static e => e.Value.ProjectUpdate.ProjectChanges.HasChange() || e.Value.SourceItemsUpdate.ProjectChanges.HasChange(), applyFunc: static (e, applyChangesToWorkspaceContext, contextState, token) => applyChangesToWorkspaceContext.ApplyProjectEvaluation(e.Derive(v => (v.ProjectUpdate, v.SourceItemsUpdate)), contextState, token))); } Task OnBuildUpdateAsync(IProjectVersionedValue <(ConfiguredProject ActiveConfiguredProject, IProjectSubscriptionUpdate BuildUpdate, CommandLineArgumentsSnapshot CommandLineArgumentsUpdate)> e) { return(OnProjectChangedAsync( _projectBuildProgressRegistration, e.Value.ActiveConfiguredProject, e, hasChange: static e => e.Value.BuildUpdate.ProjectChanges.HasChange() || e.Value.CommandLineArgumentsUpdate.IsChanged, applyFunc: static (e, applyChangesToWorkspaceContext, contextState, token) => applyChangesToWorkspaceContext.ApplyProjectBuild(e.Derive(v => (v.BuildUpdate, v.CommandLineArgumentsUpdate)), contextState, token))); } }