Chasm.SemanticVersioning 2.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Chasm.SemanticVersioning --version 2.2.0                
NuGet\Install-Package Chasm.SemanticVersioning -Version 2.2.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Chasm.SemanticVersioning" Version="2.2.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Chasm.SemanticVersioning --version 2.2.0                
#r "nuget: Chasm.SemanticVersioning, 2.2.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Chasm.SemanticVersioning as a Cake Addin
#addin nuget:?package=Chasm.SemanticVersioning&version=2.2.0

// Install Chasm.SemanticVersioning as a Cake Tool
#tool nuget:?package=Chasm.SemanticVersioning&version=2.2.0                

Chasm.SemanticVersioning

You're probably wondering "Why should I use this library instead of any other more popular alternatives?". Well, here's a quick overview...

  • Focus on functionality and performance. I will make sure to implement any common manipulations with semantic versions, and I will microoptimize the hell out of everything! (not as much as diving into assembly code though) I'll whip up some benchmarks later to show you the difference.

  • Nice concise naming. SemanticVersion, SemverPreRelease, SemverOptions. It's a bit inconsistent with SemanticVersion compared to other types, but calling it SemverVersion would sound redundant.

  • .NET-style documentation. Written in the style of System namespace docs. I don't know if it's worth advertising, but I really like how descriptive and consistent it is, so I thought I should mention that.

  • In active development, lots of plans. See the to-do list below.

To-do List

Extra functionality

  • Use more efficient formatting (Chasm.Formatting);
  • Advanced SemanticVersion formatting (M.m.p-rrr+ddd);
  • SemanticVersionBuilder class;
  • BuildMetadataComparer class;
  • Advanced SemverPreRelease formatting, maybe?;
  • SemverPreRelease.ParseMultiple/Many method;
  • Option to ignore empty pre-releases/build metadata during parsing;
  • Option to allow an older version syntax, like 1.2.3beta5;

node-semver version ranges

  • Classes PartialVersion, VersionRange, ComparatorSet, Comparator;
  • Primitive version comparators;
  • Advanced version comparators;
  • PartialVersion parsing and formatting;
  • Parsing of version ranges and its components;

SemanticVersion

SemanticVersion represents a valid semantic version as per the SemVer 2.0.0 specification.

var a = SemanticVersion.Parse("1.0.0-alpha.8");
var b = SemanticVersion.Parse("=v 1.2-pre  ", SemverOptions.Loose);

Console.WriteLine($"{a} < {b} = {a < b}");
// 1.0.0-alpha.8 < 1.2-pre = true

Note that the default comparison doesn't account for build metadata! For build metadata-sensitive comparison, use BuildMetadataComparer.

var a = SemanticVersion.Parse("1.2.3-4");
var b = SemanticVersion.Parse("1.2.3-4+BUILD");

Console.WriteLine($"{a} == {b} = {a == b}");
// 1.2.3-4 == 1.2.3-4+BUILD = true

var cmp = BuildMetadataComparer.Instance;
Console.WriteLine($"{a} === {b} = {cmp.Equals(a, b)}");
// 1.2.3-4 === 1.2.3-4+BUILD = false

SemverPreRelease

SemverPreRelease is a pre-release identifier. Can be implicitly created from strings and ints.

var pre = new SemverPreRelease[] { "alpha", 0 };
var version = new SemanticVersion(1, 2, 3, pre);

SemverOptions

SemverOptions specifies a bunch of different semantic version parsing options.

var options = SemverOptions.AllowVersionPrefix | SemverOptions.AllowInnerWhite
            | SemverOptions.OptionalMinor | SemverOptions.RemoveEmptyPreReleases;

var version = SemanticVersion.Parse("v2 -. .alpha.", options);
// Parsed as "2.0.0-alpha"

SemanticVersionBuilder

SemanticVersionBuilder can be used to manipulate semantic versions step by step.

var builder = new SemanticVersionBuilder(1, 2, 3);

builder
    .WithPatch(7)
    .AppendPreRelease("alpha");
    .AppendPreRelease(0);

var a = builder.ToVersion(); // 1.2.7-alpha.0

builder.IncrementPatch();

var b = builder.ToVersion(); // 1.2.8

builder.Increment(IncrementType.PreMinor, "beta");

var c = builder.ToVersion(); // 1.3.0-beta.0
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.1 is compatible.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.8.0 96 9/23/2024
2.7.5 129 9/15/2024
2.7.4 109 9/14/2024
2.7.3 125 9/14/2024
2.7.2 141 8/25/2024
2.7.1 131 8/22/2024
2.7.0 129 8/19/2024
2.6.1 69 7/30/2024
2.6.0 81 7/30/2024
2.5.2 100 6/12/2024
2.5.1 106 6/10/2024
2.4.1 114 6/8/2024
2.4.0 110 6/7/2024
2.3.0 157 1/23/2024
2.2.0 169 1/3/2024
2.1.0 138 1/3/2024
2.0.0 128 1/2/2024