Redskap 1.2.3

dotnet add package Redskap --version 1.2.3                
NuGet\Install-Package Redskap -Version 1.2.3                
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="Redskap" Version="1.2.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Redskap --version 1.2.3                
#r "nuget: Redskap, 1.2.3"                
#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 Redskap as a Cake Addin
#addin nuget:?package=Redskap&version=1.2.3

// Install Redskap as a Cake Tool
#tool nuget:?package=Redskap&version=1.2.3                

🇳🇴 Redskap

Currently there's only one utility in the library, IdentificationNumber, which lets you parse, validate and generate Norwegian National Identity Numbers. More utilities are coming!

The library targets .NET Standard 2.0 and .NET 5, which means it's supported on pretty much any .NET platform still supported by Microsoft.

Parsing

The library supports parsing fødselsnummer, D-nummer and H-nummer. This is done through the various overloads of IdentificationNumber.Parse and IdentificationNumber.TryParse. There's also a few overloads of IsValid to validate that a string is a valid identification number (of a specified type). Additionally, there are convenience methods for parsing out date of birth (using TryParseDateOfBirth) and gender (using TryParseGender) directly.

Parsing is built on modern APIs such as ReadOnlySpan<T>, which makes it really fast and completely allocation free. See benchmarks below.

Benchmarks

The results of the IsValidBenchmark:

Method Runtime Mean Error StdDev Ratio RatioSD Gen 0 Allocated
Redskap .NET 5.0 58.23 ns 0.478 ns 0.423 ns 0.60 0.01 - -
Nonin .NET 5.0 270.45 ns 3.257 ns 2.888 ns 2.79 0.04 0.0315 264 B
NoCommons .NET 5.0 923.89 ns 5.672 ns 5.306 ns 9.52 0.07 0.0458 384 B
Tedd .NET 5.0 2,354.07 ns 23.517 ns 21.998 ns 24.29 0.30 0.2975 2,512 B
NinEngine .NET 5.0 383.86 ns 3.804 ns 3.558 ns 3.96 0.04 0.0153 128 B
Redskap .NET Framework 4.7.2 96.97 ns 0.594 ns 0.527 ns 1.00 0.00 - -
Nonin .NET Framework 4.7.2 480.74 ns 7.024 ns 6.570 ns 4.95 0.06 0.0410 265 B
NoCommons .NET Framework 4.7.2 1,348.68 ns 5.854 ns 5.475 ns 13.91 0.07 0.0629 409 B
Tedd .NET Framework 4.7.2 4,086.77 ns 33.722 ns 31.544 ns 42.13 0.49 0.4349 2,760 B
NinEngine .NET Framework 4.7.2 648.94 ns 5.967 ns 5.289 ns 6.69 0.06 0.0200 128 B

Generation

The library also supports generating valid fødselsnummer, D-nummer and H-nummer. This is done through the various overloads of IdentificationNumber.Generate. These let you specify kind, gender, date of birth and/or a min- and max date. If you want to control the randomness of the generation, e.g. for unit testing, you can create your own instance of IdentificationNumber.Generator and pass in your own (seeded) Random instance. See this unit test as an example.

Benchmarks

The results of the GenerateBenchmark:

Method Runtime Mean Error StdDev Ratio RatioSD Gen 0 Gen 1 Allocated
Redskap .NET 5.0 328.0 ns 2.95 ns 2.76 ns 0.82 0.01 - - -
NoCommons .NET 5.0 2,173,367.9 ns 11,802.91 ns 10,462.97 ns 5,411.11 37.73 74.2188 7.8125 621,440 B
NinEngine .NET 5.0 2,335.9 ns 14.71 ns 13.04 ns 5.82 0.03 0.3662 - 3,090 B
Redskap .NET Framework 4.7.2 401.8 ns 1.76 ns 1.65 ns 1.00 0.00 - - -
NoCommons .NET Framework 4.7.2 2,734,492.1 ns 11,812.94 ns 11,049.83 ns 6,805.64 34.93 117.1875 11.7188 745,792 B
NinEngine .NET Framework 4.7.2 2,920.9 ns 8.30 ns 7.36 ns 7.27 0.03 0.5722 - 3,623 B
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 was computed.  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 was computed.  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.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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
1.2.3 827 10/18/2023
1.2.2 224 8/7/2023
1.2.1 267 3/22/2023
1.2.0 235 3/22/2023
1.1.0 10,042 4/20/2021
1.0.0 365 3/6/2021
1.0.0-beta.2 189 3/1/2021
1.0.0-beta.1 178 3/1/2021