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 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.
                return(Task.WhenAll(
                           Subscribers.Select(
                               subscriber => subscriber.InitializeSubscriberAsync(this, _activeConfiguredProjectSubscriptionService))));
            }

            async Task OnActiveConfiguredProjectEvaluatedAsync(IProjectVersionedValue <IProjectSubscriptionUpdate> e)
            {
                if (IsDisposing || IsDisposed)
                {
                    return;
                }

                await EnsureInitializedAsync();

                await OnConfiguredProjectEvaluatedAsync(e);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize the watcher.
        /// </summary>
        protected override async Task InitializeCoreAsync(CancellationToken cancellationToken)
        {
            _fileChangeService = (IVsFileChangeEx)(await _asyncServiceProvider.GetServiceAsync(typeof(SVsFileChangeEx)).ConfigureAwait(false));

            // Explicitly get back to the thread pool for the rest of this method so we don't tie up the UI thread;
            await TaskScheduler.Default;

            await _projectTasksService.LoadedProjectAsync(() =>
            {
                // The tree source to get changes to the tree so that we can identify when the assets file changes.
                var treeSource = _fileSystemTreeProvider.Tree.SyncLinkOptions();

                // The property source used to get the value of the $ProjectAssetsFile property so that we can identify the location of the assets file.
                var sourceLinkOptions = new StandardRuleDataflowLinkOptions
                {
                    RuleNames           = Empty.OrdinalIgnoreCaseStringSet.Add(ConfigurationGeneral.SchemaName),
                    PropagateCompletion = true
                };

                var propertySource = _activeConfiguredProjectSubscriptionService.ProjectRuleSource.SourceBlock.SyncLinkOptions(sourceLinkOptions);
                var target         = new ActionBlock <IProjectVersionedValue <Tuple <IProjectTreeSnapshot, IProjectSubscriptionUpdate> > >(DataFlow_ChangedAsync);

                // Join the two sources so that we get synchronized versions of the data.
                _treeWatcher = ProjectDataSources.SyncLinkTo(treeSource, propertySource, target);

                return(Task.CompletedTask);
            }).ConfigureAwait(false);
        }
        private async Task OnProjectChangedAsync(
            IProjectSubscriptionUpdate projectUpdate,
            IProjectCatalogSnapshot catalogSnapshot,
            IProjectCapabilitiesSnapshot capabilities,
            ConfiguredProject configuredProject,
            RuleHandlerType handlerType)
        {
            if (IsDisposing || IsDisposed)
            {
                return;
            }

            // Ensure updates don't overlap and that we aren't disposed during the update without cleaning up properly
            await ExecuteUnderLockAsync(async token =>
            {
                // Ensure the project doesn't unload during the update
                await _tasksService.LoadedProjectAsync(async() =>
                {
                    // TODO pass _tasksService.UnloadCancellationToken into handler to reduce redundant work on unload

                    // Ensure the project's capabilities don't change during the update
                    using (ProjectCapabilitiesContext.CreateIsolatedContext(configuredProject, capabilities))
                    {
                        await HandleAsync(projectUpdate, catalogSnapshot, handlerType);
                    }
                });
            });
        }
Ejemplo n.º 4
0
        internal Task OnProjectChangedAsync(IProjectVersionedValue <IProjectSubscriptionUpdate>?_ = null)
        {
            return(_projectTasksService.LoadedProjectAsync(async() =>
            {
                bool isDebuggable = await IsDebuggableAsync();

                IVsStartupProjectsListService?startupProjectsListService = await _startupProjectsListService.GetValueAsync();

                if (startupProjectsListService == null)
                {
                    return;
                }

                if (isDebuggable)
                {
                    // If we're already registered, the service no-ops
                    startupProjectsListService.AddProject(ref _projectGuid);
                }
                else
                {
                    // If we're already unregistered, the service no-ops
                    startupProjectsListService.RemoveProject(ref _projectGuid);
                }
            }));
        }
Ejemplo n.º 5
0
            /// <summary>
            /// Initialize the watcher.
            /// </summary>
            protected override Task InitializeCoreAsync(CancellationToken cancellationToken)
            {
                return(_projectTasksService.LoadedProjectAsync(() =>
                {
                    // The tree source to get changes to the tree so that we can identify when the assets file changes.
                    ProjectDataSources.SourceBlockAndLink <IProjectVersionedValue <IProjectTreeSnapshot> > treeSource = _fileSystemTreeProvider.Tree.SyncLinkOptions();

                    // The property source used to get the value of the $ProjectAssetsFile property so that we can identify the location of the assets file.
                    StandardRuleDataflowLinkOptions sourceLinkOptions = DataflowOption.WithRuleNames(ConfigurationGeneral.SchemaName);

                    ProjectDataSources.SourceBlockAndLink <IProjectVersionedValue <IProjectSubscriptionUpdate> > propertySource = _activeConfiguredProjectSubscriptionService.ProjectRuleSource.SourceBlock.SyncLinkOptions(sourceLinkOptions);
                    ITargetBlock <IProjectVersionedValue <Tuple <IProjectTreeSnapshot, IProjectSubscriptionUpdate> > > target = DataflowBlockSlim.CreateActionBlock <IProjectVersionedValue <Tuple <IProjectTreeSnapshot, IProjectSubscriptionUpdate> > >(DataFlow_ChangedAsync);

                    // Join the two sources so that we get synchronized versions of the data.
                    _treeWatcher = ProjectDataSources.SyncLinkTo(treeSource, propertySource, target);

                    return Task.CompletedTask;
                }));
            }
Ejemplo n.º 6
0
 private async Task OnActiveConfigurationsChanged(IProjectVersionedValue <IConfigurationGroup <ProjectConfiguration> > e)
 {
     foreach (ProjectConfiguration configuration in e.Value)
     {
         // Make sure we aren't currently unloading, or we don't unload while we load the configuration
         await _tasksService.LoadedProjectAsync(() =>
         {
             return(_project.LoadConfiguredProjectAsync(configuration));
         }).ConfigureAwait(false);
     }
 }
        private async Task OnProjectChangedAsync(Tuple<IProjectSubscriptionUpdate, IProjectSharedFoldersSnapshot, IProjectCatalogSnapshot> e)
        {
            if (IsDisposing || IsDisposed)
            {
                return;
            }

            EnsureInitialized();

            await _tasksService.LoadedProjectAsync(() =>
            {
                return HandleAsync(e);
            });
        }
        /// <summary>
        /// Initialize the watcher.
        /// </summary>
        protected override async Task InitializeCoreAsync(CancellationToken cancellationToken)
        {
            // Explicitly get back to the thread pool for the rest of this method so we don't tie up the UI thread;
            await TaskScheduler.Default;

            await _projectTasksService.LoadedProjectAsync(() =>
            {
                // The tree source to get changes to the tree so that we can identify when the assets file changes.
                ProjectDataSources.SourceBlockAndLink <IProjectVersionedValue <IProjectTreeSnapshot> > treeSource = _fileSystemTreeProvider.Tree.SyncLinkOptions();

                // The property source used to get the value of the $ProjectAssetsFile property so that we can identify the location of the assets file.
                StandardRuleDataflowLinkOptions sourceLinkOptions = DataflowOption.WithRuleNames(ConfigurationGeneral.SchemaName);

                ProjectDataSources.SourceBlockAndLink <IProjectVersionedValue <IProjectSubscriptionUpdate> > propertySource = _activeConfiguredProjectSubscriptionService.ProjectRuleSource.SourceBlock.SyncLinkOptions(sourceLinkOptions);
                var target = new ActionBlock <IProjectVersionedValue <Tuple <IProjectTreeSnapshot, IProjectSubscriptionUpdate> > >(DataFlow_ChangedAsync);

                // Join the two sources so that we get synchronized versions of the data.
                _treeWatcher = ProjectDataSources.SyncLinkTo(treeSource, propertySource, target);

                return(Task.CompletedTask);
            });
        }