protected override void Initialize()
        {
            base.Initialize();

            // Create an action block to process the design time inputs and configuration general changes
            ITargetBlock <IProjectVersionedValue <ValueTuple <DesignTimeInputs, IProjectSubscriptionUpdate> > > inputsAction = DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <ValueTuple <DesignTimeInputs, IProjectSubscriptionUpdate> > >(ProcessDataflowChanges, _project);

            _broadcastBlock = DataflowBlockSlim.CreateBroadcastBlock <IProjectVersionedValue <DesignTimeInputSnapshot> >(nameFormat: nameof(DesignTimeInputsChangeTracker) + "Broadcast {1}");
            _publicBlock    = AllowSourceBlockCompletion ? _broadcastBlock : _broadcastBlock.SafePublicize();

            Assumes.Present(_project.Services.ProjectAsynchronousTasks);

            IDisposable projectLink = ProjectDataSources.SyncLinkTo(
                _inputsDataSource.SourceBlock.SyncLinkOptions(
                    linkOptions: DataflowOption.PropagateCompletion),
                _projectSubscriptionService.ProjectRuleSource.SourceBlock.SyncLinkOptions(
                    linkOptions: DataflowOption.WithRuleNames(ConfigurationGeneral.SchemaName)),
                inputsAction,
                DataflowOption.PropagateCompletion,
                cancellationToken: _project.Services.ProjectAsynchronousTasks.UnloadCancellationToken);

            // Create an action block to process file change notifications
            ITargetBlock <IProjectVersionedValue <string[]> > fileWatcherAction = DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <string[]> >(ProcessFileChangeNotification, _project);
            IDisposable watcherLink = _fileWatcher.SourceBlock.LinkTo(fileWatcherAction, DataflowOption.PropagateCompletion);

            _disposables.Add(projectLink);
            _disposables.Add(watcherLink);

            JoinUpstreamDataSources(_inputsDataSource, _projectSubscriptionService.ProjectRuleSource, _fileWatcher);
        }
        protected override Task InitializeCoreAsync(CancellationToken cancellationToken)
        {
            _compileActionBlock = DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <DesignTimeInputSnapshot> >(ProcessDataflowChanges, _project);

            _changeTrackerLink = _changeTracker.SourceBlock.LinkTo(_compileActionBlock, DataflowOption.PropagateCompletion);

            return(Task.CompletedTask);
        }
            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 void Initialize()
        {
            base.Initialize();

            _broadcastBlock = DataflowBlockSlim.CreateBroadcastBlock <IProjectVersionedValue <string[]> >(nameFormat: nameof(DesignTimeInputsFileWatcher) + "Broadcast {1}");
            _publicBlock    = AllowSourceBlockCompletion ? _broadcastBlock : _broadcastBlock.SafePublicize();

            _actionBlock = DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <DesignTimeInputs> >(ProcessDesignTimeInputs, _project);

            _dataSourceLink = _designTimeInputsDataSource.SourceBlock.LinkTo(_actionBlock, DataflowOption.PropagateCompletion);

            JoinUpstreamDataSources(_designTimeInputsDataSource);
        }
        protected override Task InitializeCoreAsync(CancellationToken cancellationToken)
        {
            Assumes.Present(_configuredProject.Services.ProjectSubscription);

            _link = ProjectDataSources.SyncLinkTo(
                _configuredProject.Services.ProjectSubscription.JointRuleSource.SourceBlock.SyncLinkOptions(DataflowOption.WithRuleNames(ProjectPropertiesSchemas)),
                _configuredProject.Services.ProjectSubscription.SourceItemsRuleSource.SourceBlock.SyncLinkOptions(),
                _configuredProject.Services.ProjectSubscription.ProjectSource.SourceBlock.SyncLinkOptions(),
                _projectItemSchemaService.SourceBlock.SyncLinkOptions(),
                _configuredProject.Services.ProjectSubscription.ProjectCatalogSource.SourceBlock.SyncLinkOptions(),
                target: DataflowBlockFactory.CreateActionBlock <IProjectVersionedValue <ValueTuple <IProjectSubscriptionUpdate, IProjectSubscriptionUpdate, IProjectSnapshot, IProjectItemSchema, IProjectCatalogSnapshot> > >(OnChanged, _configuredProject.UnconfiguredProject),
                linkOptions: DataflowOption.PropagateCompletion);

            return(Task.CompletedTask);
        }
Exemplo n.º 6
0
            protected override Task InitializeCoreAsync(CancellationToken cancellationToken)
            {
                _joinedDataSources = ProjectDataSources.JoinUpstreamDataSources(JoinableFactory, _projectFaultHandlerService, _projectSubscriptionService.ProjectSource, _dataSource);

                _progressRegistration = _dataProgressTrackerService.RegisterOutputDataSource(this);

                Action <IProjectVersionedValue <ValueTuple <IProjectSnapshot, RestoreData> > > action = OnRestoreCompleted;

                _subscription = ProjectDataSources.SyncLinkTo(
                    _projectSubscriptionService.ProjectSource.SourceBlock.SyncLinkOptions(),
                    _dataSource.SourceBlock.SyncLinkOptions(),
                    DataflowBlockFactory.CreateActionBlock(action, ConfiguredProject.UnconfiguredProject),
                    linkOptions: DataflowOption.PropagateCompletion);

                return(Task.CompletedTask);
            }
Exemplo n.º 7
0
        protected override async Task InitializeCoreAsync(CancellationToken cancellationToken)
        {
            _projectGuid = await _project.UnconfiguredProject.GetProjectGuidAsync();

            _joinedDataSources = ProjectDataSources.JoinUpstreamDataSources(JoinableFactory, _projectFaultHandlerService, _projectSubscriptionService.ProjectSource, _workloadDescriptorDataSource);

            _missingSetupComponentRegistrationService.RegisterProjectConfiguration(_projectGuid, _project);

            Action <IProjectVersionedValue <ValueTuple <IProjectSnapshot, ISet <WorkloadDescriptor> > > > action = OnWorkloadDescriptorsComputed;

            _subscription = ProjectDataSources.SyncLinkTo(
                _projectSubscriptionService.ProjectSource.SourceBlock.SyncLinkOptions(),
                _workloadDescriptorDataSource.SourceBlock.SyncLinkOptions(),
                DataflowBlockFactory.CreateActionBlock(action, _project.UnconfiguredProject, ProjectFaultSeverity.LimitedFunctionality),
                linkOptions: DataflowOption.PropagateCompletion,
                cancellationToken: cancellationToken);
        }
Exemplo n.º 8
0
            protected override Task InitializeCoreAsync(CancellationToken cancellationToken)
            {
                _joinedDataSources = ProjectDataSources.JoinUpstreamDataSources(JoinableFactory, _projectFaultHandlerService, _projectSubscriptionService.ProjectSource, _dataSource);

                _progressRegistration = _dataProgressTrackerService.RegisterOutputDataSource(this);

                Action <IProjectVersionedValue <ValueTuple <IProjectSnapshot, RestoreData> > > action = OnRestoreCompleted;

                _subscription = ProjectDataSources.SyncLinkTo(
                    _projectSubscriptionService.ProjectSource.SourceBlock.SyncLinkOptions(),
                    _dataSource.SourceBlock.SyncLinkOptions(),
                    DataflowBlockFactory.CreateActionBlock(action, ConfiguredProject.UnconfiguredProject, ProjectFaultSeverity.LimitedFunctionality),
                    linkOptions: DataflowOption.PropagateCompletion,
                    cancellationToken: cancellationToken);

                _packageReferenceTelemetryService.PostPackageRestoreEvent(PackageRestoreOperationNames.PackageRestoreProgressTrackerInstanceInitialized, _packageRestoreProgressTrackerId);

                return(Task.CompletedTask);
            }
        /// <summary>
        /// Generates the original references directory tree.
        /// </summary>
        protected override void Initialize()
        {
#pragma warning disable RS0030 // symbol LoadedProject is banned
            using (UnconfiguredProjectAsynchronousTasksService.LoadedProject())
#pragma warning restore RS0030
            {
#pragma warning disable RS0030 // https://github.com/dotnet/roslyn-analyzers/issues/3295
                base.Initialize();
#pragma warning restore RS0030

                // this.IsApplicable may take a project lock, so we can't do it inline with this method
                // which is holding a private lock.  It turns out that doing it asynchronously isn't a problem anyway,
                // so long as we guard against races with the Dispose method.
#pragma warning disable RS0030 // symbol LoadedProjectAsync is banned
                UnconfiguredProjectAsynchronousTasksService.LoadedProjectAsync(
#pragma warning restore RS0030
                    async delegate
                {
                    await TaskScheduler.Default.SwitchTo(alwaysYield: true);
                    UnconfiguredProjectAsynchronousTasksService
                    .UnloadCancellationToken.ThrowIfCancellationRequested();

                    lock (SyncObject)
                    {
                        Verify.NotDisposed(this);

                        // Issue this token before hooking the SnapshotChanged event to prevent a race
                        // where a snapshot tree is replaced by the initial, empty tree created below.
                        // The handler will cancel this token before submitting its update.
                        CancellationToken initialTreeCancellationToken = _treeUpdateCancellationSeries.CreateNext();

                        _ = SubmitTreeUpdateAsync(
                            delegate
                        {
                            IProjectTree dependenciesNode = CreateDependenciesNode();

                            return(Task.FromResult(new TreeUpdateResult(dependenciesNode)));
                        },
                            initialTreeCancellationToken);

                        ITargetBlock <SnapshotChangedEventArgs> actionBlock = DataflowBlockFactory.CreateActionBlock <SnapshotChangedEventArgs>(
                            OnDependenciesSnapshotChangedAsync,
                            _project,
                            nameFormat: "DependenciesProjectTreeProviderSource {1}",
                            skipIntermediateInputData: true);
                        _snapshotEventListener = _dependenciesSnapshotProvider.SnapshotChangedSource.LinkTo(actionBlock, DataflowOption.PropagateCompletion);
                    }
                },
                    registerFaultHandler: true);
            }

            IProjectTree CreateDependenciesNode()
            {
                var values = new ReferencesProjectTreeCustomizablePropertyValues
                {
                    Caption      = Resources.DependenciesNodeName,
                    Icon         = KnownMonikers.ReferenceGroup.ToProjectSystemType(),
                    ExpandedIcon = KnownMonikers.ReferenceGroup.ToProjectSystemType(),
                    Flags        = ProjectTreeFlags.Create(ProjectTreeFlags.Common.BubbleUp)
                                   + ProjectTreeFlags.Create(ProjectTreeFlags.Common.ReferencesFolder)
                                   + ProjectTreeFlags.Create(ProjectTreeFlags.Common.VirtualFolder)
                                   + DependencyTreeFlags.DependenciesRootNode
                };

                // Allow property providers to perform customization.
                // These are ordered from lowest priority to highest, allowing higher priority
                // providers to override lower priority providers.
                foreach (IProjectTreePropertiesProvider provider in _projectTreePropertiesProviders.ExtensionValues())
                {
                    provider.CalculatePropertyValues(ProjectTreeCustomizablePropertyContext.Instance, values);
                }

                return(NewTree(
                           caption: values.Caption,
                           icon: values.Icon,
                           expandedIcon: values.ExpandedIcon,
                           flags: values.Flags));
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// The LaunchSettingsProvider sinks 2 sets of information:
        /// 1. Changes to the launchsettings.json file on disk
        /// 2. Changes to the ActiveDebugProfile property in the .user file
        /// </summary>
        protected override void Initialize()
        {
            // Create our broadcast block for subscribers to get new ILaunchProfiles Information
            _broadcastBlock     = DataflowBlockSlim.CreateBroadcastBlock <ILaunchSettings>();
            _changedSourceBlock = _broadcastBlock.SafePublicize();

            // Subscribe to changes to the broadcast block using the idle scheduler. This should filter out a lot of the intermediate
            // states that files can be in.
            if (_projectSubscriptionService != null)
            {
                // The use of AsyncLazy with dataflow can allow state stored in the execution context to leak through. The downstream affect is
                // calls to say, get properties, may fail. To avoid this, we capture the execution context here, and it will be reapplied when
                // we get new subscription data from the dataflow.
                ITargetBlock <IProjectVersionedValue <ValueTuple <IProjectSubscriptionUpdate, IProjectCapabilitiesSnapshot> > > projectChangesBlock = DataflowBlockFactory.CreateActionBlock(
                    DataflowUtilities.CaptureAndApplyExecutionContext <IProjectVersionedValue <ValueTuple <IProjectSubscriptionUpdate, IProjectCapabilitiesSnapshot> > >(ProjectRuleBlock_ChangedAsync), _project, ProjectFaultSeverity.LimitedFunctionality);
                StandardRuleDataflowLinkOptions evaluationLinkOptions = DataflowOption.WithRuleNames(ProjectDebugger.SchemaName);

                _projectRuleSubscriptionLink = ProjectDataSources.SyncLinkTo(
                    _projectSubscriptionService.ProjectRuleSource.SourceBlock.SyncLinkOptions(evaluationLinkOptions),
                    _commonProjectServices.Project.Capabilities.SourceBlock.SyncLinkOptions(),
                    projectChangesBlock,
                    linkOptions: DataflowOption.PropagateCompletion);
            }

            // Make sure we are watching the file at this point
            WatchLaunchSettingsFile();
        }