Hue Preserving Color Blending
Public Member Functions | Static Public Member Functions | Properties | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
Semver.SemVersion Class Reference

A semantic version implementation. Conforms to v2.0.0 of http://semver.org/ More...

Inheritance diagram for Semver.SemVersion:

Public Member Functions

 SemVersion (int major, int minor=0, int patch=0, string prerelease="", string build="")
 Initializes a new instance of the SemVersion class. More...
 
 SemVersion (Version version)
 Initializes a new instance of the SemVersion class. More...
 
SemVersion Change (int? major=null, int? minor=null, int? patch=null, string prerelease=null, string build=null)
 Make a copy of the current instance with optional altered fields. More...
 
override string ToString ()
 Returns a System.String that represents this instance. More...
 
int CompareTo (object obj)
 Compares the current instance with another object of the same type 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 object. More...
 
int CompareTo (SemVersion other)
 Compares the current instance with another object of the same type 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 object. More...
 
bool PrecedenceMatches (SemVersion other)
 Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information. More...
 
int CompareByPrecedence (SemVersion other)
 Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information. More...
 
override bool Equals (object obj)
 Determines whether the specified System.Object is equal to this instance. More...
 
override int GetHashCode ()
 Returns a hash code for this instance. More...
 
void GetObjectData (SerializationInfo info, StreamingContext context)
 

Static Public Member Functions

static SemVersion Parse (string version, bool strict=false)
 Parses the specified string to a semantic version. More...
 
static bool TryParse (string version, out SemVersion semver, bool strict=false)
 Parses the specified string to a semantic version. More...
 
static bool Equals (SemVersion versionA, SemVersion versionB)
 Tests the specified versions for equality. More...
 
static int Compare (SemVersion versionA, SemVersion versionB)
 Compares the specified versions. More...
 
static implicit operator SemVersion (string version)
 Implicit conversion from string to SemVersion. More...
 
static bool operator== (SemVersion left, SemVersion right)
 The override of the equals operator. More...
 
static bool operator != (SemVersion left, SemVersion right)
 The override of the un-equal operator. More...
 
static bool operator > (SemVersion left, SemVersion right)
 The override of the greater operator. More...
 
static bool operator >= (SemVersion left, SemVersion right)
 The override of the greater than or equal operator. More...
 
static bool operator< (SemVersion left, SemVersion right)
 The override of the less operator. More...
 
static bool operator<= (SemVersion left, SemVersion right)
 The override of the less than or equal operator. More...
 

Properties

int Major [get, private set]
 Gets the major version. More...
 
int Minor [get, private set]
 Gets the minor version. More...
 
int Patch [get, private set]
 Gets the patch version. More...
 
string Prerelease [get, private set]
 Gets the pre-release version. More...
 
string Build [get, private set]
 Gets the build version. More...
 

Private Member Functions

 SemVersion (SerializationInfo info, StreamingContext context)
 Initializes a new instance of the SemVersion class. More...
 

Static Private Member Functions

static int CompareComponent (string a, string b, bool lower=false)
 

Static Private Attributes

static Regex parseEx
 

Detailed Description

A semantic version implementation. Conforms to v2.0.0 of http://semver.org/

Definition at line 43 of file SemVersion.cs.

Constructor & Destructor Documentation

◆ SemVersion() [1/3]

Semver.SemVersion.SemVersion ( SerializationInfo  info,
StreamingContext  context 
)
inlineprivate

Initializes a new instance of the SemVersion class.

Parameters
info
context
Exceptions
ArgumentNullException

Definition at line 65 of file SemVersion.cs.

◆ SemVersion() [2/3]

Semver.SemVersion.SemVersion ( int  major,
int  minor = 0,
int  patch = 0,
string  prerelease = "",
string  build = "" 
)
inline

Initializes a new instance of the SemVersion class.

Parameters
majorThe major version.
minorThe minor version.
patchThe patch version.
prereleaseThe prerelease version (eg. "alpha").
buildThe build eg ("nightly.232").

Definition at line 85 of file SemVersion.cs.

◆ SemVersion() [3/3]

Semver.SemVersion.SemVersion ( Version  version)
inline

Initializes a new instance of the SemVersion class.

Parameters
versionThe System.Version that is used to initialize the Major, Minor, Patch and Build properties.

Definition at line 100 of file SemVersion.cs.

Member Function Documentation

◆ Change()

SemVersion Semver.SemVersion.Change ( int?  major = null,
int?  minor = null,
int?  patch = null,
string  prerelease = null,
string  build = null 
)
inline

Make a copy of the current instance with optional altered fields.

Parameters
majorThe major version.
minorThe minor version.
patchThe patch version.
prereleaseThe prerelease text.
buildThe build text.
Returns
The new version object.

Definition at line 241 of file SemVersion.cs.

◆ Compare()

static int Semver.SemVersion.Compare ( SemVersion  versionA,
SemVersion  versionB 
)
inlinestatic

Compares the specified versions.

Parameters
versionAThe version to compare to.
versionBThe version to compare against.
Returns
If versionA < versionB < 0, if versionA > versionB > 0, if versionA is equal to versionB 0.

Definition at line 225 of file SemVersion.cs.

◆ CompareByPrecedence()

int Semver.SemVersion.CompareByPrecedence ( SemVersion  other)
inline

Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.

Parameters
otherThe semantic version.
Returns
A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the version precedence. Zero This instance has the same precedence as other . i Greater than zero This instance has creater precedence as other .

Definition at line 373 of file SemVersion.cs.

◆ CompareTo() [1/2]

int Semver.SemVersion.CompareTo ( object  obj)
inline

Compares the current instance with another object of the same type 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 object.

Parameters
objAn object to compare with this instance.
Returns
A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj . i Greater than zero This instance follows obj in the sort order.

Definition at line 321 of file SemVersion.cs.

◆ CompareTo() [2/2]

int Semver.SemVersion.CompareTo ( SemVersion  other)
inline

Compares the current instance with another object of the same type 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 object.

Parameters
otherAn object to compare with this instance.
Returns
A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other . i Greater than zero This instance follows other in the sort order.

Definition at line 339 of file SemVersion.cs.

◆ Equals() [1/2]

static bool Semver.SemVersion.Equals ( SemVersion  versionA,
SemVersion  versionB 
)
inlinestatic

Tests the specified versions for equality.

Parameters
versionAThe first version.
versionBThe second version.
Returns
If versionA is equal to versionB true, else false.

Definition at line 211 of file SemVersion.cs.

◆ Equals() [2/2]

override bool Semver.SemVersion.Equals ( object  obj)
inline

Determines whether the specified System.Object is equal to this instance.

Parameters
objThe System.Object to compare with this instance.
Returns
true if the specified System.Object is equal to this instance; otherwise, false.

Definition at line 442 of file SemVersion.cs.

◆ GetHashCode()

override int Semver.SemVersion.GetHashCode ( )
inline

Returns a hash code for this instance.

Returns
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Definition at line 465 of file SemVersion.cs.

◆ operator !=()

static bool Semver.SemVersion.operator != ( SemVersion  left,
SemVersion  right 
)
inlinestatic

The override of the un-equal operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is not equal to right true, else false.

Definition at line 514 of file SemVersion.cs.

◆ operator >()

static bool Semver.SemVersion.operator > ( SemVersion  left,
SemVersion  right 
)
inlinestatic

The override of the greater operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is greater than right true, else false.

Definition at line 525 of file SemVersion.cs.

◆ operator >=()

static bool Semver.SemVersion.operator >= ( SemVersion  left,
SemVersion  right 
)
inlinestatic

The override of the greater than or equal operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is greater than or equal to right true, else false.

Definition at line 536 of file SemVersion.cs.

◆ operator SemVersion()

static implicit Semver.SemVersion.operator SemVersion ( string  version)
inlinestatic

Implicit conversion from string to SemVersion.

Parameters
versionThe semantic version.
Returns
The SemVersion object.

Definition at line 492 of file SemVersion.cs.

◆ operator<()

static bool Semver.SemVersion.operator< ( SemVersion  left,
SemVersion  right 
)
inlinestatic

The override of the less operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is less than right true, else false.

Definition at line 547 of file SemVersion.cs.

◆ operator<=()

static bool Semver.SemVersion.operator<= ( SemVersion  left,
SemVersion  right 
)
inlinestatic

The override of the less than or equal operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is less than or equal to right true, else false.

Definition at line 558 of file SemVersion.cs.

◆ operator==()

static bool Semver.SemVersion.operator== ( SemVersion  left,
SemVersion  right 
)
inlinestatic

The override of the equals operator.

Parameters
leftThe left value.
rightThe right value.
Returns
If left is equal to right true, else false.

Definition at line 503 of file SemVersion.cs.

◆ Parse()

static SemVersion Semver.SemVersion.Parse ( string  version,
bool  strict = false 
)
inlinestatic

Parses the specified string to a semantic version.

Parameters
versionThe version string.
strictIf set to true minor and patch version are required, else they default to 0.
Returns
The SemVersion object.
Exceptions
System.InvalidOperationExceptionWhen a invalid version string is passed.

Definition at line 132 of file SemVersion.cs.

◆ PrecedenceMatches()

bool Semver.SemVersion.PrecedenceMatches ( SemVersion  other)
inline

Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.

Parameters
otherThe semantic version.
Returns
true if the version precedence matches.

Definition at line 357 of file SemVersion.cs.

◆ ToString()

override string Semver.SemVersion.ToString ( )
inline

Returns a System.String that represents this instance.

Returns
A System.String that represents this instance.

Definition at line 298 of file SemVersion.cs.

◆ TryParse()

static bool Semver.SemVersion.TryParse ( string  version,
out SemVersion  semver,
bool  strict = false 
)
inlinestatic

Parses the specified string to a semantic version.

Parameters
versionThe version string.
semverWhen the method returns, contains a SemVersion instance equivalent to the version string passed in, if the version string was valid, or null if the version string was not valid.
strictIf set to true minor and patch version are required, else they default to 0.
Returns
False when a invalid version string is passed, otherwise true.

Definition at line 191 of file SemVersion.cs.

Member Data Documentation

◆ parseEx

Regex Semver.SemVersion.parseEx
staticprivate
Initial value:
=
new Regex(@"^(?<major>\d+)" +
@"(\.(?<minor>\d+))?" +
@"(\.(?<patch>\d+))?" +
@"(\-(?<pre>[0-9A-Za-z\-\.]+))?" +
@"(\+(?<build>[0-9A-Za-z\-\.]+))?$",
RegexOptions.CultureInvariant | RegexOptions.Compiled | RegexOptions.ExplicitCapture)

Definition at line 46 of file SemVersion.cs.

Property Documentation

◆ Build

string Semver.SemVersion.Build
getprivate set

Gets the build version.

The build version.

Definition at line 290 of file SemVersion.cs.

◆ Major

int Semver.SemVersion.Major
getprivate set

Gets the major version.

The major version.

Definition at line 258 of file SemVersion.cs.

◆ Minor

int Semver.SemVersion.Minor
getprivate set

Gets the minor version.

The minor version.

Definition at line 266 of file SemVersion.cs.

◆ Patch

int Semver.SemVersion.Patch
getprivate set

Gets the patch version.

The patch version.

Definition at line 274 of file SemVersion.cs.

◆ Prerelease

string Semver.SemVersion.Prerelease
getprivate set

Gets the pre-release version.

The pre-release version.

Definition at line 282 of file SemVersion.cs.


The documentation for this class was generated from the following file: