Skip to main content

Definition

Assembly: CloudNimble.DotNetDocs.Tools.dll Namespace: CloudNimble.DotNetDocs.Tools.Models Inheritance: System.Object

Syntax

CloudNimble.DotNetDocs.Tools.Models.NuGetVersion

Summary

Represents a simplified NuGet version for comparison purposes.

Remarks

This class provides basic semantic versioning support with major, minor, patch, and prerelease components. It implements IComparable`1 to allow version comparisons, where stable versions are considered greater than prerelease versions with the same major.minor.patch numbers.

Constructors

.ctor

Initializes a new instance of the NuGetVersion class from a version string.

Syntax

public NuGetVersion(string version)

Parameters

NameTypeDescription
versionstringThe version string to parse (e.g., “1.0.0” or “1.0.0-preview.1”).

Remarks

The version string should be in the format “major.minor.patch” or “major.minor.patch-prerelease”. If any component cannot be parsed, it defaults to 0.

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

IsPrerelease

Gets a value indicating whether this version is a prerelease version.

Syntax

public bool IsPrerelease { get; }

Property Value

Type: bool

Major

Gets the major version component.

Syntax

public int Major { get; }

Property Value

Type: int

Minor

Gets the minor version component.

Syntax

public int Minor { get; }

Property Value

Type: int

Patch

Gets the patch version component.

Syntax

public int Patch { get; }

Property Value

Type: int

Prerelease

Gets the prerelease label, if any.

Syntax

public string Prerelease { get; }

Property Value

Type: string?

Methods

CompareTo

Compares the current version to another version.

Syntax

public int CompareTo(CloudNimble.DotNetDocs.Tools.Models.NuGetVersion other)

Parameters

NameTypeDescription
otherCloudNimble.DotNetDocs.Tools.Models.NuGetVersion?The version to compare to.

Returns

Type: int A negative value if this version is less than other, zero if they are equal, or a positive value if this version is greater than other.

Remarks

Version comparison follows semantic versioning rules. Stable versions are considered greater than prerelease versions with the same major.minor.patch numbers. Prerelease versions are compared lexicographically by their prerelease labels.

Equals Override

Determines whether the specified object is equal to the current version.

Syntax

public override bool Equals(object obj)

Parameters

NameTypeDescription
objobject?The object to compare with the current version.

Returns

Type: bool true if the specified object is equal to the current version; otherwise, false.

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Override

Returns a hash code for the current version.

Syntax

public override int GetHashCode()

Returns

Type: int A hash code for the current version.

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Override

Returns a string representation of the version.

Syntax

public override string ToString()

Returns

Type: string A string in the format “major.minor.patch” or “major.minor.patch-prerelease”.

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?
  • System.IComparable<CloudNimble.DotNetDocs.Tools.Models.NuGetVersion>