using System; using System.Collections; using System.Collections.Generic; using System.Linq; namespace EndToEnd { public static class TargetFrameworkHelper { private static Version _firstNetAppVersion = new Version(5, 0); public static IEnumerable GetNetAppTargetFrameworks(IEnumerable versions) => versions.Select(v => $"netcoreapp{v}") // Add netX.X tfms starting with 5.0 .Concat(versions.Where(v => Version.Parse(v) >= _firstNetAppVersion).Select(v => $"net{v}")); } public class SupportedNetCoreAppVersions : IEnumerable { public IEnumerator GetEnumerator() => Versions.Select(version => new object[] { version }).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public static IEnumerable Versions => new[] { "1.0", "1.1", "2.0", "2.1", "2.2", "3.0", "3.1", "5.0", "6.0", "7.0", "8.0", "9.0" }; public static IEnumerable TargetFrameworkShortFolderVersion { get { var targetFrameworkShortFolderVersion = new List(); foreach (var v in Versions) { if (Version.Parse(v).Major >= 5) { targetFrameworkShortFolderVersion.Add($"net{v}"); } else { targetFrameworkShortFolderVersion.Add($"netcoreapp{v}"); } } return targetFrameworkShortFolderVersion; } } } public class SupportedAspNetCoreVersions : IEnumerable { public IEnumerator GetEnumerator() => Versions.Select(version => new object[] { version }).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public static IEnumerable Versions => SupportedNetCoreAppVersions.Versions.Except(new List() { "1.0", "1.1", "2.0" }); } public class SupportedAspNetCoreAllVersions : IEnumerable { public IEnumerator GetEnumerator() => Versions.Select(version => new object[] { version }).GetEnumerator(); IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); public static IEnumerable Versions => SupportedAspNetCoreVersions.Versions.Where(v => new Version(v).Major < 3); } }