Guint 2.0.1

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

// Install Guint as a Cake Tool
#tool nuget:?package=Guint&version=2.0.1

Guint

Sure! int's make pretty primary keys! They're fast! Easy to share! Easy to communicate!

Yes, but...

  • Now I can enumerate your primary keys. One little authorization oversight and all your data are belong to me, thank you
  • And, ha! all your competitors and future investors can exactly see how many records you actually have, thanks again!
  • And, no proper domain-centric architecture or CQS for you, my friend, with your database dictating id's. Back to 2005 🦕 do not collect $200 👋

So what should I do?

Change the primary key to Guid

But I can't!*

Then, use Guint

Take your int and transform it to an Guid and the other way around. So have your int as a primary key in your database, but expose it as a Guid

In other words: Have your cake and eat it too!

Show me how

public async Task<IHttpActionResult> Get(Guid id)
    => id
        .ToInt()
        .Match(
            i => this.carService.Get(i),
            notfound => NotFound());
}

Setup

  1. Generate your personal secret. Go to https://dotnetfiddle.net/2x6cA6 or run var secret = Guint.GenerateSecret();

  2. Initialize Guint at the start of your application with Guint.Use(secret)

  3. To transform, use extension methods .ToGuid, .ToInt, .ToIntOrDefault or .ToGuidOrExplode


* For reasons!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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.
  • .NETStandard 2.0

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.0.1 106 2/12/2024
2.0.0 126 2/9/2024
2.0.0-beta.5 51 2/9/2024
2.0.0-beta.4 59 2/8/2024
2.0.0-beta.3 44 2/8/2024
2.0.0-beta.2 50 2/6/2024
2.0.0-beta.1 45 2/2/2024
1.1.5 682 3/25/2022
1.1.4 410 3/25/2022
1.1.3 403 3/24/2022
1.1.2 404 2/17/2022
1.1.1 443 2/14/2022
1.1.0 434 1/24/2022
1.0.0 420 1/21/2022