public ITargetFramework?GetNearestFramework(ITargetFramework targetFramework, IEnumerable <ITargetFramework> otherFrameworks) { if (targetFramework?.FrameworkName == null || otherFrameworks == null) { return(null); } var others = otherFrameworks.Where(other => other.FrameworkName != null).ToList(); if (others.Count == 0) { return(null); } FrameworkName?nearestFrameworkName = _nuGetComparer.GetNearest( targetFramework.FrameworkName, others.Select(x => x.FrameworkName)); if (nearestFrameworkName == null) { return(null); } return(others.FirstOrDefault((x, nearest) => nearest.Equals(x.FrameworkName), nearestFrameworkName)); }
public ITargetFramework GetNearestFramework(ITargetFramework targetFramework, IEnumerable <ITargetFramework> otherFrameworks) { if (targetFramework == null || otherFrameworks == null || !otherFrameworks.Any()) { return(null); } var nearestFrameworkName = _nuGetComparer.GetNearest( targetFramework.FrameworkName, otherFrameworks.Select(x => x.FrameworkName)); if (nearestFrameworkName == null) { return(null); } return(otherFrameworks.FirstOrDefault(x => nearestFrameworkName.Equals(x.FrameworkName))); }