public static ReadOnlyCollection TrySetCollection()

in src/VSSetup.PowerShell/Utilities.cs [118:140]


        public static ReadOnlyCollection<R> TrySetCollection<T, R>(
            ref IList<R> property,
            string propertyName,
            Func<IEnumerable<T>> action,
            Func<T, R> creator,
            Action<string> error = null)
            where T : ISetupPackageReference
            where R : PackageReference
        {
            Validate.NotNullOrEmpty(propertyName, nameof(propertyName));
            Validate.NotNull(action, nameof(action));
            Validate.NotNull(creator, nameof(creator));

            var packages = GetAdaptedPackages(action, creator);
            TrySet(ref property, propertyName, packages.ToList, error);

            if (property != null && property.Any())
            {
                return new ReadOnlyCollection<R>(property);
            }

            return EmptyReadOnlyCollection<R>();
        }