PackageVersion

Namespace: AnyPackage.Provider

The PackageVersion class.

public sealed class PackageVersion : System.IComparable, System.IComparable`1[[AnyPackage.Provider.PackageVersion, AnyPackage, Version=0.5.1.0, Culture=neutral, PublicKeyToken=null]], System.IEquatable`1[[AnyPackage.Provider.PackageVersion, AnyPackage, Version=0.5.1.0, Culture=neutral, PublicKeyToken=null]]

Inheritance ObjectPackageVersion
Implements IComparable, IComparable<PackageVersion>, IEquatable<PackageVersion>

Properties

Version

Gets the version.

public string Version { get; }

Property Value

String

Major

Gets the dot separated first position.

public Nullable<ulong> Major { get; }

Property Value

Nullable<UInt64>

Minor

Gets the dot separated second position.

public Nullable<ulong> Minor { get; }

Property Value

Nullable<UInt64>

Patch

Gets the dot separated third position.

public Nullable<ulong> Patch { get; }

Property Value

Nullable<UInt64>

Revision

Gets the dot separated fourth position.

public Nullable<ulong> Revision { get; }

Property Value

Nullable<UInt64>

Parts

Gets all the dot separated values.

public IEnumerable<ulong> Parts { get; }

Property Value

IEnumerable<UInt64>

IsPrerelease

Gets if the version is a prerelease.

public bool IsPrerelease { get; }

Property Value

Boolean

Suffix

Gets the suffix of a multi-part numeric with suffix version.

public string Suffix { get; }

Property Value

String

HasMetadata

Gets if there

public bool HasMetadata { get; }

Property Value

Boolean

Prerelease

Gets the dot separated values of the prerelease string.

public IEnumerable<string> Prerelease { get; }

Property Value

IEnumerable<String>

Metadata

Gets the dot separated values of the build metadata string.

public IEnumerable<string> Metadata { get; }

Property Value

IEnumerable<String>

Scheme

Gets the version scheme.

public PackageVersionScheme Scheme { get; }

Property Value

PackageVersionScheme

Constructors

PackageVersion(String)

Constructs an instance of the PackageVersion class.

public PackageVersion(string version)

Parameters

version String
The version.

PackageVersion(Version)

Constructs an instance of the PackageVersion class.

public PackageVersion(Version version)

Parameters

version Version
The version.

Methods

Parse(String)

Converts the string representation of a version to an equivalent PackageVersion object.

public static PackageVersion Parse(string version)

Parameters

version String
A string that contains a version to convert.

Returns

PackageVersion

        An object that is equivalent to the version specified in the version parameter.

TryParse(String, PackageVersion&)

Tries to convert the string representation of a version to an equivalent PackageVersion object, and returns a value that indicates whether the conversion succeeded.

public static bool TryParse(string version, PackageVersion& result)

Parameters

version String
A string that contains a version to convert.

result PackageVersion&

        When this methods returns, contains the PackageVersion equivalent of the string, if the conversion succeeded.
        If version is null, Empty, or if the conversion fails, result is null when the method returns.

Returns

Boolean
true if the version parameter was converted successfully; otherwise, false.

ToVersion()

A Version representation of PackageVersion.

public Version ToVersion()

Returns

Version
A Version representation of PackageVersion.

CompareTo(Object)

Compares this object to the other for version comparison.

public int CompareTo(object obj)

Parameters

obj Object
The version to compare against

Returns

Int32

        Returns -1 when this object is a lower version than the other.
        Returns 0 when this object and other object are equal.
        Returns 1 for this object is a higher version than the other.

Remarks:

Refer to CompareTo(PackageVersion other) for version comparison rules.

CompareTo(PackageVersion)

Compares this object to the other for version comparison.

public int CompareTo(PackageVersion other)

Parameters

other PackageVersion
The version to compare against.

Returns

Int32

        Returns -1 when this object is a lower version than the other.
        Returns 0 when this object and other object are equal.
        Returns 1 for this object is a higher version than the other.

Remarks:

The sorting is by first comparing if both versions are using the alpha-numeric version scheme. If so then it compares using string comparison. If one of the two versions is alpha-numeric it be considered higher compared to the numeric version.

Numeric sorting takes place after it is determined neither is alpha-numeric. It will compare each version part numerically until one part is different. The version sorting is able to compare different version lengths (1.0 vs 1.0.0 or 1.0.0.1). If no difference is found it will then compare suffix and prerelease.

Versions with a suffix are considered higher than their non-suffix counterparts (1.0 is lower than 1.0a). If both versions contain a suffix they will compared using the string comparison.

Versions with a prerelease are considered lower than their non-prerelease counterparts (1.0 is higher than 1.0-alpha). If both versions contain a prerelease they will compared using the rules defined in semver 2.0.

Equals(PackageVersion)

Provides an Equals implementation.

public bool Equals(PackageVersion other)

Parameters

other PackageVersion
Input object.

Returns

Boolean
Returns true if the objects are equal.

Equals(Object)

Provides an Equals implementation.

public bool Equals(object obj)

Parameters

obj Object
Input object.

Returns

Boolean
Returns true if the objects are equal.

GetHashCode()

Provides a GetHashCode implementation.

public int GetHashCode()

Returns

Int32
Returns the hash code for Version property.

ToString()

Provides a ToString implementation.

public string ToString()

Returns

String
Returns the Version property.