SemVer
public sealed class SemVerParsed semantic version with precedence comparison, prerelease support, and helpers for normalizing patch and minor components.
Fields
Section titled “Fields”
ComponentCount
Section titled “ComponentCount”public readonly int ComponentCountReturns
System.Int32
public readonly int MajorReturns
System.Int32
public readonly int MinorReturns
System.Int32
MinorQualifier
Section titled “MinorQualifier”public readonly string MinorQualifierReturns
System.String
SmallerMinorQualifier
Section titled “SmallerMinorQualifier”public readonly bool SmallerMinorQualifierReturns
System.Boolean
public readonly int MicroReturns
System.Int32
MicroQualifier
Section titled “MicroQualifier”public readonly string MicroQualifierReturns
System.String
SmallerMicroQualifier
Section titled “SmallerMicroQualifier”public readonly bool SmallerMicroQualifierReturns
System.Boolean
public readonly int PatchReturns
System.Int32
PatchQualifier
Section titled “PatchQualifier”public readonly string PatchQualifierReturns
System.String
SmallerPatchQualifier
Section titled “SmallerPatchQualifier”public readonly bool SmallerPatchQualifierReturns
System.Boolean
IsValid
Section titled “IsValid”public readonly bool IsValidReturns
System.Boolean
Constructors
Section titled “Constructors”
SemVer(string)
Section titled “SemVer(string)”public SemVer(string version)Parses the supplied semantic-version string, including optional prerelease and build components.
Parameters
| Name | Type |
|---|---|
version |
System.String |
Methods
Section titled “Methods”
WithOnlyMinor()
Section titled “WithOnlyMinor()”public SemVer WithOnlyMinor()Returns a version containing only this version’s major and minor components.
Returns
AssetInventory.SemVer
WithPatch(int)
Section titled “WithPatch(int)”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
Equals(object)
Section titled “Equals(object)”public override bool Equals(object obj)Parameters
| Name | Type |
|---|---|
obj |
System.Object |
Returns
System.Boolean
GetHashCode()
Section titled “GetHashCode()”public override int GetHashCode()Returns
System.Int32
CompareTo(object)
Section titled “CompareTo(object)”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
ToString()
Section titled “ToString()”public override string ToString()Returns
System.String
OnlyDiffersInPatch(SemVer)
Section titled “OnlyDiffersInPatch(SemVer)”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
Operators
Section titled “Operators”
operator ==(SemVer, SemVer)
Section titled “operator ==(SemVer, SemVer)”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.
operator !=(SemVer, SemVer)
Section titled “operator !=(SemVer, SemVer)”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.
operator >=(SemVer, SemVer)
Section titled “operator >=(SemVer, SemVer)”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
operator <=(SemVer, SemVer)
Section titled “operator <=(SemVer, SemVer)”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
operator >(SemVer, SemVer)
Section titled “operator >(SemVer, SemVer)”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
operator <(SemVer, SemVer)
Section titled “operator <(SemVer, SemVer)”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
Properties
Section titled “Properties”
CleanedVersion
Section titled “CleanedVersion”public string CleanedVersion { get; }Returns
System.String