예제 #1
0
            private static ImmutableArray <PackageReference> GetPackageReferences(ICollection <MSB.Execution.ProjectItemInstance> items)
            {
                var builder  = ImmutableArray.CreateBuilder <PackageReference>(items.Count);
                var addedSet = new HashSet <PackageReference>();

                foreach (var item in items)
                {
                    var name         = item.EvaluatedInclude;
                    var versionValue = item.GetMetadataValue(MetadataNames.Version);
                    var versionRange = PropertyConverter.ToVersionRange(versionValue);
                    var dependency   = new PackageDependency(name, versionRange);

                    var isImplicitlyDefinedValue = item.GetMetadataValue(MetadataNames.IsImplicitlyDefined);
                    var isImplicitlyDefined      = PropertyConverter.ToBoolean(isImplicitlyDefinedValue, defaultValue: false);

                    var packageReference = new PackageReference(dependency, isImplicitlyDefined);

                    if (addedSet.Add(packageReference))
                    {
                        builder.Add(packageReference);
                    }
                }

                return(builder.ToImmutable());
            }