Example #1
0
        public static Version DetermineGenerationForFramework(NuGetFramework framework, bool useNetPlatform)
        {
            FrameworkExpander expander = new FrameworkExpander();
            var generationFramework = useNetPlatform ? FrameworkConstants.FrameworkIdentifiers.NetPlatform : FrameworkConstants.FrameworkIdentifiers.NetStandard;
            var generationFxs = expander.Expand(framework).Where(fx => fx.Framework == generationFramework).Select(fx => fx.Version);

            return generationFxs.Max();
        }
        public void FrameworkExpander_Win()
        {
            NuGetFramework framework = NuGetFramework.Parse("win");

            FrameworkExpander expander = new FrameworkExpander();
            var expanded = expander.Expand(framework).ToArray();

            Assert.Equal<int>(5, expanded.Length);
        }
        public void FrameworkExpander_Indirect()
        {
            NuGetFramework framework = NuGetFramework.Parse("win9");
            NuGetFramework indirect = new NuGetFramework(".NETCore", new Version(4, 5));

            FrameworkExpander expander = new FrameworkExpander();
            var expanded = expander.Expand(framework).ToArray();

            Assert.True(expanded.Contains(indirect, NuGetFramework.Comparer), String.Join("|", expanded.Select(e => e.ToString())));
        }
        public void FrameworkExpander_UAPWIN()
        {
            NuGetFramework framework = NuGetFramework.Parse("UAP10.0");
            NuGetFramework indirect = new NuGetFramework("Windows", new Version(8, 1, 0, 0));

            FrameworkExpander expander = new FrameworkExpander();
            var expanded = expander.Expand(framework).ToArray();

            Assert.True(expanded.Contains(indirect, NuGetFramework.Comparer), String.Join("|", expanded.Select(e => e.ToString())));
        }
        public void FrameworkExpander_Basic()
        {
            NuGetFramework framework = NuGetFramework.Parse("net45");

            FrameworkExpander expander = new FrameworkExpander();
            var expanded = expander.Expand(framework).ToArray();

            Assert.Equal(2, expanded.Length);
            Assert.Equal(".NETFramework,Version=v4.5,Profile=Client", expanded[0].ToString());
            Assert.Equal(".NETFramework,Version=v4.5,Profile=Full", expanded[1].ToString());
        }
 public CompatibilityProvider(IFrameworkNameProvider mappings)
 {
     _mappings = mappings;
     _expander = new FrameworkExpander(mappings);
     _cache    = new Dictionary <int, bool>();
 }
Example #7
0
 public CompatibilityProvider(IFrameworkNameProvider mappings)
 {
     _mappings = mappings;
     _expander = new FrameworkExpander(mappings);
     _cache    = new ConcurrentDictionary <CompatibilityCacheKey, bool>();
 }
        private void LoadFrameworks()
        {
            _frameworks = new Dictionary<NuGetFramework, string[]>(NuGetFramework.Comparer);

            // load the specified frameworks
            foreach(var framework in Frameworks)
            {
                var runtimeIds = framework.GetMetadata("RuntimeIDs")?.Split(';');

                NuGetFramework fx;
                try
                {
                    fx = FrameworkUtilities.ParseNormalized(framework.ItemSpec);
                }
                catch (Exception ex)
                {
                    Log.LogError($"Could not parse Framework {framework.ItemSpec}. {ex}");
                    continue;
                }

                if (fx.Equals(NuGetFramework.UnsupportedFramework))
                {
                    Log.LogError($"Did not recognize {framework.ItemSpec} as valid Framework.");
                    continue;
                }

                _frameworks.Add(fx, runtimeIds);
            }

            // inspect any TFMs explicitly targeted
            var fileFrameworks = _targetPathToPackageItem.Values.Select(f => f.TargetFramework).Distinct(NuGetFramework.Comparer).Where(f => f != null);
            foreach(var fileFramework in fileFrameworks)
            {
                if (!_frameworks.ContainsKey(fileFramework))
                {
                    _frameworks.Add(fileFramework, s_noRids);
                }
            }

            // inspect any TFMs inbox
            var frameworkData = FrameworkSet.Load(FrameworkListsPath);
            var inboxFrameworks = frameworkData.Frameworks.SelectMany(f => f.Value)
                .Where(fx => fx.Assemblies.ContainsKey(PackageId))
                .Select(fx => NuGetFramework.Parse(fx.FrameworkName.FullName));
            
            foreach (var inboxFramework in inboxFrameworks)
            {
                if (!_frameworks.ContainsKey(inboxFramework))
                {
                    _frameworks.Add(inboxFramework, s_noRids);
                }
            }

            // inspect for derived TFMs
            var expander = new FrameworkExpander();
            foreach(var framework in _frameworks.Keys.ToArray())
            {
                var derivedFxs = expander.Expand(framework);

                foreach (var derivedFx in derivedFxs)
                {
                    if (!_frameworks.ContainsKey(derivedFx))
                    {
                        _frameworks.Add(derivedFx, s_noRids);
                    }
                }
            }
        }
        public void FrameworkExpander_NetCore45()
        {
            NuGetFramework framework = NuGetFramework.Parse("nfcore45");

            FrameworkExpander expander = new FrameworkExpander();
            var expanded = expander.Expand(framework).ToArray();

            Assert.Equal(0, expanded.Length);
        }
Example #10
0
 public CompatibilityProvider(IFrameworkNameProvider mappings)
 {
     _mappings = mappings;
     _expander = new FrameworkExpander(mappings);
     _cache = new ConcurrentDictionary<int, bool>();
 }