示例#1
0
        /// <summary>
        /// Return all possible equivalent, subset, and known compatible frameworks.
        /// </summary>
        public IEnumerable <NuGetFramework> Expand(NuGetFramework framework)
        {
            var seen = new HashSet <NuGetFramework>()
            {
                framework
            };
            var toExpand = new Stack <NuGetFramework>();

            toExpand.Push(framework);

            while (toExpand.Count > 0)
            {
                foreach (var expansion in ExpandInternal(toExpand.Pop()))
                {
                    // only return distinct frameworks
                    if (seen.Add(expansion))
                    {
                        yield return(expansion);

                        toExpand.Push(expansion);
                    }
                }
            }

            // This PCL check is done outside of the loop because we do not want
            // to recurse (via the stack above) on this PCL equivalence. The
            // intent here is to ensure that PCL should expand to netstandard,
            // but NOT to dotnet (which is deprecated).
            if (framework.IsPCL)
            {
                int profileNumber;
                IEnumerable <FrameworkRange> ranges;
                if (_mappings.TryGetPortableProfileNumber(framework.Profile, out profileNumber) &&
                    _mappings.TryGetPortableCompatibilityMappings(profileNumber, out ranges))
                {
                    foreach (var range in ranges)
                    {
                        yield return(range.Min);

                        if (!range.Min.Equals(range.Max))
                        {
                            yield return(range.Max);
                        }
                    }
                }
            }
        }