CkVersionRange
Namespace: Meshmakers.Octo.ConstructionKit.Contracts
Represents a construction kit dependency version range
public struct CkVersionRange
Inheritance Object → ValueType → CkVersionRange
Implements IEquatable<CkVersionRange>, IComparable<CkVersionRange>
Remarks:
Version range syntax:
Simple version strings (without brackets):
1.0 or 1.0.0 - Creates an open-ended minimum version range, inclusive (x >= 1.0.0)
This means "1.0.0" includes ALL versions from 1.0.0 onwards (1.0.0, 1.0.1, 1.1.0, 2.0.0, etc.)
Exact version matching:
[1.0] or [1.0.0] - Exact version match only (x == 1.0.0)
This matches ONLY the specified version, nothing else
Range specifications:
[1.0,) - Minimum version, inclusive (x >= 1.0.0) - same as simple "1.0"
(1.0,) - Minimum version, exclusive (x > 1.0.0)
(,1.0] - Maximum version, inclusive (x <= 1.0.0)
(,1.0) - Maximum version, exclusive (x < 1.0.0)
[1.0,2.0] - Bounded range, inclusive (1.0.0 <= x <= 2.0.0)
(1.0,2.0) - Bounded range, exclusive (1.0.0 < x < 2.0.0)
[1.0,2.0) - Mixed inclusive minimum and exclusive maximum (1.0.0 <= x < 2.0.0)
Important note on overlapping: Two ranges overlap if there exists at least one version that satisfies both ranges. For example, "1.0.0" (which means >= 1.0.0) and "1.0.1" (which means >= 1.0.1) DO overlap because all versions >= 1.0.1 satisfy both ranges.
Properties
MinVersion
Gets the minimum version (if specified)
public Nullable<CkVersion> MinVersion { get; }
Property Value
MaxVersion
Gets the maximum version (if specified)
public Nullable<CkVersion> MaxVersion { get; }
Property Value
MinInclusive
Gets whether the minimum version is inclusive
public bool MinInclusive { get; }
Property Value
MaxInclusive
Gets whether the maximum version is inclusive
public bool MaxInclusive { get; }
Property Value
Constructors
CkVersionRange(String)
Creates a new instance of CkVersionRange
public CkVersionRange(string versionRange)
Parameters
versionRange String
Version range as string. Examples:
"1.0.0" - Creates range [1.0.0,) meaning version >= 1.0.0
"[1.0.0]" - Exact version 1.0.0 only
"[1.0.0,2.0.0)" - Range from 1.0.0 inclusive to 2.0.0 exclusive
Exceptions
ArgumentException
Thrown when the version range format is invalid
Methods
IsSatisfiedBy(CkVersion)
Checks if a version satisfies this version range
public bool IsSatisfiedBy(CkVersion version)
Parameters
version CkVersion
The version to check
Returns
Boolean
True if the version is within the range, false otherwise
Overlaps(CkVersionRange)
Checks if another version range overlaps with this one
public bool Overlaps(CkVersionRange other)
Parameters
other CkVersionRange
The other version range
Returns
Boolean
True if there exists at least one version that satisfies both ranges, false otherwise
Remarks:
Two ranges overlap if there is any version that would be accepted by both ranges. For example:
"1.0.0" (meaning >= 1.0.0) and "1.0.1" (meaning >= 1.0.1) DO overlap because both ranges share versions like 1.0.1, 1.0.2, 1.1.0, etc. Note: "1.0.1" does NOT include 1.0.0, but the ranges still overlap via their shared versions.
"[1.0.0]" (exactly 1.0.0) and "[1.0.1]" (exactly 1.0.1) do NOT overlap - no version satisfies both
"[1.0.0,2.0.0]" and "[1.5.0,3.0.0]" DO overlap - versions 1.5.0 to 2.0.0 satisfy both
"[1.0.0,2.0.0)" and "[2.0.0,3.0.0]" do NOT overlap - no version satisfies both (2.0.0 is excluded from first, included in second)
IsCompatible(CkVersion)
Checks if a version is compatible with this version range
public bool IsCompatible(CkVersion other)
Parameters
other CkVersion
The version to check compatibility with
Returns
Boolean
True if the version is compatible, false otherwise
Remarks:
This is an alias for IsSatisfiedBy for backward compatibility
CompareTo(CkVersionRange)
Compares this version range to another version range
public int CompareTo(CkVersionRange other)
Parameters
other CkVersionRange
The other version range to compare to
Returns
Int32
A value that indicates the relative order of the ranges:
Less than zero: This range is considered "less than" the other range
Zero: This range is equivalent to the other range
Greater than zero: This range is considered "greater than" the other range
Remarks:
Comparison logic:
- First compare minimum versions (null is treated as "earliest")
- If minimum versions are equal, compare minimum inclusivity (inclusive < exclusive)
- If still equal, compare maximum versions (null is treated as "latest")
- If maximum versions are equal, compare maximum inclusivity (exclusive < inclusive)
Equals(CkVersionRange)
public bool Equals(CkVersionRange other)
Parameters
other CkVersionRange
Returns
ToString()
Returns a string representation of the version range.
public string ToString()
Returns
String
A string representation of the version range.
Equals(Object)
public bool Equals(object obj)
Parameters
obj Object
Returns
GetHashCode()
public int GetHashCode()