Semver An interface that combines equality and order comparison for the class. This interface provides a type for the and so that separate properties aren't needed for the and of . Compare by the left bound and then by the reversed right bound. Thus wider ranges sort before narrower ones. Finally, sort ranges including prerelease before those not including prerelease. This order is important to the removal of fully contained ranges from since it sorts the ranges and then checks earlier ranges to see if they contain later ranges. Thus, more inclusive ranges need to come first so that the ranges they contain will be removed. Note that the API will never expose this order exactly because contained ranges will not be included in the final . An individual metadata identifier for a semantic version. The metadata for a semantic version is composed of dot ('.') separated identifiers. A valid identifier is a non-empty string of ASCII alphanumeric and hyphen characters ([0-9A-Za-z-]). Metadata identifiers are compared lexically in ASCII sort order. Because is a struct, the default value is a with a value. However, the namespace types do not accept and will not return such a . Invalid metadata identifiers including arbitrary Unicode characters and empty string can currently be produced by the constructor. Such identifiers are compared via an ordinal string comparision. The string value of the metadata identifier. The string value of this metadata identifier or if this is a default . Construct a potentially invalid . The parameter is . This should only be used by the constructor that still accepts illegal values. Constructs a without checking that any of the invariants hold. Used by the parser for performance. This is a create method rather than a constructor to clearly indicate uses of it. The other constructors have not been hidden behind create methods because only constructors are visible to the package users. So they see a class consistently using constructors without any create methods. Private constructor used by . The value for the identifier. Not validated. Unused parameter that differentiates this from the constructor that performs validation. Constructs a valid . The is . The is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens). Constructs a valid . Internal constructor allows changing the parameter name to enable methods using this as part of their metadata identifier validation to match the parameter name to their parameter name. Determines whether two identifiers are equal. if is equal to the this identifier; otherwise . Determines whether the given object is equal to this identifier. if is equal to the this identifier; otherwise . Gets a hash code for this identifier. A hash code for this identifier. Determines whether two identifiers are equal. if the value of is the same as the value of ; otherwise . Determines whether two identifiers are not equal. if the value of is different from the value of ; otherwise . Compares two identifiers and indicates whether this instance precedes, follows, or is equal to the other in sort order. An integer that indicates whether this instance precedes, follows, or is equal to in sort order. Value Condition -1 This instance precedes . 0 This instance is equal to . 1 This instance follows . Identifiers are compared lexically in ASCII sort order. Invalid identifiers are compared via an ordinal string comparision. Compares this identifier to an and indicates whether this instance precedes, follows, or is equal to the object in sort order. An integer that indicates whether this instance precedes, follows, or is equal to in sort order. Value Condition -1 This instance precedes . 0 This instance is equal to . 1 This instance follows or is . is not a . Identifiers are compared lexically in ASCII sort order. Invalid identifiers are compared via an ordinal string comparision. Converts this identifier into an equivalent string value. The string value of this identifier or if this is a default . Converts this identifier into an equivalent string value. The string value of this identifier or if this is a default Parse optional spaces from the beginning of the segment. Parse optional whitespace from the beginning of the segment. Parse a version number from the beginning of the segment. Parse a comparison from the beginning of the segment. Must have leading whitespace removed. Will consume trailing whitespace. When applying caret, tilde, or wildcards to versions already at there are ranges that would be equivalent to being able to increment beyond max value. However, for simplicity, this is treated as an error instead. This also makes sense given that these ranges would logically include versions valid according to the spec that can't be represented by this library due to the limitations of . Finally, if these equivalent ranges were supported they would also need special case handling in the method. The greater than operator taking into account the wildcard. The less than operator taking into account the wildcard. Parsing for The new parsing code was complex enough that is made sense to break out into its own class. The internal method that all parsing is based on. Because this is called by both and it does not throw exceptions, but instead returns the exception that should be thrown by the parse method. For performance when used from try parse, all exception construction and message formatting can be avoided by passing in an exception which will be returned when parsing fails. This does not validate the or parameter values. That must be done in the calling method. An internal method that is used when parsing versions from ranges. Because this is called by both and it does not throw exceptions, but instead returns the exception that should be thrown by the parse method. For performance when used from try parse, all exception construction and message formatting can be avoided by passing in an exception which will be returned when parsing fails. This does not validate the or parameter values. That must be done in the calling method. Options beyond the for version parsing used by range parsing. No special parsing options. Used when parsing versions outside of ranges. Allow wildcards as defined by in the major, minor, and patch version numbers. Allow a wildcard as defined by as the final prerelease identifier. Whether missing minor and patch version numbers allowed by the optional minor and patch options count as being wildcard version numbers. Determines whether any given character is a wildcard character. Approximately equivalent to version. Allows patch updates. Compatible with version. Allows minor and patch updates. Parse a comparison from the beginning of the segment. Must have leading whitespace removed. Will consume trailing whitespace. When applying caret, tilde, or wildcards to versions already at there are ranges that would be equivalent to being able to increment beyond max value. However, for simplicity, this is treated as an error instead. This also makes sense given that these ranges would logically include versions valid according to the spec that can't be represented by this library due to the limitations of . Finally, if these equivalent ranges were supported they would also need special case handling in the method. The method is surprisingly slow. This provides a fast alternative for the enum. Remove a flag from a . An individual prerelease identifier for a semantic version. The prerelease portion of a semantic version is composed of dot ('.') separated identifiers. A prerelease identifier is either an alphanumeric or numeric identifier. A valid numeric identifier is composed of ASCII digits ([0-9]) without leading zeros. A valid alphanumeric identifier is a non-empty string of ASCII alphanumeric and hyphen characters ([0-9A-Za-z-]) with at least one non-digit character. Prerelease identifiers are compared first by whether they are numeric or alphanumeric. Numeric identifiers have lower precedence than alphanumeric identifiers. Numeric identifiers are compared to each other numerically. Alphanumeric identifiers are compared to each other lexically in ASCII sort order. Because is a struct, the default value is a with a value. However, the namespace types do not accept and will not return such a . Invalid prerelease identifiers including arbitrary Unicode characters, empty string, and numeric identifiers with leading zero can currently be produced by the constructor and the obsolete and methods. Such alphanumeric identifiers are compared via an ordinal string comparision. Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015'). The string value of the prerelease identifier even if it is a numeric identifier. The string value of this prerelease identifier even if it is a numeric identifier or if this is a default . Invalid numeric prerelease identifiers with leading zeros will have a string value including the leading zeros. This can be used to distinguish invalid numeric identifiers with different numbers of leading zeros. The numeric value of the prerelease identifier if it is a numeric identifier, otherwise . The numeric value of the prerelease identifier if it is a numeric identifier, otherwise . The numeric value of a prerelease identifier will never be negative. Construct a potentially invalid . The parameter is . This should be used only by the constructor that still accepts illegal values. Construct a without checking that any of the invariants hold. Used by the parser for performance. This is a create method rather than a constructor to clearly indicate uses of it. The other constructors have not been hidden behind create methods because only constructors are visible to the package users. So they see a class consistently using constructors without any create methods. Private constructor used by . Constructs a valid . The string value of this prerelease identifier. Whether to allow leading zeros in the parameter. If , leading zeros will be allowed on numeric identifiers but will be removed. The is . The is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens) or has leading zeros for a numeric identifier when is . The numeric identifier value is too large for . Because a valid numeric identifier does not have leading zeros, this constructor will never create a with leading zeros even if is . Any leading zeros will be removed. Constructs a valid . Internal constructor allows changing the parameter name to enable methods using this as part of their prerelease identifier validation to match the parameter name to their parameter name. Construct a valid numeric from an integer value. The is negative. The non-negative value of this identifier. Determines whether two identifiers are equal. if is equal to the this identifier; otherwise . Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015'). Determines whether the given object is equal to this identifier. if is equal to the this identifier; otherwise . Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015'). Gets a hash code for this identifier. A hash code for this identifier. Numeric identifiers with leading zeros are have the same hash code (e.g. '15' has the same hash code as '015'). Determines whether two identifiers are equal. if the value of is the same as the value of ; otherwise . Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015'). Determines whether two identifiers are not equal. if the value of is different from the value of ; otherwise . Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015'). Compares two identifiers and indicates whether this instance precedes, follows, or is equal to the other in precedence order. An integer that indicates whether this instance precedes, follows, or is equal to in precedence order. Value Condition -1 This instance precedes . 0 This instance is equal to . 1 This instance follows . Numeric identifiers have lower precedence than alphanumeric identifiers. Numeric identifiers are compared numerically. Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015'). Alphanumeric identifiers are compared lexically in ASCII sort order. Invalid alphanumeric identifiers are compared via an ordinal string comparision. Compares this identifier to an and indicates whether this instance precedes, follows, or is equal to the object in precedence order. An integer that indicates whether this instance precedes, follows, or is equal to in precedence order. Value Condition -1 This instance precedes . 0 This instance is equal to . 1 This instance follows or is . is not a . Numeric identifiers have lower precedence than alphanumeric identifiers. Numeric identifiers are compared numerically. Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015'). Alphanumeric identifiers are compared lexically in ASCII sort order. Invalid alphanumeric identifiers are compared via an ordinal string comparision. Converts this identifier into an equivalent string value. The string value of this identifier or if this is a default Converts this identifier into an equivalent string value. The string value of this identifier or if this is a default A range of versions that is bounded only on the left. That is a range defined by some version x such that x < v or x <= v depending on whether it is inclusive. A left-bounded range forms the lower limit for a version range. An "unbounded" left-bounded range is represented by a lower bound of since compares as less than all versions. However, it does not allow such ranges to be inclusive because a range cannot contain null. The (i.e. 0.0.0-0) cannot be used instead because it would be inclusive of prerelease. A range of versions that is bounded only on the right. That is a range defined by some version x such that v < x or v <= x depending on whether it is inclusive. A right-bounded range forms the upper limit for a version range. An "unbounded" right-bounded range is represented by an inclusive upper bound of . Whether this bound actually includes any prerelease versions. A non-inclusive bound of X.Y.Z-0 doesn't actually include any prerelease versions. A semantic version number. Conforms with v2.0.0 of semantic versioning (semver.org). Deserialize a . The parameter is null. Populates a with the data needed to serialize the target object. The to populate with data. The destination (see ) for this serialization. Constructs a new instance of the class. The major version number. Constructs a new instance of the class. The major version number. The minor version number. Constructs a new instance of the class. The major version number. The minor version number. The patch version number. Constructs a new instance of the class. The major version number. The minor version number. The patch version number. The prerelease portion (e.g. "alpha.5"). The build metadata (e.g. "nightly.232"). Constructs a new instance of the class. The major version number. The minor version number. The patch version number. The prerelease identifiers. The build metadata identifiers. A , , or version number is negative. A prerelease or metadata identifier has the default value. Constructs a new instance of the class. The major version number. The minor version number. The patch version number. The prerelease identifiers. The build metadata identifiers. A , , or version number is negative. One of the prerelease or metadata identifiers is . A prerelease identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens) or has leading zeros for a numeric identifier. Or, a metadata identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens). A numeric prerelease identifier value is too large for . Create a new instance of the class. Parses prerelease and metadata identifiers from dot separated strings. If parsing is not needed, use a constructor instead. The major version number. The minor version number. The patch version number. The prerelease portion (e.g. "alpha.5"). The build metadata (e.g. "nightly.232"). Allow leading zeros in numeric prerelease identifiers. Leading zeros will be removed. A , , or version number is negative. A prerelease identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens) or has leading zeros for a numeric identifier when is . Or, a metadata identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens). A numeric prerelease identifier value is too large for . Constructs a new instance of the class from a . used to initialize the major, minor, and patch version numbers and the build metadata. The is null. Constructs a with the same major and minor version numbers. The patch version number will be the fourth component of the . The build meta data will contain the third component of the if it is greater than zero. Construct a from its proper parts. Parameter validation is not performed. The , , and version numbers must not be negative. The and must not be or contain invalid values and must be immutable. The and must not be null and must be equal to the corresponding identifiers. Converts a into the equivalent semantic version. The version to be converted to a semantic version. The equivalent semantic version. is . has a revision number greater than zero. numbers have the form major.minor[.build[.revision]] where square brackets ('[' and ']') indicate optional components. The first three parts are converted to the major, minor, and patch version numbers of a semantic version. If the build component is not defined (-1), the patch number is assumed to be zero. numbers with a revision greater than zero cannot be converted to semantic versions. An is thrown when this method is called with such a . Converts this semantic version to a . The equivalent . The semantic version is a prerelease version or has build metadata or has a negative major, minor, or patch version number. A semantic version of the form major.minor.patch is converted to a of the form major.minor.build where the build number is the patch version of the semantic version. Prerelease versions and build metadata are not representable in a . This method throws an if the semantic version is a prerelease version or has build metadata. Converts the string representation of a semantic version to its equivalent. The version string. A bitwise combination of enumeration values that indicates the style elements that can be present in . The preferred value to use is . The maximum length of that should be parsed. This prevents attacks using very long version strings. is not a valid value. is . The is invalid or not in a format compliant with . A numeric part of is too large for an . Converts the string representation of a semantic version to its equivalent. The version string. If set to , minor and patch version are required; otherwise they are optional. The is . The has an invalid format. The is missing minor or patch version numbers when is . The major, minor, or patch version number is larger than . Converts the string representation of a semantic version to its equivalent. The return value indicates whether the conversion succeeded. The version string. A bitwise combination of enumeration values that indicates the style elements that can be present in . The preferred value to use is . When this method returns, contains a instance equivalent to the version string passed in, if the version string was valid, or if the version string was invalid. The maximum length of that should be parsed. This prevents attacks using very long version strings. when an invalid version string is passed, otherwise . is not a valid value. Converts the string representation of a semantic version to its equivalent. The return value indicates whether the conversion succeeded. The version string. When this method returns, contains a instance equivalent to the version string passed in, if the version string was valid, or if the version string was invalid. If set to , minor and patch version numbers are required; otherwise they are optional. when an invalid version string is passed, otherwise . Compares two versions and indicates whether the first precedes, follows, or is equal to the other in the sort order. Note that sort order is more specific than precedence order. An integer that indicates whether precedes, follows, or is equal to in the sort order. Value Condition Less than zero precedes in the sort order. Zero is equal to . Greater than zero follows in the sort order or is . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Make a copy of the current instance with changed properties. The value to replace the major version number or to leave it unchanged. The value to replace the minor version number or to leave it unchanged. The value to replace the patch version number or to leave it unchanged. The value to replace the prerelease portion or to leave it unchanged. The value to replace the build metadata or to leave it unchanged. The new version with changed properties. The change method is intended to be called using named argument syntax, passing only those fields to be changed. To change only the patch version: var changedVersion = version.Change(patch: 4); Creates a copy of the current instance with multiple changed properties. If changing only one property use one of the more specific WithX() methods. The value to replace the major version number or to leave it unchanged. The value to replace the minor version number or to leave it unchanged. The value to replace the patch version number or to leave it unchanged. The value to replace the prerelease identifiers or to leave it unchanged. The value to replace the build metadata identifiers or to leave it unchanged. The new version with changed properties. A , , or version number is negative. A prerelease or metadata identifier has the default value. A numeric prerelease identifier value is too large for . The method is intended to be called using named argument syntax, passing only those fields to be changed. To change the minor and patch versions: var modifiedVersion = version.With(minor: 2, patch: 4); Creates a copy of the current instance with multiple changed properties. Parses prerelease and metadata identifiers from dot separated strings. Use instead if parsing is not needed. If changing only one property use one of the more specific WithX() methods. The value to replace the major version number or to leave it unchanged. The value to replace the minor version number or to leave it unchanged. The value to replace the patch version number or to leave it unchanged. The value to replace the prerelease identifiers or to leave it unchanged. The value to replace the build metadata identifiers or to leave it unchanged. Allow leading zeros in numeric prerelease identifiers. Leading zeros will be removed. The new version with changed properties. A , , or version number is negative. A prerelease identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens) or has leading zeros for a numeric identifier when is . Or, a metadata identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens). A numeric prerelease identifier value is too large for . The method is intended to be called using named argument syntax, passing only those fields to be changed. To change the patch version and prerelease identifiers version: var modifiedVersion = version.WithParsedFrom(patch: 4, prerelease: "alpha.5"); Creates a copy of the current instance with a different major version number. The value to replace the major version number. The new version with the different major version number. is negative. Creates a copy of the current instance with a different minor version number. The value to replace the minor version number. The new version with the different minor version number. is negative. Creates a copy of the current instance with a different patch version number. The value to replace the patch version number. The new version with the different patch version number. is negative. Creates a copy of the current instance with a different prerelease portion. The value to replace the prerelease portion. Whether to allow leading zeros in the prerelease identifiers. If , leading zeros will be allowed on numeric identifiers but will be removed. The new version with the different prerelease identifiers. is . A prerelease identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens) or has leading zeros for a numeric identifier when is . A numeric prerelease identifier value is too large for . Because a valid numeric identifier does not have leading zeros, this constructor will never create a with leading zeros even if is . Any leading zeros will be removed. Creates a copy of the current instance with different prerelease identifiers. The first identifier to replace the existing prerelease identifiers. The rest of the identifiers to replace the existing prerelease identifiers. The new version with the different prerelease identifiers. or is or one of the prerelease identifiers is . A prerelease identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens) or has leading zeros for a numeric identifier. A numeric prerelease identifier value is too large for . Creates a copy of the current instance with different prerelease identifiers. The identifiers to replace the prerelease identifiers. The new version with the different prerelease identifiers. is or one of the prerelease identifiers is . A prerelease identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens) or has leading zeros for a numeric identifier. A numeric prerelease identifier value is too large for . Creates a copy of the current instance with different prerelease identifiers. The first identifier to replace the existing prerelease identifiers. The rest of the identifiers to replace the existing prerelease identifiers. The new version with the different prerelease identifiers. is . A prerelease identifier has the default value. Creates a copy of the current instance with different prerelease identifiers. The identifiers to replace the prerelease identifiers. The new version with the different prerelease identifiers. is . A prerelease identifier has the default value. Creates a copy of the current instance without prerelease identifiers. The new version without prerelease identifiers. Creates a copy of the current instance with different build metadata. The value to replace the build metadata. The new version with the different build metadata. is . A metadata identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens). Creates a copy of the current instance with different build metadata identifiers. The first identifier to replace the existing build metadata identifiers. The rest of the build metadata identifiers to replace the existing build metadata identifiers. The new version with the different build metadata identifiers. or is or one of the metadata identifiers is . A metadata identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens). Creates a copy of the current instance with different build metadata identifiers. The identifiers to replace the build metadata identifiers. The new version with the different build metadata identifiers. is or one of the metadata identifiers is . A metadata identifier is empty or contains invalid characters (i.e. characters that are not ASCII alphanumerics or hyphens). Creates a copy of the current instance with different build metadata identifiers. The first identifier to replace the existing build metadata identifiers. The rest of the identifiers to replace the existing build metadata identifiers. is . A metadata identifier has the default value. Creates a copy of the current instance with different build metadata identifiers. The identifiers to replace the build metadata identifiers. The new version with the different build metadata identifiers. is . A metadata identifier has the default value. Creates a copy of the current instance without build metadata. The new version without build metadata. Creates a copy of the current instance without prerelease identifiers or build metadata. The new version without prerelease identifiers or build metadata. The major version number. The major version number. An increase in the major version number indicates a backwards incompatible change. The minor version number. The minor version number. An increase in the minor version number indicates backwards compatible changes. The patch version number. The patch version number. An increase in the patch version number indicates backwards compatible bug fixes. The prerelease identifiers for this version. The prerelease identifiers for this version or empty string if this is a release version. A prerelease version is denoted by appending a hyphen ('-') and a series of dot separated identifiers immediately following the patch version number. Each prerelease identifier may be numeric or alphanumeric. Valid numeric identifiers consist of ASCII digits ([0-9]) without leading zeros. Valid alphanumeric identifiers are non-empty strings of ASCII alphanumeric and hyphen characters ([0-9A-Za-z-]) with at least one non-digit character. Prerelease versions have lower precedence than release versions. Prerelease version precedence is determined by comparing each prerelease identifier in order from left to right. Numeric identifiers have lower precedence than alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. The prerelease identifiers for this version. The prerelease identifiers for this version or empty if this is a release version. A prerelease version is denoted by appending a hyphen ('-') and a series of dot separated identifiers immediately following the patch version number. Each prerelease identifier may be numeric or alphanumeric. Valid numeric identifiers consist of ASCII digits ([0-9]) without leading zeros. Valid alphanumeric identifiers are non-empty strings of ASCII alphanumeric and hyphen characters ([0-9A-Za-z-]) with at least one non-digit character. Prerelease versions have lower precedence than release versions. Prerelease version precedence is determined by comparing each prerelease identifier in order from left to right. Numeric identifiers have lower precedence than alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. Whether this is a prerelease version where the prerelease version is zero (i.e. "-0"). Whether this is a prerelease version. Whether this is a prerelease version. A semantic version with prerelease identifiers is a prerelease version. When this is , the and properties are non-empty. When this is , the property will be an empty string and the will be an empty collection. Whether this is a release version. Whether this is a release version. A semantic version without prerelease identifiers is a release version. When this is , the property will be an empty string and the will be an empty collection. When this is , the and properties are non-empty. The build metadata for this version. The build metadata for this version or empty string if there is no build metadata. The build metadata is a series of dot separated identifiers separated from the rest of the version number with a plus sign ('+'). Valid metadata identifiers are non-empty and consist of ASCII alphanumeric characters and hyphens ([0-9A-Za-z-]). The metadata does not affect precedence. Two version numbers differing only in build metadata have the same precedence. However, metadata does affect sort order. An otherwise identical version without metadata sorts before one that has metadata. The build metadata for this version. The build metadata for this version or empty string if there is no metadata. The build metadata is a series of dot separated identifiers separated from the rest of the version number with a plus sign ('+'). Valid metadata identifiers are non-empty and consist of ASCII alphanumeric characters and hyphens ([0-9A-Za-z-]). The metadata does not affect precedence. Two version numbers differing only in build metadata have the same precedence. However, metadata does affect sort order. An otherwise identical version without metadata sorts before one that has metadata. The build metadata identifiers for this version. The build metadata identifiers for this version or empty if there is no metadata. The build metadata is a series of dot separated identifiers separated from the rest of the version number with a plus sign ('+'). Valid metadata identifiers are non-empty and consist of ASCII alphanumeric characters and hyphens ([0-9A-Za-z-]). The metadata does not affect precedence. Two version numbers differing only in build metadata have the same precedence. However, metadata does affect sort order. An otherwise identical version without metadata sorts before one that has metadata. Converts this version to an equivalent string value. The equivalent of this version. Determines whether two semantic versions are equal. if the two versions are equal, otherwise . Two versions are equal if every part of the version numbers are equal. Thus two versions with the same precedence may not be equal. Determines whether the given object is equal to this version. if is equal to the this version; otherwise . Two versions are equal if every part of the version numbers are equal. Thus two versions with the same precedence may not be equal. Determines whether two semantic versions are equal. if is equal to the this version; otherwise . Two versions are equal if every part of the version numbers are equal. Thus two versions with the same precedence may not be equal. Determines whether two semantic versions have the same precedence. Versions that differ only by build metadata have the same precedence. The semantic version to compare to. if the version precedences are equal, otherwise . Determines whether two semantic versions have the same precedence. Versions that differ only by build metadata have the same precedence. if the version precedences are equal, otherwise . Determines whether two semantic versions have the same precedence. Versions that differ only by build metadata have the same precedence. The semantic version to compare to. if the version precedences are equal. Gets a hash code for this instance. A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. Two versions are equal if every part of the version numbers are equal. Thus two versions with the same precedence may not have the same hash code. Determines whether two semantic versions are equal. if the two versions are equal, otherwise . Two versions are equal if every part of the version numbers are equal. Thus two versions with the same precedence may not be equal. Determines whether two semantic versions are not equal. if the two versions are not equal, otherwise . Two versions are equal if every part of the version numbers are equal. Thus two versions with the same precedence may not be equal. An and that compares by precedence. This can be used for sorting, binary search, and using as a dictionary key. A precedence comparer that implements and for . Precedence order is determined by comparing the major, minor, patch, and prerelease portion in order from left to right. Versions that differ only by build metadata have the same precedence. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. An and that compares by sort order. This can be used for sorting, binary search, and using as a dictionary key. A sort order comparer that implements and for . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions and indicates whether this instance precedes, follows, or is in the same position as the other in the precedence order. Versions that differ only by build metadata have the same precedence. An integer that indicates whether this instance precedes, follows, or is in the same position as in the precedence order. Value Condition -1 This instance precedes in the precedence order. 0 This instance has the same precedence as . 1 This instance follows in the precedence order or is . Precedence order is determined by comparing the major, minor, patch, and prerelease portion in order from left to right. Versions that differ only by build metadata have the same precedence. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions and indicates whether this instance precedes, follows, or is equal to the other in the sort order. Note that sort order is more specific than precedence order. An integer that indicates whether this instance precedes, follows, or is equal to the other in the sort order. Value Condition -1 This instance precedes the other in the sort order. 0 This instance is equal to the other. 1 This instance follows the other in the sort order or the other is . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions and indicates whether the first precedes, follows, or is in the same position as the second in the precedence order. Versions that differ only by build metadata have the same precedence. An integer that indicates whether precedes, follows, or is in the same position as in the precedence order. Value Condition -1 precedes in the precedence order or is . 0 has the same precedence as . 1 follows in the precedence order or is . Precedence order is determined by comparing the major, minor, patch, and prerelease portion in order from left to right. Versions that differ only by build metadata have the same precedence. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions and indicates whether the first precedes, follows, or is equal to the second in the sort order. Note that sort order is more specific than precedence order. An integer that indicates whether precedes, follows, or is equal to in the sort order. Value Condition -1 precedes in the sort order or is . 0 is equal to . 1 follows in the sort order or is . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares this version to an and indicates whether this instance precedes, follows, or is equal to the object in the sort order. Note that sort order is more specific than precedence order. An integer that indicates whether this instance precedes, follows, or is equal to the other in the sort order. Value Condition Less than zero This instance precedes the other in the sort order. Zero This instance is equal to the other. Greater than zero This instance follows the other in the sort order or the other is . The is not a . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions and indicates whether this instance precedes, follows, or is equal to the other in the sort order. Note that sort order is more specific than precedence order. An integer that indicates whether this instance precedes, follows, or is equal to the other in the sort order. Value Condition Less than zero This instance precedes the other in the sort order. Zero This instance is equal to the other. Greater than zero This instance follows the other in the sort order or the other is . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions and indicates whether this instance precedes, follows, or is in the same position as the other in the precedence order. Versions that differ only by build metadata have the same precedence. An integer that indicates whether this instance precedes, follows, or is in the same position as in the precedence order. Value Condition Less than zero This instance precedes in the precedence order. Zero This instance has the same precedence as . Greater than zero This instance follows in the precedence order or is . Precedence order is determined by comparing the major, minor, patch, and prerelease portion in order from left to right. Versions that differ only by build metadata have the same precedence. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions by sort order. Note that sort order is more specific than precedence order. if follows in the sort order; otherwise . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions by sort order. Note that sort order is more specific than precedence order. if follows or is equal to in the sort order; otherwise . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions by sort order. Note that sort order is more specific than precedence order. if precedes in the sort order; otherwise . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Compares two versions by sort order. Note that sort order is more specific than precedence order. if precedes or is equal to in the sort order; otherwise . Sort order is consistent with precedence order, but provides an order for versions with the same precedence. Sort order is determined by comparing the major, minor, patch, prerelease portion, and build metadata in order from left to right. The major, minor, and patch version numbers are compared numerically. A prerelease version precedes a release version. The prerelease portion is compared by comparing each prerelease identifier from left to right. Numeric prerelease identifiers precede alphanumeric identifiers. Numeric identifiers are compared numerically. Alphanumeric identifiers are compared lexically in ASCII sort order. A longer series of prerelease identifiers follows a shorter series if all the preceding identifiers are equal. Otherwise equal versions without build metadata precede those with metadata. The build metadata is compared by comparing each metadata identifier. Identifiers are compared lexically in ASCII sort order. A longer series of metadata identifiers follows a shorter series if all the preceding identifiers are equal. Checks if this version satisfies the given predicate. The predicate to evaluate on this version. if the version satisfies the predicate, otherwise . is . Checks if this version is contained in the given range. The range to evaluate. if the version is contained in the range, otherwise . is . Checks if this version is contained in the given unbroken range. The unbroken range to evaluate. if the version is contained in the range, otherwise . is . Checks if this version is contained in the given range. The range to parse and evaluate. A bitwise combination of enumeration values that indicates the style elements that can be present in . The overload without this parameter defaults to . The maximum length of that should be parsed. This prevents attacks using very long range strings. if the version is contained in the range, otherwise . is . is not a valid value. is less than zero. The is invalid or not in a format compliant with . A numeric part of a version in is too large for an . If checks against a range will be performed repeatedly, it is much more efficient to parse the range into a once and use that object to repeatedly check for containment. Checks if this version is contained in the given range. The range is parsed using . The range to parse and evaluate. The maximum length of that should be parsed. This prevents attacks using very long range strings. if the version is contained in the range, otherwise . is . is less than zero. The is invalid or not in a format compliant with . A numeric part of a version in is too large for an . If checks against a range will be performed repeatedly, it is much more efficient to parse the range into a once and use that object to repeatedly check for containment. Checks if this version is contained in the given range in npm format. The npm format range to parse and evaluate. Whether to include all prerelease versions satisfying the bounds in the range or to only include prerelease versions when it matches a bound that explicitly includes prerelease versions. The maximum length of that should be parsed. This prevents attacks using very long range strings. if the version is contained in the range, otherwise . is . is less than zero. The is invalid. A numeric part of a version in is too large for an . If checks against a range will be performed repeatedly, it is much more efficient to parse the range into a once using and use that object to repeatedly check for containment. Checks if this version is contained in the given range in npm format. Does not include all prerelease when parsing the range. The npm format range to parse and evaluate. The maximum length of that should be parsed. This prevents attacks using very long range strings. if the version is contained in the range, otherwise . is . is less than zero. The is invalid. A numeric part of a version in is too large for an . If checks against a range will be performed repeatedly, it is much more efficient to parse the range into a once using and use that object to repeatedly check for containment. Implicit conversion from to . The semantic version. The object. The is . The version number has an invalid format. The major, minor, or patch version number is larger than . A range of values. A range can have gaps in it and may include only some prerelease versions between included release versions. For a range that cannot have gaps see the class. The empty range that contains no versions. The empty range that contains no versions. The range that contains all release versions but no prerelease versions. The range that contains all release versions but no prerelease versions. The range that contains both all release and prerelease versions. The range that contains both all release and prerelease versions. Construct a range containing only a single version. The version the range should contain. A range containing only the given version. Construct a range containing versions greater than the given version. The range will contain all versions greater than this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions greater than the given version. Construct a range containing versions equal to or greater than the given version. The range will contain all versions greater than or equal to this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions greater than or equal to the given version. Construct a range containing versions less than the given version. The range will contain all versions less than this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions less than the given version. Construct a range containing versions equal to or less than the given version. The range will contain all versions less than or equal to this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions less than or equal to the given version. Construct a range containing all versions between the given versions including those versions. The range will contain only versions greater than or equal to this. The range will contain only versions less than or equal to this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including those versions. Construct a range containing all versions between the given versions including the start but not the end. The range will contain only versions greater than or equal to this. The range will contain only versions less than this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including the start but not the end. Construct a range containing all versions between the given versions including the end but not the start. The range will contain only versions greater than this. The range will contain only versions less than or equal to this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including the end but not the start. Construct a range containing all versions between the given versions excluding those versions. The range will contain only versions greater than this. The range will contain only versions less than this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including the end but not the start. Ownership of the list must be given to this method. The list will be mutated and used as the basis of an immutable list. It must not still be referenced by the caller. Construct a range that joins the given s. It will contain all versions contained by any of the given unbroken ranges. The unbroken ranges to join into a single range. A range that joins the given s. It will contain all versions contained by any of the given unbroken ranges. The unbroken ranges are simplified and sorted. So, the resulting may not contain the same number of s in the same order as passed to this method. Construct a range that joins the given s. It will contain all versions contained by any of the given unbroken ranges. The unbroken ranges to join into a single range. A range that joins the given s. It will contain all versions contained by any of the given unbroken ranges. The unbroken ranges are simplified and sorted. So, the resulting may not contain the same number of s in the same order as passed to this method. Parameter validation is not performed. The unbroken range must not be empty. Parameter validation is not performed. The must be an immutable list of properly ordered and combined ranges. Determine whether this range contains the given version. The version to test against the range. if the version is contained in the range, otherwise . Convert this range into a predicate function indicating whether a version is contained in the range. The range to convert into a predicate function. A predicate that indicates whether a given version is contained in this range. Convert a version range string in the standard range syntax into a using the given options. The version range string to parse. Accepts the standard range syntax. A bitwise combination of enumeration values that indicates the style elements that can be present in and the options to use when constructing the range. The maximum length of that should be parsed. This prevents attacks using very long version range strings. is not a valid value. is less than zero. is . The is invalid or not in a format compliant with . A numeric part of a version in is too large for an . Convert a version range string in the standard range syntax into a using the option. The version range string to parse. Accepts the standard range syntax. The maximum length of that should be parsed. This prevents attacks using very long version range strings. is less than zero. is . The is invalid or not in a format compliant with the option. A numeric part of a version in is too large for an . Convert a version range string in the standard range syntax into a using the given options. The version range string to parse. Accepts the standard range syntax. A bitwise combination of enumeration values that indicates the style elements that can be present in and the options to use when constructing the range. The converted . The maximum length of that should be parsed. This prevents attacks using very long version range strings. when an invalid version range string is passed, otherwise . is not a valid value. is less than zero. Convert a version range string in the standard range syntax into a using the option. The version range string to parse. Accepts the standard range syntax. The converted . The maximum length of that should be parsed. This prevents attacks using very long version range strings. when an invalid version range string is passed, otherwise . is less than zero. Convert a version range string in the npm syntax into a . The version range string to parse. Accepts the npm syntax. Whether to include all prerelease versions in the range rather than just prerelease versions matching a prerelease identifier in the range. The maximum length of that should be parsed. This prevents attacks using very long version range strings. is less than zero. is . The is invalid. A numeric part of a version in is too large for an . The npm "loose" option is not supported. The method provides more control over parsing. However, it does not accept all of the npm syntax. Convert a version range string in the npm syntax into a . The version range string to parse. Accepts the npm syntax. The maximum length of that should be parsed. This prevents attacks using very long version range strings. is less than zero. is . The is invalid. A numeric part of a version in is too large for an . The npm "loose" option is not supported. The method provides more control over parsing. However, it does not accept all of the npm syntax. Convert a version range string in the npm syntax into a . The version range string to parse. Accepts the npm syntax. Whether to include all prerelease versions in the range rather than just prerelease versions matching a prerelease identifier in the range. The converted . The maximum length of that should be parsed. This prevents attacks using very long version range strings. when an invalid version range string is passed, otherwise . is less than zero. The npm "loose" option is not supported. The method provides more control over parsing. However, it does not accept all of the npm syntax. Convert a version range string in the npm syntax into a . The version range string to parse. Accepts the npm syntax. The converted . The maximum length of that should be parsed. This prevents attacks using very long version range strings. when an invalid version range string is passed, otherwise . is less than zero. The npm "loose" option is not supported. The method provides more control over parsing. However, it does not accept all of the npm syntax. The number of s that make up this range. The number of s that make up this range. Get the making up this range at the given index. The zero-based index of the to get. The making up this range at the given index. Get an enumerator that iterates through the s making up this range. An enumerator that iterates through the s making up this range. Get an enumerator that iterates through the s making up this range. An enumerator that iterates through the s making up this range. Determines whether two version ranges are equal. Due to the complexity of ranges, it may be possible for two ranges to match the same set of versions but be expressed in different ways and so not be equal. if is equal to the this range; otherwise . Determines whether the given object is equal to this range. Due to the complexity of ranges, it may be possible for two ranges to match the same set of versions but be expressed in different ways and so not be equal. if is equal to the this range; otherwise . Gets a hash code for this instance. A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. Determines whether two version ranges are equal. Due to the complexity of ranges, it may be possible for two ranges to match the same set of versions but be expressed in different ways and so not be equal. if the two values are equal, otherwise . Determines whether two version ranges are not equal. Due to the complexity of ranges, it may be possible for two ranges to match the same set of versions but be expressed in different ways and so not be equal. if the two ranges are not equal, otherwise . Converts this version range to an equivalent string value in standard range syntax. The equivalent of this version in standard range syntax. Because version ranges are simplified and sorted, this method may return a different, but equivalent, range string from the originally parsed one. Ranges including all prerelease versions are indicated with the idiom of prefixing each comparison group with "*-*". This includes all prerelease versions because it matches all prerelease versions. Determines the parsing options and allowed styles of range and version strings passed to the and methods. These styles only affect which strings are accepted when parsing. The constructed ranges and version numbers are valid semantic version ranges without any of the optional features in the original string. Most options only allow additional version styles. However, the option modifies how version ranges are interpreted. With this option, all prerelease versions within the range bounds will be considered to be in the range. Without this option, only prerelease versions where one comparison with the same major, minor, and patch versions is prerelease will satisfy the range. For more information, see the range expressions documentation. This enumeration supports a bitwise combination of its member values (e.g. SemVersionRangeOptions.OptionalPatch | SemVersionRangeOptions.AllowV). Accept versions strictly conforming to the SemVer 2.0 spec without metadata. Allow leading zeros on major, minor, patch, and prerelease version numbers. Leading zeros will be removed from the constructed version number. Allow a leading lowercase "v" on versions. Allow a leading uppercase "V" on versions. Allow a leading "v" or "V" on versions. Patch version number is optional on versions. Minor and patch version numbers are optional on versions. Include all prerelease versions in the range rather than just prerelease versions matching a prerelease identifier in the range. Allow version numbers with build metadata in version range expressions. The metadata will be removed/ignored for the definition of the version range. Accept any version string format supported. The formats accepted by this style will change if/when more formats are supported. The method is surprisingly slow. This provides a fast alternative for the enum. Determines the styles that are allowed in version strings passed to the and methods. These styles only affect which strings are accepted when parsing. The constructed version numbers are valid semantic versions without any of the optional features in the original string. This enumeration supports a bitwise combination of its member values (e.g. SemVersionStyles.AllowWhitespace | SemVersionStyles.AllowV). Accept version strings strictly conforming to the SemVer 2.0 spec. Allow leading zeros on major, minor, patch, and prerelease version numbers. Leading zeros will be removed from the constructed version number. Allow leading whitespace. When combined with leading "v", the whitespace must come before the "v". Allow trailing whitespace. Allow leading and/or trailing whitespace. When combined with leading "v", the leading whitespace must come before the "v". Allow a leading lowercase "v". Allow a leading uppercase "V". Allow a leading "v" or "V". Patch version number is optional. Minor and patch version numbers are optional. Accept any version string format supported. The formats accepted by this style will change if/when more formats are supported. The method is surprisingly slow. This provides a fast alternative for the enum. A range of values with no gaps. The more general and flexible range class is typically used instead. It combines multiple s. can be used directly if it is important to reflect that something must be a range with no gaps in it. An is represented as an interval between two versions, the and . For each, that version may or may not be included. A standard representation for the empty range that contains no versions. A standard representation for the empty range that contains no versions. There are an infinite number of ways to represent the empty range. Any range where the start is greater than the end or where start equals end but one is not inclusive would be empty. See https://en.wikipedia.org/wiki/Interval_(mathematics)#Classification_of_intervals Since all objects have a and , the only unique empty range is the one whose start is the max version and end is the minimum version. The range that contains all release versions but no prerelease versions. The range that contains all release versions but no prerelease versions. The range that contains both all release and prerelease versions. The range that contains both all release and prerelease versions. Construct a range containing only a single version. The version the range should contain. A range containing only the given version. Construct a range containing versions greater than the given version. The range will contain all versions greater than this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions greater than the given version. Construct a range containing versions equal to or greater than the given version. The range will contain all versions greater than or equal to this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions greater than or equal to the given version. Construct a range containing versions less than the given version. The range will contain all versions less than this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions less than the given version. Construct a range containing versions equal to or less than the given version. The range will contain all versions less than or equal to this. Include all prerelease versions in the range rather than just those matching the given version if it is prerelease. A range containing versions less than or equal to the given version. Construct a range containing all versions between the given versions including those versions. The range will contain only versions greater than or equal to this. The range will contain only versions less than or equal to this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including those versions. Construct a range containing all versions between the given versions including the start but not the end. The range will contain only versions greater than or equal to this. The range will contain only versions less than this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including the start but not the end. Construct a range containing all versions between the given versions including the end but not the start. The range will contain only versions greater than this. The range will contain only versions less than or equal to this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including the end but not the start. Construct a range containing all versions between the given versions excluding those versions. The range will contain only versions greater than this. The range will contain only versions less than this. Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease. A range containing versions between the given versions including the end but not the start. If this and those prerelease versions are entirely covered by the left and right bounds so that effectively, it doesn't need to include all prerelease. The start, left limit, or minimum of this range. Can be . The start or left end of this range. Can be . Ranges with no lower bound have a value of . This ensures that they do not unintentionally include any prerelease versions. Whether this range includes the value. Whether this range includes the value. When is , will always be . The end, right limit, or maximum of this range. Cannot be null. The end, right limit, or maximum of this range. Cannot be null. Whether this range includes the value. Whether this range includes the value. Whether this range includes all prerelease versions between and . If is then prerelease versions matching the major, minor, and patch version of the or will be included only if that end is a prerelease version. Determine whether this range contains the given version. The version to test against the range. if the version is contained in the range, otherwise . Convert this range into a predicate function indicating whether a version is contained in the range. The range to convert into a predicate function. A predicate that indicates whether a given version is contained in this range. Determines whether two version ranges are equal. if is equal to the this range; otherwise . Determines whether the given object is equal to this range. if is equal to the this range; otherwise . Gets a hash code for this instance. A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. Determines whether two version ranges are equal. if the two values are equal, otherwise . Determines whether two version ranges are not equal. Due to the complexity of ranges, it may be possible for two ranges to match the same set of versions but be expressed in different ways and so not be equal. if the two ranges are not equal, otherwise . Converts this version range to an equivalent string value in standard range syntax. The equivalent of this version in standard range syntax. Ranges including all prerelease versions are indicated with the idiom of prefixing with "*-*". This includes all prerelease versions because it matches all prerelease versions. Whether this range contains the other. For this to be the case, it must contain all the versions accounting for which prerelease versions are in each range. Try to union this range with the other. This is a complex operation because it must account for prerelease versions that may be accepted at the endpoints of the ranges. Is this character an ASCII digit '0' through '9' Is this character and ASCII alphabetic character or hyphen [A-Za-z-] Combine hash codes in a good way since System.HashCode isn't available. Algorithm based on HashHelpers previously used in the core CLR. https://github.com/dotnet/coreclr/blob/456afea9fbe721e57986a21eb3b4bb1c9c7e4c56/src/System.Private.CoreLib/shared/System/Numerics/Hashing/HashHelpers.cs The class allows for the various conditional checks done only in debug builds to not count against the code coverage metrics. When using a preprocessor conditional block, the contained lines are not covered by the unit tests (see example below). This is expected because the conditions should not be reachable. But it makes it difficult to evaluate at a glance whether full code coverage has been reached. #if DEBUG if(condition) throw new Exception("..."); #endif This check ensures that an exception hasn't been constructed, but rather something always returns . Methods for working with the strings that make up identifiers Compare two strings as they should be compared as identifiers. This enforces ordinal comparision. It also fixes a technically correct but odd thing where the comparision result can be a number other than -1, 0, or 1. The number of digits in a non-negative number. Returns 1 for all negative numbers. That is ok because we are using it to calculate string length for a for numbers that aren't supposed to be negative, but when they are it is just a little slower. This approach is based on https://stackoverflow.com/a/51099524/268898 where the poster offers performance benchmarks showing this is the fastest way to get a number of digits. Internal helper for efficiently creating empty read only lists Is this string composed entirely of ASCII digits '0' to '9'? Is this string composed entirely of ASCII alphanumeric characters and hyphens? Split a string, map the parts, and return a read only list of the values. Splitting a string, mapping the result and storing into a is a common operation in this package. This method optimizes that. It avoids the performance overhead of: Constructing the params array for Constructing the intermediate returned by Not allocating list capacity based on the size Benchmarking shows this to be 30%+ faster and that may not reflect the whole benefit since it doesn't fully account for reduced allocations. Trim leading zeros from a numeric string. If the string consists of all zeros, return "0". The standard method handles all zeros by returning "". This efficiently handles the kind of trimming needed. An efficient representation of a section of a string Trim leading zeros from a numeric string segment. If the segment consists of all zeros, return "0". The standard method handles all zeros by returning "". This efficiently handles the kind of trimming needed. Used to clearly mark when a case should be unreachable and helps properly manage code coverage. Struct used as a marker to differentiate constructor overloads that would otherwise be the same as safe overloads. This exception is used with the method to indicate parse failure without constructing a new exception. This exception should never be thrown or exposed outside of this package.