Show / Hide Table of Contents

Class PrereleaseIdentifier

An individual prerelease identifier for a semantic version.
Inheritance
System.Object
PrereleaseIdentifier
Implements
System.IEquatable<PrereleaseIdentifier>
System.IComparable<PrereleaseIdentifier>
System.IComparable
Namespace: Semver
Assembly: Semver.dll
Syntax
public sealed class PrereleaseIdentifier : ValueType
Remarks

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 PrereleaseIdentifier is a struct, the default value is a PrereleaseIdentifier with a null value. However, the Semver namespace types do not accept and will not return such a PrereleaseIdentifier.

Constructors

PrereleaseIdentifier(BigInteger)

Construct a valid numeric PrereleaseIdentifier from an integer value.
Declaration
public PrereleaseIdentifier(BigInteger value)
Parameters
Type Name Description
System.Numerics.BigInteger value The non-negative value of this identifier.
Exceptions
Type Condition
System.ArgumentOutOfRangeException The value is negative.

PrereleaseIdentifier(String, Boolean)

Constructs a valid PrereleaseIdentifier.
Declaration
public PrereleaseIdentifier(string value, bool allowLeadingZeros = false)
Parameters
Type Name Description
System.String value The string value of this prerelease identifier.
System.Boolean allowLeadingZeros Whether to allow leading zeros in the value parameter. If true, leading zeros will be allowed on numeric identifiers but will be removed.
Remarks
Because a valid numeric identifier does not have leading zeros, this constructor will never create a PrereleaseIdentifier with leading zeros even if allowLeadingZeros is true. Any leading zeros will be removed.
Exceptions
Type Condition
System.ArgumentNullException The value is null.
System.ArgumentException The value 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 allowLeadingZeros is false.

Properties

NumericValue

The numeric value of the prerelease identifier if it is a numeric identifier, otherwise null.
Declaration
public Nullable<BigInteger> NumericValue { get; }
Property Value
Type Description
System.Nullable<System.Numerics.BigInteger> The numeric value of the prerelease identifier if it is a numeric identifier, otherwise null.
Remarks
The numeric value of a prerelease identifier will never be negative.

Value

The string value of the prerelease identifier even if it is a numeric identifier.
Declaration
public string Value { get; }
Property Value
Type Description
System.String The string value of this prerelease identifier even if it is a numeric identifier or null if this is a default PrereleaseIdentifier.
Remarks
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.

Methods

CompareTo(PrereleaseIdentifier)

Compares two identifiers and indicates whether this instance precedes, follows, or is equal to the other in precedence order.
Declaration
public int CompareTo(PrereleaseIdentifier value)
Parameters
Type Name Description
PrereleaseIdentifier value
Returns
Type Description
System.Int32 An integer that indicates whether this instance precedes, follows, or is equal to value in precedence order.
ValueCondition
-1This instance precedes value.
0This instance is equal to value.
1This instance follows value.
Remarks
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 comparison.

CompareTo(Object)

Compares this identifier to an System.Object and indicates whether this instance precedes, follows, or is equal to the object in precedence order.
Declaration
public int CompareTo(object value)
Parameters
Type Name Description
System.Object value
Returns
Type Description
System.Int32 An integer that indicates whether this instance precedes, follows, or is equal to value in precedence order.
ValueCondition
-1This instance precedes value.
0This instance is equal to value.
1This instance follows value or value is null.
Remarks
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 comparison.
Exceptions
Type Condition
System.ArgumentException value is not a PrereleaseIdentifier.

Equals(PrereleaseIdentifier)

Determines whether two identifiers are equal.
Declaration
public bool Equals(PrereleaseIdentifier value)
Parameters
Type Name Description
PrereleaseIdentifier value
Returns
Type Description
System.Boolean true if value is equal to this identifier; otherwise false.
Remarks
Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015').

Equals(Object)

Determines whether the given object is equal to this identifier.
Declaration
public override bool Equals(object value)
Parameters
Type Name Description
System.Object value
Returns
Type Description
System.Boolean true if value is equal to this identifier; otherwise false.
Remarks
Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015').

GetHashCode()

Gets a hash code for this identifier.
Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32 A hash code for this identifier.
Remarks
Numeric identifiers with leading zeros are have the same hash code (e.g. '15' has the same hash code as '015').

ToString()

Converts this identifier into an equivalent string value.
Declaration
public override string ToString()
Returns
Type Description
System.String The string value of this identifier or null if this is a default PrereleaseIdentifier

Operators

Equality(PrereleaseIdentifier, PrereleaseIdentifier)

Determines whether two identifiers are equal.
Declaration
public static bool operator ==(PrereleaseIdentifier left, PrereleaseIdentifier right)
Parameters
Type Name Description
PrereleaseIdentifier left
PrereleaseIdentifier right
Returns
Type Description
System.Boolean true if the value of left is the same as the value of right; otherwise false.
Remarks
Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015').

Implicit(PrereleaseIdentifier to String)

Converts this identifier into an equivalent string value.
Declaration
public static implicit operator string (PrereleaseIdentifier prereleaseIdentifier)
Parameters
Type Name Description
PrereleaseIdentifier prereleaseIdentifier
Returns
Type Description
System.String The string value of this identifier or null if this is a default PrereleaseIdentifier

Inequality(PrereleaseIdentifier, PrereleaseIdentifier)

Determines whether two identifiers are not equal.
Declaration
public static bool operator !=(PrereleaseIdentifier left, PrereleaseIdentifier right)
Parameters
Type Name Description
PrereleaseIdentifier left
PrereleaseIdentifier right
Returns
Type Description
System.Boolean true if the value of left is different from the value of right; otherwise false.
Remarks
Numeric identifiers with leading zeros are considered equal (e.g. '15' is equal to '015').

Implements

System.IEquatable<>
System.IComparable<>
System.IComparable
In This Article
Back to top Generated by DocFX