Table of Contents

Struct Semver

A simple semantic versioning implementation that supports parsing, comparison, and equality checks.

public readonly struct Semver : IComparable<Semver>, IEquatable<Semver>
Implements
Inherited Members
Extension Methods

Properties

Build

Gets the build identifiers, if any.

public string Build { get; }

Property Value

string

IsPrerelease

Gets a value indicating whether this version is a pre-release version.

public bool IsPrerelease { get; }

Property Value

bool

IsValid

Determines if this is a valid semantic version.

public bool IsValid { get; }

Property Value

bool

Major

The major version number.

public int Major { get; }

Property Value

int

Minor

The minor version number.

public int Minor { get; }

Property Value

int

Patch

The patch version number.

public int Patch { get; }

Property Value

int

Prerelease

Gets the pre-release identifiers, if any.

public string Prerelease { get; }

Property Value

string

Methods

CompareTo(Semver)

Compares this instance with another Semver instance.

public int CompareTo(Semver other)

Parameters

other Semver

The other Semver instance to compare with.

Returns

int

An integer that indicates the relative order of the instances.

Equals(Semver)

Checks if this instance is equal to another Semver instance.

public bool Equals(Semver other)

Parameters

other Semver

The other Semver instance to compare with.

Returns

bool

True if the instances are equal; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

TryParse(string, out Semver)

Tries to parse a semantic version string into a Semver instance.

public static bool TryParse(string version, out Semver result)

Parameters

version string

The version string to parse.

result Semver

The parsed Semver instance if parsing succeeds.

Returns

bool

True if parsing was successful; otherwise, false.

Operators

operator ==(Semver, Semver)

public static bool operator ==(Semver left, Semver right)

Parameters

left Semver
right Semver

Returns

bool

operator >(Semver, Semver)

public static bool operator >(Semver left, Semver right)

Parameters

left Semver
right Semver

Returns

bool

operator >=(Semver, Semver)

public static bool operator >=(Semver left, Semver right)

Parameters

left Semver
right Semver

Returns

bool

implicit operator Semver(string)

public static implicit operator Semver(string str)

Parameters

str string

Returns

Semver

operator !=(Semver, Semver)

public static bool operator !=(Semver left, Semver right)

Parameters

left Semver
right Semver

Returns

bool

operator <(Semver, Semver)

public static bool operator <(Semver left, Semver right)

Parameters

left Semver
right Semver

Returns

bool

operator <=(Semver, Semver)

public static bool operator <=(Semver left, Semver right)

Parameters

left Semver
right Semver

Returns

bool