Skip to content

Getting started

This page takes you from nothing to your first CommonKit call. It assumes you can run dotnet commands in a terminal — nothing more.

What you need

  • The .NET 8 SDK or newer (the library targets net8.0; it is built with the .NET 10 SDK and tested on .NET 8, 9 and 10). Check with dotnet --version.
  • Any editor. Visual Studio, VS Code or Rider all work.

Step 1 — get the library

There is no NuGet package yet (one is planned). For now, the library travels as source: copy the SafeCoder.CommonKit folder — the one that holds SafeCoder.CommonKit.csproj — next to your own project. A typical layout:

MySolution/
├── MyApp/
│   └── MyApp.csproj
└── SafeCoder.CommonKit/
    └── SafeCoder.CommonKit.csproj

Step 2 — reference it

Tell your project to use the library. From the solution folder:

dotnet sln add SafeCoder.CommonKit/SafeCoder.CommonKit.csproj
dotnet add MyApp reference ../SafeCoder.CommonKit/SafeCoder.CommonKit.csproj

(If you don't use a solution file, the second command alone is enough.)

That's it. The library pulls in one small package, TimeZoneConverter, for time-zone id mapping — nothing else.

Step 3 — make your first call

Add the using line at the top of a file, then call any class:

using SafeCoder.CommonKit;

string name = CkText.Name("  mary-jane  smith ");     // -> "Mary-Jane Smith"
decimal price = CkMoney.Amount("$1,299.99");          // -> 1299.99m
string country = CkCountry.Alpha2("U.S.A.");          // -> "US"

Console.WriteLine($"{name} from {country} pays {price}");

Run it. Notice what you did not write: no try/catch, no null checks, no TryParse dance. That is the whole idea — bad input gives you a calm, predictable value instead of an exception. What those values are, and how to change them, is on How it works.

The three namespaces

Namespace What lives there
SafeCoder.CommonKit the eighteen helper classes — you almost always need only this one
SafeCoder.CommonKit.Enums small option enums like DateOrder and TextCase
SafeCoder.CommonKit.Exceptions the Ck…Exception types, if you opt into throwing

Where next

  • Your first payload — a fifteen-minute tutorial: a messy order payload to clean, typed values, and the whole handler at the end.
  • How it works — the five rules, and which reader to call.
  • Common mistakes — the twelve traps everyone hits once.
  • Or jump straight to a class page — CkText is a good first stop.