Table of Contents

Class ImplementationVersion

Namespace
ZeroInstall.Model
Assembly
ZeroInstall.Model.dll

Represents a version number consisting of dot-separated decimals and optional modifier strings.

[TypeConverter(typeof(StringConstructorConverter<ImplementationVersion>))]
public sealed class ImplementationVersion : IComparable<ImplementationVersion>, IEquatable<ImplementationVersion>
Inheritance
object
ImplementationVersion
Implements

Remarks

This class is immutable and thread-safe.

This is the syntax for valid version strings:

Version := DottedList ("-" Modifier? DottedList?)*
DottedList := (Integer ("." Integer)*)
Modifier := "pre" | "rc" | "post"

If the string ContainsTemplateVariables(string) the entire string is stored verbatim and not parsed.

Constructors

ImplementationVersion(string)

Creates a new implementation version from a string.

public ImplementationVersion(string value)

Parameters

value string

The string containing the version information.

Exceptions

FormatException

value is not a valid version string.

ImplementationVersion(Version)

Creates a new implementation version from a .NET Version.

public ImplementationVersion(Version version)

Parameters

version Version

The .NET Version to convert.

ImplementationVersion(VersionDottedList, params VersionPart[])

Creates a new implementation version.

public ImplementationVersion(VersionDottedList firstPart, params VersionPart[] additionalParts)

Parameters

firstPart VersionDottedList

The first part of the version number.

additionalParts VersionPart[]

All additional parts of the version number.

Properties

AdditionalParts

All additional parts of the version number.

public IReadOnlyList<VersionPart> AdditionalParts { get; }

Property Value

IReadOnlyList<VersionPart>

ContainsTemplateVariables

Indicates whether this version number contains a template variable (a substring enclosed in curly brackets, e.g {var}) .

[Browsable(false)]
public bool ContainsTemplateVariables { get; }

Property Value

bool

Remarks

This must be false in regular feeds; true is only valid for templates.

FirstPart

The first part of the version number.

public VersionDottedList FirstPart { get; }

Property Value

VersionDottedList

Methods

CompareTo(ImplementationVersion?)

public int CompareTo(ImplementationVersion? other)

Parameters

other ImplementationVersion

Returns

int

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

FromSemVer(string)

Creates a new ImplementationVersion from a SemVer string.

public static ImplementationVersion FromSemVer(string value)

Parameters

value string

Returns

ImplementationVersion

Remarks

Tries to parse as much as possible, while ignoring parts that can't be mapped to 0install version numbers. Returns 0 for entirely unparsable values.

GetHashCode()

public override int GetHashCode()

Returns

int

ToString()

Returns a string representation of the version. Safe for parsing!

public override string ToString()

Returns

string

TryCreate(string, out ImplementationVersion?)

Creates a new ImplementationVersion using the specified string representation.

public static bool TryCreate(string value, out ImplementationVersion? result)

Parameters

value string

The string to parse.

result ImplementationVersion

Returns the created ImplementationVersion if successfully; null otherwise.

Returns

bool

true if the ImplementationVersion was successfully created; false otherwise.

Operators

operator ==(ImplementationVersion?, ImplementationVersion?)

Indicates whether the object on the left is equal to the object on the right.

public static bool operator ==(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion

The left object

right ImplementationVersion

The right object

Returns

bool

true if the objects are equal; otherwise, false.

operator >(ImplementationVersion?, ImplementationVersion?)

public static bool operator >(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool

operator >=(ImplementationVersion?, ImplementationVersion?)

public static bool operator >=(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool

operator !=(ImplementationVersion?, ImplementationVersion?)

Indicates whether the object on the left is not equal to the object on the right.

public static bool operator !=(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion

The left object

right ImplementationVersion

The right object

Returns

bool

true if the objects are not equal; otherwise, false.

operator <(ImplementationVersion?, ImplementationVersion?)

public static bool operator <(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool

operator <=(ImplementationVersion?, ImplementationVersion?)

public static bool operator <=(ImplementationVersion? left, ImplementationVersion? right)

Parameters

left ImplementationVersion
right ImplementationVersion

Returns

bool