private void OnDependenciesChanged(object sender, DependenciesChangedEventArgs e)
        {
            if (IsDisposing || IsDisposed)
            {
                return;
            }

            var nowait = SubmitTreeUpdateAsync(
                (treeSnapshot, configuredProjectExports, cancellationToken) =>
            {
                var dependenciesNode = treeSnapshot.Value.Tree;
                dependenciesNode     = CreateOrUpdateSubTreeProviderNode(dependenciesNode,
                                                                         e.Provider,
                                                                         changes: e.Changes,
                                                                         cancellationToken: cancellationToken,
                                                                         catalogs: e.Catalogs);

                ProjectContextChanged?.Invoke(this, new ProjectContextEventArgs(this, e.Changes));

                // TODO We still are getting mismatched data sources and need to figure out better
                // way of merging, mute them for now and get to it in U1
                return(Task.FromResult(new TreeUpdateResult(dependenciesNode,
                                                            false,
                                                            null /*GetMergedDataSourceVersions(e)*/)));
            });
        }
Exemple #2
0
        private void OnDependenciesChanged(object sender, DependenciesChangedEventArgs e)
        {
            var nowait = SubmitTreeUpdateAsync(
                (treeSnapshot, configuredProjectExports, cancellationToken) =>
            {
                var dependenciesNode = treeSnapshot.Value.Tree;
                dependenciesNode     = CreateOrUpdateSubTreeProviderNode(dependenciesNode,
                                                                         e.Provider,
                                                                         changes: e.Changes,
                                                                         cancellationToken: cancellationToken,
                                                                         catalogs: e.Catalogs);

                ProjectContextChanged?.Invoke(this, new ProjectContextEventArgs(this));

                return(Task.FromResult(new TreeUpdateResult(dependenciesNode, false, e.DataSourceVersions)));
            });
        }
        /// <summary>
        /// Note: this is important to merge data source versions correctly here, since
        /// and different providers sending this event might have different processing time
        /// and we might end up in later data source versions coming before earlier ones. If
        /// we post greater versions before lower ones there will be exception and data flow
        /// might be broken after that.
        /// Another reason post data source versions here is that there could be other
        /// components waiting for Dependencies tree changes and if we don't post versions,
        /// they could not track our changes.
        /// </summary>
        private IImmutableDictionary <NamedIdentity, IComparable> GetMergedDataSourceVersions(
            DependenciesChangedEventArgs e)
        {
            IImmutableDictionary <NamedIdentity, IComparable> mergedDataSourcesVersions = null;

            lock (_latestDataSourcesVersions)
            {
                if (!string.IsNullOrEmpty(e.Provider.ProviderType) && e.DataSourceVersions != null)
                {
                    _latestDataSourcesVersions[e.Provider.ProviderType] = e.DataSourceVersions;
                }

                mergedDataSourcesVersions =
                    ProjectDataSources.MergeDataSourceVersions(_latestDataSourcesVersions.Values);
            }

            return(mergedDataSourcesVersions);
        }
        private void OnDependenciesChanged(object sender, DependenciesChangedEventArgs e)
        {
            var nowait = SubmitTreeUpdateAsync(
                (treeSnapshot, configuredProjectExports, cancellationToken) =>
            {
                var dependenciesNode = treeSnapshot.Value.Tree;
                dependenciesNode     = CreateOrUpdateSubTreeProviderNode(dependenciesNode,
                                                                         e.Provider,
                                                                         changes: e.Changes,
                                                                         cancellationToken: cancellationToken,
                                                                         catalogs: e.Catalogs);

                ProjectContextChanged?.Invoke(this, new ProjectContextEventArgs(this));

                // Note: temporary workaround to prevent data sources being out of sync is send null always,
                // this would stop error dialog, however subscribers could not check for Dependencies tree changes
                // until real fix is checked it (its fine since there probably should not be any at the moment).
                return(Task.FromResult(new TreeUpdateResult(dependenciesNode, false, null /*e.DataSourceVersions*/)));
            });
        }