Search Results for

    Show / Hide Table of Contents
    View Source

    Class SemVersion

    A semantic version implementation. Conforms to v2.0.0 of http://semver.org/

    Inheritance
    object
    Namespace: Umbraco.Cms.Core.Semver
    Assembly: Umbraco.Core.dll
    Syntax
    public sealed class SemVersion

    Constructors

    View Source

    SemVersion(int, int, int, string, string)

    Initializes a new instance of the SemVersion class.

    Declaration
    public SemVersion(int major, int minor = 0, int patch = 0, string prerelease = "", string build = "")
    Parameters
    Type Name Description
    int major

    The major version.

    int minor

    The minor version.

    int patch

    The patch version.

    string prerelease

    The prerelease version (eg. "alpha").

    string build

    The build eg ("nightly.232").

    View Source

    SemVersion(Version)

    Initializes a new instance of the SemVersion class.

    Declaration
    public SemVersion(Version version)
    Parameters
    Type Name Description
    Version version

    The System.Version that is used to initialize the Major, Minor, Patch and Build properties.

    Properties

    View Source

    Build

    Gets the build version.

    Declaration
    public string Build { get; }
    Property Value
    Type Description
    string

    The build version.

    View Source

    Major

    Gets the major version.

    Declaration
    public int Major { get; }
    Property Value
    Type Description
    int

    The major version.

    View Source

    Minor

    Gets the minor version.

    Declaration
    public int Minor { get; }
    Property Value
    Type Description
    int

    The minor version.

    View Source

    Patch

    Gets the patch version.

    Declaration
    public int Patch { get; }
    Property Value
    Type Description
    int

    The patch version.

    View Source

    Prerelease

    Gets the pre-release version.

    Declaration
    public string Prerelease { get; }
    Property Value
    Type Description
    string

    The pre-release version.

    Methods

    View Source

    Change(int?, int?, int?, string?, string?)

    Make a copy of the current instance with optional altered fields.

    Declaration
    public SemVersion Change(int? major = null, int? minor = null, int? patch = null, string? prerelease = null, string? build = null)
    Parameters
    Type Name Description
    int? major

    The major version.

    int? minor

    The minor version.

    int? patch

    The patch version.

    string prerelease

    The prerelease text.

    string build

    The build text.

    Returns
    Type Description
    SemVersion

    The new version object.

    View Source

    Compare(SemVersion, SemVersion)

    Compares the specified versions.

    Declaration
    public static int Compare(SemVersion versionA, SemVersion versionB)
    Parameters
    Type Name Description
    SemVersion versionA

    The version to compare to.

    SemVersion versionB

    The version to compare against.

    Returns
    Type Description
    int

    If versionA < versionB < 0, if versionA > versionB > 0, if versionA is equal to versionB 0.

    View Source

    CompareByPrecedence(SemVersion)

    Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.

    Declaration
    public int CompareByPrecedence(SemVersion other)
    Parameters
    Type Name Description
    SemVersion other

    The semantic version.

    Returns
    Type Description
    int

    A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the version precedence. Zero This instance has the same precedence as other. i Greater than zero This instance has creater precedence as other.

    View Source

    CompareTo(object?)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

    Declaration
    public int CompareTo(object? obj)
    Parameters
    Type Name Description
    object obj

    An object to compare with this instance.

    Returns
    Type Description
    int

    A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes obj in the sort order. Zero This instance occurs in the same position in the sort order as obj. i Greater than zero This instance follows obj in the sort order.

    View Source

    CompareTo(SemVersion?)

    Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

    Declaration
    public int CompareTo(SemVersion? other)
    Parameters
    Type Name Description
    SemVersion other

    An object to compare with this instance.

    Returns
    Type Description
    int

    A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance precedes other in the sort order. Zero This instance occurs in the same position in the sort order as other. i Greater than zero This instance follows other in the sort order.

    View Source

    Equals(object?)

    Determines whether the specified object is equal to this instance.

    Declaration
    public override bool Equals(object? obj)
    Parameters
    Type Name Description
    object obj

    The object to compare with this instance.

    Returns
    Type Description
    bool

    true if the specified object is equal to this instance; otherwise, false.

    View Source

    Equals(SemVersion, SemVersion)

    Tests the specified versions for equality.

    Declaration
    public static bool Equals(SemVersion versionA, SemVersion versionB)
    Parameters
    Type Name Description
    SemVersion versionA

    The first version.

    SemVersion versionB

    The second version.

    Returns
    Type Description
    bool

    If versionA is equal to versionB true, else false.

    View Source

    GetHashCode()

    Returns a hash code for this instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int

    A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

    View Source

    GetObjectData(SerializationInfo, StreamingContext)

    Populates a System.Runtime.Serialization.SerializationInfo with the data needed to serialize the target object.

    Declaration
    public void GetObjectData(SerializationInfo info, StreamingContext context)
    Parameters
    Type Name Description
    SerializationInfo info

    The System.Runtime.Serialization.SerializationInfo to populate with data.

    StreamingContext context

    The destination (see System.Runtime.Serialization.StreamingContext) for this serialization.

    Exceptions
    Type Condition
    SecurityException

    The caller does not have the required permission.

    View Source

    Parse(string, bool)

    Parses the specified string to a semantic version.

    Declaration
    public static SemVersion Parse(string version, bool strict = false)
    Parameters
    Type Name Description
    string version

    The version string.

    bool strict

    If set to true minor and patch version are required, else they default to 0.

    Returns
    Type Description
    SemVersion

    The SemVersion object.

    Exceptions
    Type Condition
    InvalidOperationException

    When a invalid version string is passed.

    View Source

    PrecedenceMatches(SemVersion)

    Compares to semantic versions by precedence. This does the same as a Equals, but ignores the build information.

    Declaration
    public bool PrecedenceMatches(SemVersion other)
    Parameters
    Type Name Description
    SemVersion other

    The semantic version.

    Returns
    Type Description
    bool

    true if the version precedence matches.

    View Source

    ToString()

    Returns a string that represents this instance.

    Declaration
    public override string ToString()
    Returns
    Type Description
    string

    A string that represents this instance.

    View Source

    TryParse(string, out SemVersion?, bool)

    Parses the specified string to a semantic version.

    Declaration
    public static bool TryParse(string version, out SemVersion? semver, bool strict = false)
    Parameters
    Type Name Description
    string version

    The version string.

    SemVersion semver

    When the method returns, contains a SemVersion instance equivalent to the version string passed in, if the version string was valid, or null if the version string was not valid.

    bool strict

    If set to true minor and patch version are required, else they default to 0.

    Returns
    Type Description
    bool

    False when a invalid version string is passed, otherwise true.

    Operators

    View Source

    operator ==(SemVersion, SemVersion)

    The override of the equals operator.

    Declaration
    public static bool operator ==(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    bool

    If left is equal to right true, else false.

    View Source

    operator >(SemVersion, SemVersion)

    The override of the greater operator.

    Declaration
    public static bool operator >(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    bool

    If left is greater than right true, else false.

    View Source

    operator >=(SemVersion, SemVersion)

    The override of the greater than or equal operator.

    Declaration
    public static bool operator >=(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    bool

    If left is greater than or equal to right true, else false.

    View Source

    implicit operator SemVersion(string)

    Implicit conversion from string to SemVersion.

    Declaration
    public static implicit operator SemVersion(string version)
    Parameters
    Type Name Description
    string version

    The semantic version.

    Returns
    Type Description
    SemVersion

    The SemVersion object.

    View Source

    operator !=(SemVersion, SemVersion)

    The override of the un-equal operator.

    Declaration
    public static bool operator !=(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    bool

    If left is not equal to right true, else false.

    View Source

    operator <(SemVersion, SemVersion)

    The override of the less operator.

    Declaration
    public static bool operator <(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    bool

    If left is less than right true, else false.

    View Source

    operator <=(SemVersion, SemVersion)

    The override of the less than or equal operator.

    Declaration
    public static bool operator <=(SemVersion left, SemVersion right)
    Parameters
    Type Name Description
    SemVersion left

    The left value.

    SemVersion right

    The right value.

    Returns
    Type Description
    bool

    If left is less than or equal to right true, else false.

    • Edit this page
    • View Source
    In this article
    Back to top Copyright © 2016-present Umbraco
    Generated by DocFX