Table of Contents

Class SemVer

Namespace
Ubiquity.NET.Versioning
Assembly
Ubiquity.NET.Versioning.dll

Semantic Version value

public sealed class SemVer : IParsable<SemVer>
Inheritance
SemVer
Implements
Inherited Members

Remarks

Officially a SemVer value does NOT limit the size of the numeric portions of a version so this implementation uses BigInteger values for each component. This allows all possible values.

In practical terms any such component will likely "down convert" to an integer. If a version component in the real world exceeds the size of an integer, then there is probably something wrong with how the versioning is maintained.

important

This type is ***intentionally*** NOT a value type or `record struct` etc... as the ONLY valid comparison that is always correct is reference equality. Any other comparison/ordering requires a specific comparer that not only understands the rules of a Semantic Version, but also deals with case sensitivity of those comparisons. Sadly, the SemVer spec is silent on the point of case comparisons and different major component repositories have chosen different interpretations of the spec as a result. Thus any consumer must explicitly decide which comparison to use.

Technically, the SemVer spec states that alphanumeric Identifiers are ordered lexicographically, which would make them case sensitive. However, since MAJOR framework repositories have chosen to use each approach the real world of ambiguity, sadly, wins.

Constructors

SemVer(BigInteger, BigInteger, BigInteger)

Initializes a new instance of the SemVer class.

SemVer(BigInteger, BigInteger, BigInteger, IEnumerable<string>?)

Initializes a new instance of the SemVer class.

SemVer(BigInteger, BigInteger, BigInteger, IEnumerable<string>?, IEnumerable<string>?)

Initializes a new instance of the SemVer class.

Properties

BuildMeta

Gets the build components of the version

Major

Gets the Major portion of the core version

Minor

Gets the Minor portion of the core version

Patch

Gets the Patch portion of the core version

PreRelease

Gets the pre-release components of the version

Methods

Parse(string, IFormatProvider?)

Parses a string into a value.

ToString()

Converts the version to a canonical SemVer string

TryParse(string?, IFormatProvider?, out SemVer)

Tries to parse a string into a value.

See Also