Show / Hide Table of Contents

Class UnbrokenSemVersionRange

A range of SemVersion values with no gaps. The more general and flexible range class SemVersionRange is typically used instead. It combines multiple UnbrokenSemVersionRanges. UnbrokenSemVersionRange can be used directly if it is important to reflect that something must be a range with no gaps in it.
Inheritance
System.Object
UnbrokenSemVersionRange
Implements
System.IEquatable<UnbrokenSemVersionRange>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Semver
Assembly: Semver.dll
Syntax
public sealed class UnbrokenSemVersionRange : IEquatable<UnbrokenSemVersionRange>
Remarks
An UnbrokenSemVersionRange is represented as an interval between two versions, the Start and End. For each, that version may or may not be included.

Properties

All

The range that contains both all release and prerelease versions.
Declaration
public static UnbrokenSemVersionRange All { get; }
Property Value
Type Description
UnbrokenSemVersionRange The range that contains both all release and prerelease versions.

AllRelease

The range that contains all release versions but no prerelease versions.
Declaration
public static UnbrokenSemVersionRange AllRelease { get; }
Property Value
Type Description
UnbrokenSemVersionRange The range that contains all release versions but no prerelease versions.

Empty

A standard representation for the empty range that contains no versions.
Declaration
public static UnbrokenSemVersionRange Empty { get; }
Property Value
Type Description
UnbrokenSemVersionRange A standard representation for the empty range that contains no versions.
Remarks

There are an infinite number of ways to represent the empty range. Any range where the start is greater than the end or where start equals end but one is not inclusive would be empty. See https://en.wikipedia.org/wiki/Interval_(mathematics)#Classification_of_intervals

Since all UnbrokenSemVersionRange objects have a Start and End, the only unique empty range is the one whose start is the max version and end is the minimum version.

End

The end, right limit, or maximum of this range. Cannot be null.
Declaration
public SemVersion End { get; }
Property Value
Type Description
SemVersion The end, right limit, or maximum of this range. Cannot be null.

EndInclusive

Whether this range includes the End value.
Declaration
public bool EndInclusive { get; }
Property Value
Type Description
System.Boolean Whether this range includes the End value.

IncludeAllPrerelease

Whether this range includes all prerelease versions between Start and End. If IncludeAllPrerelease is false then prerelease versions matching the major, minor, and patch version of the Start or End will be included only if that end is a prerelease version.
Declaration
public bool IncludeAllPrerelease { get; }
Property Value
Type Description
System.Boolean

Start

The start, left limit, or minimum of this range. Can be null.
Declaration
public SemVersion Start { get; }
Property Value
Type Description
SemVersion The start or left end of this range. Can be null.
Remarks
Ranges with no lower bound have a Start value of null. This ensures that they do not unintentionally include any prerelease versions.

StartInclusive

Whether this range includes the Start value.
Declaration
public bool StartInclusive { get; }
Property Value
Type Description
System.Boolean Whether this range includes the Start value.
Remarks
When Start is null, StartInclusive will always be false.

Methods

AtLeast(SemVersion, Boolean)

Construct a range containing versions equal to or greater than the given version.
Declaration
public static UnbrokenSemVersionRange AtLeast(SemVersion version, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion version The range will contain all versions greater than or equal to this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given version if it is prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions greater than or equal to the given version.

AtMost(SemVersion, Boolean)

Construct a range containing versions equal to or less than the given version.
Declaration
public static UnbrokenSemVersionRange AtMost(SemVersion version, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion version The range will contain all versions less than or equal to this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given version if it is prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions less than or equal to the given version.

Contains(SemVersion)

Determine whether this range contains the given version.
Declaration
public bool Contains(SemVersion version)
Parameters
Type Name Description
SemVersion version The version to test against the range.
Returns
Type Description
System.Boolean true if the version is contained in the range, otherwise false.

Equals(SemVersion)

Construct a range containing only a single version.
Declaration
public static UnbrokenSemVersionRange Equals(SemVersion version)
Parameters
Type Name Description
SemVersion version The version the range should contain.
Returns
Type Description
UnbrokenSemVersionRange A range containing only the given version.

Equals(UnbrokenSemVersionRange)

Determines whether two version ranges are equal.
Declaration
public bool Equals(UnbrokenSemVersionRange other)
Parameters
Type Name Description
UnbrokenSemVersionRange other
Returns
Type Description
System.Boolean true if other is equal to the this range; otherwise false.

Equals(Object)

Determines whether the given object is equal to this range.
Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj
Returns
Type Description
System.Boolean true if obj is equal to the this range; otherwise false.
Overrides
System.Object.Equals(System.Object)

Exclusive(SemVersion, SemVersion, Boolean)

Construct a range containing all versions between the given versions excluding those versions.
Declaration
public static UnbrokenSemVersionRange Exclusive(SemVersion start, SemVersion end, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion start The range will contain only versions greater than this.
SemVersion end The range will contain only versions less than this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions between the given versions including the end but not the start.

GetHashCode()

Gets a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32 A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Overrides
System.Object.GetHashCode()

GreaterThan(SemVersion, Boolean)

Construct a range containing versions greater than the given version.
Declaration
public static UnbrokenSemVersionRange GreaterThan(SemVersion version, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion version The range will contain all versions greater than this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given version if it is prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions greater than the given version.

Inclusive(SemVersion, SemVersion, Boolean)

Construct a range containing all versions between the given versions including those versions.
Declaration
public static UnbrokenSemVersionRange Inclusive(SemVersion start, SemVersion end, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion start The range will contain only versions greater than or equal to this.
SemVersion end The range will contain only versions less than or equal to this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions between the given versions including those versions.

InclusiveOfEnd(SemVersion, SemVersion, Boolean)

Construct a range containing all versions between the given versions including the end but not the start.
Declaration
public static UnbrokenSemVersionRange InclusiveOfEnd(SemVersion start, SemVersion end, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion start The range will contain only versions greater than this.
SemVersion end The range will contain only versions less than or equal to this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions between the given versions including the end but not the start.

InclusiveOfStart(SemVersion, SemVersion, Boolean)

Construct a range containing all versions between the given versions including the start but not the end.
Declaration
public static UnbrokenSemVersionRange InclusiveOfStart(SemVersion start, SemVersion end, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion start The range will contain only versions greater than or equal to this.
SemVersion end The range will contain only versions less than this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given versions if they are prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions between the given versions including the start but not the end.

LessThan(SemVersion, Boolean)

Construct a range containing versions less than the given version.
Declaration
public static UnbrokenSemVersionRange LessThan(SemVersion version, bool includeAllPrerelease = false)
Parameters
Type Name Description
SemVersion version The range will contain all versions less than this.
System.Boolean includeAllPrerelease Include all prerelease versions in the range rather than just those matching the given version if it is prerelease.
Returns
Type Description
UnbrokenSemVersionRange A range containing versions less than the given version.

ToString()

Converts this version range to an equivalent string value in standard range syntax.
Declaration
public override string ToString()
Returns
Type Description
System.String The System.String equivalent of this version in standard range syntax.
Overrides
System.Object.ToString()
Remarks
Ranges including all prerelease versions are indicated with the idiom of prefixing with "*-*". This includes all prerelease versions because it matches all prerelease versions.

Operators

Equality(UnbrokenSemVersionRange, UnbrokenSemVersionRange)

Determines whether two version ranges are equal.
Declaration
public static bool operator ==(UnbrokenSemVersionRange left, UnbrokenSemVersionRange right)
Parameters
Type Name Description
UnbrokenSemVersionRange left
UnbrokenSemVersionRange right
Returns
Type Description
System.Boolean true if the two values are equal, otherwise false.

Implicit(UnbrokenSemVersionRange to Predicate<SemVersion>)

Convert this range into a predicate function indicating whether a version is contained in the range.
Declaration
public static implicit operator Predicate<SemVersion>(UnbrokenSemVersionRange range)
Parameters
Type Name Description
UnbrokenSemVersionRange range The range to convert into a predicate function.
Returns
Type Description
System.Predicate<SemVersion> A predicate that indicates whether a given version is contained in this range.

Inequality(UnbrokenSemVersionRange, UnbrokenSemVersionRange)

Determines whether two version ranges are not equal. Due to the complexity of ranges, it may be possible for two ranges to match the same set of versions but be expressed in different ways and so not be equal.
Declaration
public static bool operator !=(UnbrokenSemVersionRange left, UnbrokenSemVersionRange right)
Parameters
Type Name Description
UnbrokenSemVersionRange left
UnbrokenSemVersionRange right
Returns
Type Description
System.Boolean true if the two ranges are not equal, otherwise false.

Implements

System.IEquatable<T>
In This Article
Back to top Generated by DocFX