private static bool IsPortableLibraryCompatible(FrameworkName frameworkName, FrameworkName targetFrameworkName) { if (String.IsNullOrEmpty(targetFrameworkName.Profile)) { return(false); } NetPortableProfile targetFrameworkPortableProfile = NetPortableProfile.Parse(targetFrameworkName.Profile); if (targetFrameworkPortableProfile == null) { return(false); } if (frameworkName.IsPortableFramework()) { // this is the case with Portable Library vs. Portable Library if (String.Equals(frameworkName.Profile, targetFrameworkName.Profile, StringComparison.OrdinalIgnoreCase)) { return(true); } NetPortableProfile frameworkPortableProfile = NetPortableProfile.Parse(frameworkName.Profile); if (frameworkPortableProfile == null) { return(false); } return(targetFrameworkPortableProfile.IsCompatibleWith(frameworkPortableProfile)); } else { // this is the case with Portable Library installed into a normal project bool isCompatible = targetFrameworkPortableProfile.IsCompatibleWith(frameworkName); if (!isCompatible) { // TODO: Remove this logic when out dependencies have moved to ASP.NET Core 5.0 // as this logic is super fuzzy and terrible if (string.Equals(frameworkName.Identifier, AspNetCoreFrameworkIdentifier, StringComparison.OrdinalIgnoreCase)) { var frameworkIdentifierLookup = targetFrameworkPortableProfile.SupportedFrameworks .Select(NormalizeFrameworkName) .ToLookup(f => f.Identifier); if (frameworkIdentifierLookup[NetFrameworkIdentifier].Any(f => f.Version >= new Version(4, 5)) && frameworkIdentifierLookup[NetCoreFrameworkIdentifier].Any(f => f.Version >= new Version(4, 5))) { return(true); } } } return(isCompatible); } }
internal static bool HasCompatibleProfileWith(NetPortableProfile packageFramework, FrameworkName projectOptionalFrameworkName) { List <VersionStringISetTuple> versionProfileISetTupleList = null; // In the dictionary _portableProfilesSetByOptionalFrameworks, // key is the identifier of the optional framework and value is the tuple of (optional Framework Version, set of profiles in which they are optional) // We try to get a value with key as projectOptionalFrameworkName.Identifier. If one exists, we check if the project version is >= the version from the retrieved tuple // If so, then, we see if one of the profiles, in the set from the retrieved tuple, is compatible with the packageFramework profile if (_portableProfilesSetByOptionalFrameworks != null && _portableProfilesSetByOptionalFrameworks.TryGetValue(projectOptionalFrameworkName.Identifier, out versionProfileISetTupleList)) { foreach (var versionProfileISetTuple in versionProfileISetTupleList) { if (projectOptionalFrameworkName.Version >= versionProfileISetTuple.Item1) { foreach (var profileName in versionProfileISetTuple.Item2) { NetPortableProfile profile = GetProfile(profileName); if (profile != null && packageFramework.IsCompatibleWith(profile)) { return(true); } } } } } return(false); }
private static bool IsPortableLibraryCompatible( NetPortableProfileTable table, FrameworkName projectFrameworkName, FrameworkName packageTargetFrameworkName) { if (string.IsNullOrEmpty(packageTargetFrameworkName.Profile)) { return(false); } NetPortableProfile targetFrameworkPortableProfile = NetPortableProfile.Parse(table, packageTargetFrameworkName.Profile); if (targetFrameworkPortableProfile == null) { return(false); } if (projectFrameworkName.IsPortableFramework()) { // this is the case with Portable Library vs. Portable Library if (string.Equals(projectFrameworkName.Profile, packageTargetFrameworkName.Profile, StringComparison.OrdinalIgnoreCase)) { return(true); } NetPortableProfile frameworkPortableProfile = NetPortableProfile.Parse(table, projectFrameworkName.Profile); if (frameworkPortableProfile == null) { return(false); } return(targetFrameworkPortableProfile.IsCompatibleWith(frameworkPortableProfile)); } else { // this is the case with Portable Library installed into a normal project return(targetFrameworkPortableProfile.IsCompatibleWith(table, projectFrameworkName)); } }
private static bool IsPortableLibraryCompatible(FrameworkName projectFrameworkName, FrameworkName packageTargetFrameworkName, NetPortableProfileTable portableProfileTable) { if (string.IsNullOrEmpty(packageTargetFrameworkName.get_Profile())) { return(false); } NetPortableProfile profile = NetPortableProfile.Parse(packageTargetFrameworkName.get_Profile(), false, portableProfileTable); if (profile == null) { return(false); } if (!projectFrameworkName.IsPortableFramework()) { return(profile.IsCompatibleWith(projectFrameworkName)); } if (string.Equals(projectFrameworkName.get_Profile(), packageTargetFrameworkName.get_Profile(), StringComparison.OrdinalIgnoreCase)) { return(true); } NetPortableProfile projectFrameworkProfile = NetPortableProfile.Parse(projectFrameworkName.get_Profile(), false, portableProfileTable); return((projectFrameworkProfile != null) ? profile.IsCompatibleWith(projectFrameworkProfile, portableProfileTable) : false); }
internal bool HasCompatibleProfileWith(NetPortableProfile packageFramework, FrameworkName projectOptionalFrameworkName, NetPortableProfileTable portableProfileTable) { List <Tuple <Version, ISet <string> > > list = null; if ((this._portableProfilesSetByOptionalFrameworks != null) && this._portableProfilesSetByOptionalFrameworks.TryGetValue(projectOptionalFrameworkName.get_Identifier(), out list)) { using (List <Tuple <Version, ISet <string> > > .Enumerator enumerator = list.GetEnumerator()) { while (true) { if (!enumerator.MoveNext()) { break; } Tuple <Version, ISet <string> > current = enumerator.Current; if (projectOptionalFrameworkName.get_Version() >= current.Item1) { using (IEnumerator <string> enumerator2 = current.Item2.GetEnumerator()) { while (true) { if (!enumerator2.MoveNext()) { break; } string profileName = enumerator2.Current; NetPortableProfile projectFrameworkProfile = this.GetProfile(profileName); if ((projectFrameworkProfile != null) && packageFramework.IsCompatibleWith(projectFrameworkProfile, portableProfileTable)) { return(true); } } } } } } } return(false); }