Table of Contents

About

The Ubiquity.NET.Versioning library provides types to support use of versioning via

  1. Semantic Versioning
  2. Constrained Semantic Versioning
    • Including Continuous Integration (CI) via CSemVer-CI

It is viable as a standalone package to allow validation of or comparisons to versions reported at runtime. (Especially from native interop that does not support package dependencies or versioning at runtime.)

Example

var epectedMinimum = new CSemVer(20, 1, 5, "alpha");
var actual = CSemVer.From(SomeAPIToRetrieveAVersionAsUInt64());
if (actual < expectedMinimum)
{
    // Uh-OH! "older" version!
}

// Good to go...

Formatting

The library contains support for proper formatting of strings based on the rules of a SemVer, CSemVer, and CSemVer-CI

Parsing

The library contains support for parsing of strings based on the rules of a SemVer, CSemVer, and CSemVer-CI

Ordering

The types all support IComparable<T>1 and properly handle correct sort ordering of the versions according to the rules of SemVer (Which, CSemVer and CSemVer-CI follow)

Warning

The formal 'spec' for CSemVer remains mostly silent on the point of the short format. See this known issue. Since, the existence of that form was to support NuGet V2, which is now obsolete, this library does not support the short form at all. (This choice keeps documentation clarity [NOT SUPPORTED] and implementation simplicity)


1 The SemVer class does NOT support IComparable<T> as the spec is not explicit2 on case sensitive comparison of AlphaNumeric Identifiers.

2Technically the spec says that pre-release identifiers are compared lexicographically, which would mean they are case sensitive. Unfortunately, that was not made explicit and major repositories using SemVer have chosen to use different rules of comparison and ordering. Thus, a consumer is required to know a-priori if the version is compared insensitive or not. IComparer<SemVer> instances are available for both cases via the static class SemVerComparer and CSmeVerComparer.CaseSensitive.