Пример #1
0
 public HashSet <string> GetUniqueTopLevelDependencies()
 {
     return(CurrentSnapshot.GetUniqueTopLevelDependencies());
 }
Пример #2
0
        private NugetDependenciesChange ProcessResolvedChanges(IProjectSubscriptionUpdate projectSubscriptionUpdate,
                                                               HashSet <IDependencyNode> rootTreeNodes)
        {
            var changes         = projectSubscriptionUpdate.ProjectChanges;
            var resolvedChanges = ResolvedReferenceRuleNames.Where(x => changes.Keys.Contains(x))
                                  .Select(ruleName => changes[ruleName])
                                  .ToImmutableHashSet();
            var dependenciesChange = new NugetDependenciesChange();
            var newDependencies    = new HashSet <DependencyMetadata>();

            foreach (var change in resolvedChanges)
            {
                if (!change.Difference.AnyChanges)
                {
                    continue;
                }

                foreach (string removedItemSpec in change.Difference.RemovedItems)
                {
                    var metadata = CurrentSnapshot.RemoveDependency(removedItemSpec);
                    var itemNode = rootTreeNodes.FirstOrDefault(
                        x => x.Id.ItemSpec.Equals(removedItemSpec, StringComparison.OrdinalIgnoreCase));
                    if (itemNode != null)
                    {
                        dependenciesChange.RemovedNodes.Add(metadata);
                    }
                }

                foreach (string changedItemSpec in change.Difference.ChangedItems)
                {
                    var properties = GetProjectItemProperties(change.After, changedItemSpec);
                    if (properties == null)
                    {
                        continue;
                    }

                    var metadata = CurrentSnapshot.UpdateDependency(changedItemSpec, properties);
                    var itemNode = rootTreeNodes.FirstOrDefault(
                        x => x.Id.ItemSpec.Equals(changedItemSpec, StringComparison.OrdinalIgnoreCase));
                    if (itemNode != null)
                    {
                        dependenciesChange.UpdatedNodes.Add(metadata);
                    }
                }

                foreach (string addedItemSpec in change.Difference.AddedItems)
                {
                    var properties = GetProjectItemProperties(change.After, addedItemSpec);
                    if (properties == null)
                    {
                        continue;
                    }

                    var newDependency = CurrentSnapshot.AddDependency(addedItemSpec, properties);
                    newDependencies.Add(newDependency);
                }
            }

            // Note: currently deisgn time build is limited and is not aware of conditional on TFM
            // PackageReference items: Unresolved PackageReference items for conditional TFMs are not sent.
            // Thus we will display conditional PackageReferences if they were resolved and are in assets.json.
            // This limitation should go away, when we have final design for cross target dependencies and
            // DesignTime build.
            var allTargetsDependencies = CurrentSnapshot.GetUniqueTopLevelDependencies();

            if (allTargetsDependencies.Count == 0)
            {
                return(dependenciesChange);
            }

            var addedTopLevelDependencies = newDependencies.Where(
                x => allTargetsDependencies.Contains(x.ItemSpec));

            foreach (var addedDependency in addedTopLevelDependencies)
            {
                dependenciesChange.AddedNodes.Add(addedDependency);
            }

            return(dependenciesChange);
        }