/// <summary> /// Prints the id and version constraint for a node. /// </summary> /// <remarks>Projects will not display a range.</remarks> public static string GetIdAndRange <TItem>(this GraphNode <TItem> node) { var id = node.GetId(); // Ignore constraints for projects, they are not useful since // only one instance of the id may exist in the graph. if (node.IsPackage()) { // Remove floating versions var range = node.GetVersionRange().ToNonSnapshotRange(); // Print the version range if it has an upper or lower bound to display. if (range.HasLowerBound || range.HasUpperBound) { return($"{id} {range.PrettyPrint()}"); } } return(id); }
/// <summary> /// Prints the id and version of a node. If the version does not exist use the range. /// </summary> /// <remarks>Projects will not display a version or range.</remarks> public static string GetIdAndVersionOrRange <TItem>(this GraphNode <TItem> node) { var id = node.GetId(); // Ignore versions for projects, they are not useful since // only one instance of the id may exist in the graph. if (node.IsPackage()) { var version = node.GetVersionOrDefault(); // Print the version if it exists, otherwise use the id. if (version != null) { return($"{id} {version.ToNormalizedString()}"); } else { // The node was unresolved, use the range instead. return(node.GetIdAndRange()); } } return(id); }