Skip to content

SemVer

ClassAssetInventoryAssetInventory.Editor
public sealed class SemVer

Parsed semantic version with precedence comparison, prerelease support, and helpers for normalizing patch and minor components.

public readonly int ComponentCount

Returns

System.Int32

public readonly int Major

Returns

System.Int32

public readonly int Minor

Returns

System.Int32

public readonly string MinorQualifier

Returns

System.String

public readonly bool SmallerMinorQualifier

Returns

System.Boolean

public readonly int Micro

Returns

System.Int32

public readonly string MicroQualifier

Returns

System.String

public readonly bool SmallerMicroQualifier

Returns

System.Boolean

public readonly int Patch

Returns

System.Int32

public readonly string PatchQualifier

Returns

System.String

public readonly bool SmallerPatchQualifier

Returns

System.Boolean

public readonly bool IsValid

Returns

System.Boolean

public SemVer(string version)

Parses the supplied semantic-version string, including optional prerelease and build components.

Parameters

Name Type
version System.String

public SemVer WithOnlyMinor()

Returns a version containing only this version’s major and minor components.

Returns

AssetInventory.SemVer

public SemVer WithPatch(int patch)

Returns a version with the supplied patch component while preserving major, minor, and prerelease data.

Parameters

Name Type
patch System.Int32

Returns

AssetInventory.SemVer

public override bool Equals(object obj)

Parameters

Name Type
obj System.Object

Returns

System.Boolean

public override int GetHashCode()

Returns

System.Int32

public int CompareTo(object obj)

Compares this semantic version with another object and throws when the object is not a semantic version.

Parameters

Name Type
obj System.Object

Returns

System.Int32

public override string ToString()

Returns

System.String

public bool OnlyDiffersInPatch(SemVer other)

Reports whether two versions have equal major, minor, and prerelease components but different patch components.

Parameters

Name Type
other AssetInventory.SemVer

Returns

System.Boolean

public static bool operator ==(SemVer version1, SemVer version2)

Compares the cleaned version strings for exact equality. Two null references compare equal; this is stricter than semantic-version precedence comparison.

Parameters

Name Type
version1 AssetInventory.SemVer
version2 AssetInventory.SemVer

Returns

System.Boolean: true when both operands are null or contain the same cleaned version string.

public static bool operator !=(SemVer version1, SemVer version2)

Compares the cleaned version strings for exact inequality, including null-reference differences.

Parameters

Name Type
version1 AssetInventory.SemVer
version2 AssetInventory.SemVer

Returns

System.Boolean: true when only one operand is null or their cleaned version strings differ.

public static bool operator >=(SemVer version1, SemVer version2)

Reports whether the left semantic version has equal or higher precedence than the right version.

Parameters

Name Type
version1 AssetInventory.SemVer
version2 AssetInventory.SemVer

Returns

System.Boolean

public static bool operator <=(SemVer version1, SemVer version2)

Reports whether the left semantic version has equal or lower precedence than the right version.

Parameters

Name Type
version1 AssetInventory.SemVer
version2 AssetInventory.SemVer

Returns

System.Boolean

public static bool operator >(SemVer version1, SemVer version2)

Reports whether the left semantic version has higher precedence than the right version.

Parameters

Name Type
version1 AssetInventory.SemVer
version2 AssetInventory.SemVer

Returns

System.Boolean

public static bool operator <(SemVer version1, SemVer version2)

Reports whether the left semantic version has lower precedence than the right version.

Parameters

Name Type
version1 AssetInventory.SemVer
version2 AssetInventory.SemVer

Returns

System.Boolean

public string CleanedVersion { get; }

Returns

System.String