SemanticVersion Class

Summary

Represents a semantic version with optional pre-release tag and build metadata.
Namespace
GitVersion
Interfaces
Base Types
  • IFormattable
graph BT Type-->Base0["IFormattable"] Type-.->Interface0["IComparable<SemanticVersion>"] Type-.->Interface1["IEquatable<SemanticVersion>"] Type["SemanticVersion"] class Type type-node

Syntax

public sealed class SemanticVersion : IFormattable, IComparable<SemanticVersion>, 
    IEquatable<SemanticVersion>

Constructors

Name Summary
SemanticVersion(long, long, long) Initializes a new semantic version with the given major, minor, and patch values.
SemanticVersion(SemanticVersion) Initializes a new semantic version as a copy of semanticVersion.

Fields

Name Constant Value Summary
Empty
A zero-valued semantic version with no pre-release tag or build metadata.
static

Properties

Name Value Summary
BuildMetaData SemanticVersionBuildMetaData
Gets or initializes the build metadata associated with this version.
IsPreRelease bool
Gets a value indicating whether this version has a pre-release tag.
Major long
Gets or initializes the major version component.
Minor long
Gets or initializes the minor version component.
Patch long
Gets or initializes the patch version component.
PreReleaseTag SemanticVersionPreReleaseTag
Gets or initializes the pre-release tag.

Methods

Name Value Summary
CompareTo(SemanticVersion, bool) int
Compares this version to value, optionally excluding the pre-release tag from the comparison.
CompareTo(SemanticVersion) int
Compares this version to value, including the pre-release tag in the comparison.
Equals(object) bool
Returns true when obj is a SemanticVersion equal to this instance.
Equals(SemanticVersion) bool
Returns true when this version is equal to obj.
GetHashCode() int
Returns a hash code combining all version components.
Increment(VersionField, string, bool, SemanticVersion[]) SemanticVersion
Returns a new version incremented by increment with the given label, optionally forcing the increment.
Increment(VersionField, string, SemanticVersion.IncrementMode, SemanticVersion[]) SemanticVersion
Returns a new version incremented by increment with the given label and increment mode.
Increment(VersionField, string, SemanticVersion[]) SemanticVersion
Returns a new version incremented by increment with the given label.
IsEmpty() bool
Returns true when this instance equals Empty.
IsEqualTo(SemanticVersion, bool) bool
Returns true when this version is equal to value.
IsGreaterThan(SemanticVersion, bool) bool
Returns true when this version is greater than value.
IsGreaterThanOrEqualTo(SemanticVersion, bool) bool
Returns true when this version is greater than or equal to value.
IsLabeledWith(string) bool
Returns true when the pre-release tag name equals value (case-insensitive).
IsLessThan(SemanticVersion, bool) bool
Returns true when this version is less than value.
IsLessThanOrEqualTo(SemanticVersion, bool) bool
Returns true when this version is less than or equal to value.
IsMatchForBranchSpecificLabel(string) bool
Returns true when this version is compatible with a branch-specific label check: no tag set, no label supplied, or the label matches.
Parse(string, string, SemanticVersionFormat) SemanticVersion
Parses version as a semantic version, throwing when the input cannot be parsed.
static
ToString() string
Returns the default semantic version string (without build metadata).
ToString(string, IFormatProvider?) string

s - Default SemVer [1.2.3-beta.4]

f - Full SemVer [1.2.3-beta.4+5]

i - Informational SemVer [1.2.3-beta.4+5.Branch.main.BranchType.main.Sha.000000]

j - Just the SemVer part [1.2.3]

t - SemVer with the tag [1.2.3-beta.4]

ToString(string) string
Returns a string representation of this version using the given format specifier.
TryParse(string, string, SemanticVersion, SemanticVersionFormat) bool
Attempts to parse version as a semantic version, returning true on success.
static
WithLabel(string) SemanticVersion
Returns a new version derived from this one with the pre-release tag changed to label.

Operators

Name Value Summary
operator !=(SemanticVersion, SemanticVersion) bool
operator <(SemanticVersion, SemanticVersion) bool
operator <=(SemanticVersion, SemanticVersion) bool
operator ==(SemanticVersion, SemanticVersion) bool
operator >(SemanticVersion, SemanticVersion) bool
operator >=(SemanticVersion, SemanticVersion) bool

Extension Methods

Name Value Summary
NotNull<SemanticVersion>(string) T
Throws ArgumentNullException when value is null; otherwise returns the value.
GitHub