public static bool IsInbox(string frameworkListsPath, NuGetFramework framework, string assemblyName, string assemblyVersion) { if (framework.Framework == FrameworkConstants.FrameworkIdentifiers.UAP || (framework.Framework == FrameworkConstants.FrameworkIdentifiers.NetCore && framework.Version >= FrameworkConstants.CommonFrameworks.NetCore50.Version)) { // UAP & netcore50 or higher are completely OOB, despite being compatible with netcore4x which has inbox assemblies return(false); } // if no version is specified just use 0.0.0.0 to evaluate for any version of the contract Version version = FrameworkUtilities.Ensure4PartVersion(assemblyVersion); FrameworkSet fxs = GetInboxFrameworks(frameworkListsPath); Version latestLegacyVersion = null; fxs.LastNonSemanticVersions.TryGetValue(assemblyName, out latestLegacyVersion); foreach (var fxVersions in fxs.Frameworks.Values) { // Get the nearest compatible framework from this set of frameworks. var nearest = FrameworkUtilities.GetNearest(framework, fxVersions.Select(fx => NuGetFramework.Parse(fx.ShortName)).ToArray()); // If there are not compatible frameworks in the current framework set, there is not going to be a match. if (nearest == null) { continue; } // don't allow PCL to specify inbox for non-PCL framework. if (nearest.IsPCL != framework.IsPCL) { continue; } // find the first version (if any) that supports this contract foreach (var fxVersion in fxVersions) { Version supportedVersion; if (fxVersion.Assemblies.TryGetValue(assemblyName, out supportedVersion)) { if (supportedVersion >= version) { return(true); } // new versions represent API surface via major.minor only, so consider // a contract as supported so long as the latest legacy version is supported // and this contract's major.minor match the latest legacy version. if (supportedVersion == latestLegacyVersion && version.Major == latestLegacyVersion.Major && version.Minor == latestLegacyVersion.Minor) { return(true); } } } } return(false); }
private static Version GetAssemblyVersion(ITaskItem dependency) { // If we don't have the AssemblyVersion metadata (4 part version string), fall back and use Version (3 part version string) string versionString = dependency.GetMetadata("AssemblyVersion"); if (string.IsNullOrEmpty(versionString)) { versionString = dependency.GetMetadata("Version"); } return(FrameworkUtilities.Ensure4PartVersion(versionString)); }
private static Generation ReadGeneration(KeyValuePair <string, JToken> json) { var generation = new Generation() { Version = FrameworkUtilities.Ensure4PartVersion(new Version(json.Key)) }; foreach (var assembly in EachProperty(json.Value["assemblies"])) { generation.Assemblies.Add(assembly.Key, new Version(assembly.Value.ToString())); } return(generation); }
public static bool IsInbox(string frameworkListsPath, string framework, string assemblyName, string assemblyVersion) { // if no version is specified just use 0.0.0.0 to evaluate for any version of the contract Version version = FrameworkUtilities.Ensure4PartVersion(String.IsNullOrEmpty(assemblyVersion) ? new Version(0, 0, 0, 0) : new Version(assemblyVersion)); FrameworkSet fxs = GetInboxFrameworks(frameworkListsPath); Version latestLegacyVersion = null; fxs.LastNonSemanticVersions.TryGetValue(assemblyName, out latestLegacyVersion); foreach (var fxVersions in fxs.Frameworks.Values) { // Get the nearest compatible framework from this set of frameworks. var nearest = FrameworkUtilities.GetNearest(NuGetFramework.Parse(framework), fxVersions.Select(fx => NuGetFramework.Parse(fx.ShortName)).ToArray()); // If there are not compatible frameworks in the current framework set, there is not going to be a match. if (nearest == null) { continue; } var origFramework = NuGetFramework.Parse(framework); // if the nearest compatible frameworks version is greater than the version of the framework we are looking for, this is not going to be a match. if (nearest.Version > origFramework.Version) { continue; } // find the first version (if any) that supports this contract foreach (var fxVersion in fxVersions) { Version supportedVersion; if (fxVersion.Assemblies.TryGetValue(assemblyName, out supportedVersion)) { if (supportedVersion >= version) { return(true); } // new versions represent API surface via major.minor only, so consider // a contract as supported so long as the latest legacy version is supported // and this contract's major.minor match the latest legacy version. if (supportedVersion == latestLegacyVersion && version.Major == latestLegacyVersion.Major && version.Minor == latestLegacyVersion.Minor) { return(true); } } } } return(false); }
private static Version GetAssemblyVersion(ITaskItem dependency) { // If we don't have the AssemblyVersion metadata (4 part version string), fall back and use Version (3 part version string) string versionString = dependency.GetMetadata("AssemblyVersion"); if (string.IsNullOrEmpty(versionString)) { versionString = dependency.GetMetadata("Version"); int prereleaseIndex = versionString.IndexOf('-'); if (prereleaseIndex != -1) { versionString = versionString.Substring(0, prereleaseIndex); } } Version assemblyVersion = FrameworkUtilities.Ensure4PartVersion( String.IsNullOrEmpty(versionString) ? new Version(0, 0, 0, 0) : new Version(versionString)); return(assemblyVersion); }
public bool IsInbox(string assemblyName, NuGetFramework framework, string assemblyVersionString) { Version assemblyVersion = FrameworkUtilities.Ensure4PartVersion(assemblyVersionString); return(IsInbox(assemblyName, framework, assemblyVersion)); }
public IEnumerable <NuGetFramework> GetInboxFrameworks(string assemblyName, string assemblyVersionString) { Version assemblyVersion = FrameworkUtilities.Ensure4PartVersion(assemblyVersionString); return(GetInboxFrameworks(assemblyName, assemblyVersion)); }
public bool IsInbox(string assemblyName, NuGetFramework framework, string assemblyVersionString) { Version assemblyVersion = FrameworkUtilities.Ensure4PartVersion(String.IsNullOrEmpty(assemblyVersionString) ? new Version(0, 0, 0, 0) : new Version(assemblyVersionString)); return(IsInbox(assemblyName, framework, assemblyVersion)); }
public IEnumerable <NuGetFramework> GetInboxFrameworks(string assemblyName, string assemblyVersionString) { Version assemblyVersion = FrameworkUtilities.Ensure4PartVersion(String.IsNullOrEmpty(assemblyVersionString) ? new Version(0, 0, 0, 0) : new Version(assemblyVersionString)); return(GetInboxFrameworks(assemblyName, assemblyVersion)); }