Struct MetadataIdentifier
An individual metadata identifier for a semantic version.
Implements
System.IEquatable<MetadataIdentifier>
System.IComparable<MetadataIdentifier>
System.IComparable
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
Namespace: Semver
Assembly: Semver.dll
Syntax
public readonly struct MetadataIdentifier : IEquatable<MetadataIdentifier>, IComparable<MetadataIdentifier>, IComparable
Remarks
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 MetadataIdentifier is a struct, the default value is a MetadataIdentifier with a null value. However, the Semver namespace types do not accept and will not return such a MetadataIdentifier.
Invalid metadata identifiers including arbitrary Unicode characters and empty string can currently be produced by the SemVersion(Int32, Int32, Int32, String, String) constructor. Such identifiers are compared via an ordinal string comparision.
Constructors
MetadataIdentifier(String)
Constructs a valid MetadataIdentifier.
Declaration
public MetadataIdentifier(string value)
Parameters
Type | Name | Description |
---|---|---|
System.String | value |
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). |
Properties
Value
The string value of the metadata identifier.
Declaration
public readonly string Value { get; }
Property Value
Type | Description |
---|---|
System.String | The string value of this metadata identifier or null if this is a default MetadataIdentifier. |
Methods
CompareTo(MetadataIdentifier)
Compares two identifiers and indicates whether this instance precedes, follows, or is
equal to the other in sort order.
Declaration
public readonly int CompareTo(MetadataIdentifier value)
Parameters
Type | Name | Description |
---|---|---|
MetadataIdentifier | value |
Returns
Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|
System.Int32 |
An integer that indicates whether this instance precedes, follows, or is equal to
value in sort order.
|
Remarks
Identifiers are compared lexically in ASCII sort order. Invalid identifiers are
compared via an ordinal string comparision.
CompareTo(Object)
Compares this identifier to an System.Object and indicates whether this instance
precedes, follows, or is equal to the object in sort order.
Declaration
public readonly 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 sort order.
|
Remarks
Identifiers are compared lexically in ASCII sort order. Invalid identifiers are
compared via an ordinal string comparision.
Exceptions
Type | Condition |
---|---|
System.ArgumentException | value is not a MetadataIdentifier. |
Equals(MetadataIdentifier)
Determines whether two identifiers are equal.
Declaration
public readonly bool Equals(MetadataIdentifier value)
Parameters
Type | Name | Description |
---|---|---|
MetadataIdentifier | value |
Returns
Type | Description |
---|---|
System.Boolean | true if value is equal to the this identifier;
otherwise false. |
Equals(Object)
Determines whether the given object is equal to this identifier.
Declaration
public override readonly bool Equals(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value |
Returns
Type | Description |
---|---|
System.Boolean | true if value is equal to the this identifier;
otherwise false. |
Overrides
System.ValueType.Equals(System.Object)
GetHashCode()
Gets a hash code for this identifier.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for this identifier. |
Overrides
System.ValueType.GetHashCode()
ToString()
Converts this identifier into an equivalent string value.
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
System.String | The string value of this identifier or null if this is a default MetadataIdentifier |
Overrides
System.ValueType.ToString()
Operators
Equality(MetadataIdentifier, MetadataIdentifier)
Determines whether two identifiers are equal.
Declaration
public static bool operator ==(MetadataIdentifier left, MetadataIdentifier right)
Parameters
Type | Name | Description |
---|---|---|
MetadataIdentifier | left | |
MetadataIdentifier | right |
Returns
Type | Description |
---|---|
System.Boolean | true if the value of left is the same as
the value of right ; otherwise false. |
Implicit(MetadataIdentifier to String)
Converts this identifier into an equivalent string value.
Declaration
public static implicit operator string (MetadataIdentifier metadataIdentifier)
Parameters
Type | Name | Description |
---|---|---|
MetadataIdentifier | metadataIdentifier |
Returns
Type | Description |
---|---|
System.String | The string value of this identifier or null if this is a default MetadataIdentifier. |
Inequality(MetadataIdentifier, MetadataIdentifier)
Determines whether two identifiers are not equal.
Declaration
public static bool operator !=(MetadataIdentifier left, MetadataIdentifier right)
Parameters
Type | Name | Description |
---|---|---|
MetadataIdentifier | left | |
MetadataIdentifier | right |
Returns
Type | Description |
---|---|
System.Boolean | true if the value of left is different
from the value of right ; otherwise false. |
Implements
System.IEquatable<T>
System.IComparable<T>
System.IComparable