Skip to content

Class ReleaseVersion

Namespace: Void.Minecraft
Assembly: Void.Minecraft.dll

Represents a Minecraft release version number in Major.Minor[.Patch] form.

public record ReleaseVersion : IComparable<ReleaseVersion>, IEquatable<ReleaseVersion>

Inheritance

objectReleaseVersion

Implements

IComparable<ReleaseVersion>, IEquatable<ReleaseVersion>

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()

Remarks

Patch is optional: when it is 0, omits it and returns the two-component form (for example, "1.21"). A non-zero patch produces the three-component form (for example, "1.21.4").

Ordering follows the natural numeric ordering of the components: Major first, then Minor, then Patch.

Implicit conversions are provided in both directions so that a can be assigned from or cast to a string without an explicit call to .

Constructors

ReleaseVersion(int, int, int)

Represents a Minecraft release version number in Major.Minor[.Patch] form.

public ReleaseVersion(int Major, int Minor, int Patch)

Parameters

Major int

The major component of the version number (for example, 1 in 1.21.4).

Minor int

The minor component of the version number (for example, 21 in 1.21.4).

Patch int

The patch component of the version number (for example, 4 in 1.21.4). Pass 0 for releases that have no patch segment.

Remarks

Patch is optional: when it is 0, omits it and returns the two-component form (for example, "1.21"). A non-zero patch produces the three-component form (for example, "1.21.4").

Ordering follows the natural numeric ordering of the components: Major first, then Minor, then Patch.

Implicit conversions are provided in both directions so that a can be assigned from or cast to a string without an explicit call to .

Properties

Major

The major component of the version number (for example, 1 in 1.21.4).

public int Major { get; init; }

Property Value

int

Minor

The minor component of the version number (for example, 21 in 1.21.4).

public int Minor { get; init; }

Property Value

int

Patch

The patch component of the version number (for example, 4 in 1.21.4). Pass 0 for releases that have no patch segment.

public int Patch { get; init; }

Property Value

int

Methods

CompareTo(ReleaseVersion?)

Compares the current instance with another version and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other version.

public int CompareTo(ReleaseVersion? other)

Parameters

other ReleaseVersion?

The version to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. Less than zero if this instance precedes other in the sort order. Zero if this instance occurs in the same position as other in the sort order. Greater than zero if this instance follows other in the sort order, or if other is null.

Parse(string)

Converts the string representation of a version to its equivalent.

public static ReleaseVersion Parse(string versionString)

Parameters

versionString string

A string containing the version to convert.

Returns

ReleaseVersion

A equivalent to the version contained in versionString.

Exceptions

FormatException

versionString is not in a valid format.

ToString()

Converts the version to its string representation.

public override string ToString()

Returns

string

A string in the format “Major.Minor” when Patch is zero, otherwise “Major.Minor.Patch”.

TryParse(string, out ReleaseVersion)

Attempts to parse a version string into a instance.

public static bool TryParse(string versionString, out ReleaseVersion version)

Parameters

versionString string

The version string to parse in “major.minor” or “major.minor.patch” format.

version ReleaseVersion

When successful, contains the parsed ; otherwise, null.

Returns

bool

true if the version string was successfully parsed; otherwise, false.

Operators

implicit operator ReleaseVersion(string)

Converts a string to a ReleaseVersion.

public static implicit operator ReleaseVersion(string versionString)

Parameters

versionString string

The string representation of the version.

Returns

ReleaseVersion

implicit operator string(ReleaseVersion)

Implicitly converts a ReleaseVersion to its string representation.

public static implicit operator string(ReleaseVersion version)

Parameters

version ReleaseVersion

The ReleaseVersion to convert.

Returns

string