Exemplo n.º 1
0
            public SnapshotUpdater(IProjectThreadingService projectThreadingService, CancellationToken unloadCancellationToken)
            {
                // Initial snapshot is empty.
                _currentSnapshot = DependenciesSnapshot.Empty;

                // Updates will be published via Dataflow.
                _source = DataflowBlockSlim.CreateBroadcastBlock <SnapshotChangedEventArgs>("DependenciesSnapshot {1}", skipIntermediateInputData: true);

                // Updates are debounced to conflate rapid updates and reduce frequency of tree updates downstream.
                _debounce = new TaskDelayScheduler(
                    TimeSpan.FromMilliseconds(250),
                    projectThreadingService,
                    unloadCancellationToken);
            }
Exemplo n.º 2
0
        private void RegisterFileWatcher(string projectLockJsonFilePath)
        {
            // Note file change service is free-threaded
            if (_fileChangeService != null && projectLockJsonFilePath != null)
            {
                _previousContentsHash = GetFileHashOrNull(projectLockJsonFilePath);
                _taskDelayScheduler   = new TaskDelayScheduler(
                    s_notifyDelay,
                    _projectServices.ThreadingService,
                    CreateLinkedCancellationToken());

                int hr = _fileChangeService.AdviseFileChange(projectLockJsonFilePath, (uint)(_VSFILECHANGEFLAGS.VSFILECHG_Time | _VSFILECHANGEFLAGS.VSFILECHG_Size | _VSFILECHANGEFLAGS.VSFILECHG_Add | _VSFILECHANGEFLAGS.VSFILECHG_Del), this, out _filechangeCookie);
                ErrorHandler.ThrowOnFailure(hr);
            }

            _fileBeingWatched = projectLockJsonFilePath;
        }
Exemplo n.º 3
0
        public DependenciesSnapshotProvider(
            IUnconfiguredProjectCommonServices commonServices,
            Lazy <IAggregateCrossTargetProjectContextProvider> contextProvider,
            IUnconfiguredProjectTasksService tasksService,
            IActiveConfiguredProjectSubscriptionService activeConfiguredProjectSubscriptionService,
            IActiveProjectConfigurationRefreshService activeProjectConfigurationRefreshService,
            ITargetFrameworkProvider targetFrameworkProvider,
            IAggregateDependenciesSnapshotProvider aggregateSnapshotProvider)
            : base(commonServices.ThreadingService.JoinableTaskContext)
        {
            Requires.NotNull(contextProvider, nameof(contextProvider));
            Requires.NotNull(tasksService, nameof(tasksService));
            Requires.NotNull(activeConfiguredProjectSubscriptionService, nameof(activeConfiguredProjectSubscriptionService));
            Requires.NotNull(activeProjectConfigurationRefreshService, nameof(activeProjectConfigurationRefreshService));
            Requires.NotNull(targetFrameworkProvider, nameof(targetFrameworkProvider));
            Requires.NotNull(aggregateSnapshotProvider, nameof(aggregateSnapshotProvider));

            _commonServices  = commonServices;
            _contextProvider = contextProvider;
            _tasksService    = tasksService;
            _activeConfiguredProjectSubscriptionService = activeConfiguredProjectSubscriptionService;
            _activeProjectConfigurationRefreshService   = activeProjectConfigurationRefreshService;
            _targetFrameworkProvider = targetFrameworkProvider;

            _currentSnapshot = DependenciesSnapshot.CreateEmpty(_commonServices.Project.FullPath);

            _dependencySubscribers = new OrderPrecedenceImportCollection <IDependencyCrossTargetSubscriber>(
                projectCapabilityCheckProvider: commonServices.Project);

            _snapshotFilters = new OrderPrecedenceImportCollection <IDependenciesSnapshotFilter>(
                ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesLast,
                projectCapabilityCheckProvider: commonServices.Project);

            _subTreeProviders = new OrderPrecedenceImportCollection <IProjectDependenciesSubTreeProvider>(
                ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesLast,
                projectCapabilityCheckProvider: commonServices.Project);

            _dependenciesUpdateScheduler = new TaskDelayScheduler(
                _dependenciesUpdateThrottleInterval,
                commonServices.ThreadingService,
                tasksService.UnloadCancellationToken);

            _snapshotChangedSource = DataflowBlockSlim.CreateBroadcastBlock <SnapshotChangedEventArgs>("DependenciesSnapshot {1}", skipIntermediateInputData: true);

            aggregateSnapshotProvider.RegisterSnapshotProvider(this);
        }
        public DependencySubscriptionsHost(
            IUnconfiguredProjectCommonServices commonServices,
            Lazy <IAggregateCrossTargetProjectContextProvider> contextProvider,
            [Import(ExportContractNames.Scopes.UnconfiguredProject)] IProjectAsynchronousTasksService tasksService,
            IActiveConfiguredProjectSubscriptionService activeConfiguredProjectSubscriptionService,
            IActiveProjectConfigurationRefreshService activeProjectConfigurationRefreshService,
            ITargetFrameworkProvider targetFrameworkProvider,
            IAggregateDependenciesSnapshotProvider aggregateSnapshotProvider)
            : base(commonServices.ThreadingService.JoinableTaskContext)
        {
            Requires.NotNull(contextProvider, nameof(contextProvider));
            Requires.NotNull(tasksService, nameof(tasksService));
            Requires.NotNull(activeConfiguredProjectSubscriptionService, nameof(activeConfiguredProjectSubscriptionService));
            Requires.NotNull(activeProjectConfigurationRefreshService, nameof(activeProjectConfigurationRefreshService));
            Requires.NotNull(targetFrameworkProvider, nameof(targetFrameworkProvider));
            Requires.NotNull(aggregateSnapshotProvider, nameof(aggregateSnapshotProvider));

            _commonServices  = commonServices;
            _contextProvider = contextProvider;
            _tasksService    = tasksService;
            _activeConfiguredProjectSubscriptionService = activeConfiguredProjectSubscriptionService;
            _activeProjectConfigurationRefreshService   = activeProjectConfigurationRefreshService;
            _targetFrameworkProvider   = targetFrameworkProvider;
            _aggregateSnapshotProvider = aggregateSnapshotProvider;

            _currentSnapshot = DependenciesSnapshot.CreateEmpty(_commonServices.Project.FullPath);

            _dependencySubscribers = new OrderPrecedenceImportCollection <IDependencyCrossTargetSubscriber>(
                projectCapabilityCheckProvider: commonServices.Project);

            _snapshotFilters = new OrderPrecedenceImportCollection <IDependenciesSnapshotFilter>(
                projectCapabilityCheckProvider: commonServices.Project,
                orderingStyle: ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesLast);

            _subTreeProviders = new OrderPrecedenceImportCollection <IProjectDependenciesSubTreeProvider>(
                ImportOrderPrecedenceComparer.PreferenceOrder.PreferredComesLast,
                projectCapabilityCheckProvider: commonServices.Project);

            _dependenciesUpdateScheduler = new TaskDelayScheduler(
                _dependenciesUpdateThrottleInterval,
                commonServices.ThreadingService,
                tasksService.UnloadCancellationToken);

            ProjectFilePath = commonServices.Project.FullPath;
        }
        private async Task RegisterFileWatcherAsync(string projectLockJsonFilePath)
        {
            // Note file change service is free-threaded
            if (projectLockJsonFilePath != null)
            {
                _previousContentsHash = GetFileHashOrNull(projectLockJsonFilePath);
                _taskDelayScheduler?.Dispose();
                _taskDelayScheduler = new TaskDelayScheduler(
                    s_notifyDelay,
                    _projectServices.ThreadingService,
                    CreateLinkedCancellationToken());

                IVsAsyncFileChangeEx fileChangeService = await _fileChangeService.GetValueAsync();

                _filechangeCookie = await fileChangeService.AdviseFileChangeAsync(
                    projectLockJsonFilePath,
                    _VSFILECHANGEFLAGS.VSFILECHG_Time | _VSFILECHANGEFLAGS.VSFILECHG_Size | _VSFILECHANGEFLAGS.VSFILECHG_Add | _VSFILECHANGEFLAGS.VSFILECHG_Del,
                    sink : this);
            }

            _fileBeingWatched = projectLockJsonFilePath;
        }