Skip to content

Changelog — SafeCoder.CommonKit

All notable changes to the library. Versions follow Semantic Versioning. Each version lists what was Added, Changed and Fixed; a breaking change says so.

[1.4.0]

Added

  • Added FilePlace, the places an application keeps files in — Uploads, Temporary, Images, Videos, Audio, Media, Documents, Imports, Exports, Archives — each a folder under one root set in CkSettings.DefaultFileRoot, appsettings.json or an environment variable, or a folder of its own set in CkSettings.FileRoot. Nothing is set as shipped.
  • Added file operations to CkFile, each inside a place and never outside it: Exists, Read, ReadOrNull, Write, Copy, Move, Delete, Size, SizeOrNull, Files and FullPath. A file is never left half-written, and an existing one is replaced only with overwrite: true.
  • Added rules per place: the extensions it takes (CkSettings.FileExtensions) and the largest file it accepts (CkSettings.FileMaxBytes, 2 MB by default in CkSettings.DefaultMaxFileBytes). A file whose content does not match its extension is refused, and programs, scripts and web pages are never accepted (CkSettings.BlockedExtensions). CkFile.AllowedExtensions, BlockedExtensions, MaxBytes and IsAllowed answer the rules in force.
  • Added CkFile.SniffType, the type a file's bytes prove, IsOfType, ExtensionFor and UniqueName.
  • Added CkPayload.UseInput, which hands the request an application is serving to CkPayload once per request, from the application's middleware, and CkPayload.Input, the default text of every CkPayload reader: called with no text, FromJson(), FromForm(), FromQuery() and the others read that request. A null is still no value.

Changed

  • Breaking. Renamed CkDictionary.ToDateTime, ToDateOnly, ToGuid and ToEnum<TEnum> to DateTime, DateOnly, Guid and Enum<TEnum>. Rename the calls; nothing else changes.
  • Removed CkSettings.MaxHtmlPasses, which no method used; CkSettings.DefaultHtmlPasses is the one setting for how deeply CkText.Html decodes entities.
  • Changed CkWeb.Url to refuse a host that ends in a number but is not an IPv4 address, such as 1.2.3.4.5 or example.123, as browsers do. A host that is one, such as 127.1, is written as the dotted address.
  • Changed CkWeb.Url and the other CkWeb methods to refuse a bracketed IPv6 host that has text after the ] other than a port, such as http://[::1]x/, and an embedded IPv4 address with a leading zero, such as http://[::ffff:1.2.3.04]/, as .NET 11 does.
  • Changed CkWeb.Url and the other CkWeb methods to refuse a host that holds an invisible or control character or a non-ASCII digit, rather than cleaning it, and a host name that cannot be written in ASCII.
  • Changed CkWeb.Explain, and the reason the throw switch gives, to say "not an http or https URL" for any value that opens with another scheme and "not a valid host name" for a bracketed host holding a character outside ASCII, before the runtime's own parser has a say; the values were refused before, with a reason that could depend on the runtime.

Fixed

  • Fixed an issue where CkPayload.FromForm could accept multipart fields beyond the input limit.
  • Breaking fix. CkDictionary readers now match keys case-sensitively in every dictionary, including dictionaries configured to ignore case.
  • Fixed an issue where CkGeo.Distance and IsWithin could disagree about equivalent locations.
  • Fixed an issue where CkFile.Files could list links that the file readers refuse.

  • Fixed an issue where CkNumber.Clamp could answer the lower bound for a 128-bit value above the top when both bounds were too close to tell apart as decimals.

  • Fixed an issue where CkFile.FileName, IsSafeFileName, RelativePath and IsRelativePath did not treat COM0, LPT0 and COM¹ to LPT³ as reserved Windows names.
  • Fixed an issue where CkDateTime.ToDateTime, CkDate.ToDateOnly and the other date methods refused ISO 8601 text with a space, minutes and a zone, such as 2026-08-31 14:05+02:00.
  • Fixed an issue where CkDateTime.Explain and CkDate.Explain could say a date was outside the calendar when only its zone was wrong, as in 2026-08-31Z.
  • Fixed an issue where CkDateTime.Add, AddDays, AddMonths, AddYears, StartOfDay and StartOfNextDay could answer the wrong moment when the result fell on a day a zone skipped, such as 30 December 2011 in Samoa; the time now moves on past the gap.
  • Fixed an issue where a value read with an assumeZone on a day the zone skipped was read as a real moment instead of being refused.
  • Fixed an issue where CkWeb.IsPublicHost could accept some host names that point to an internal address.
  • Fixed an issue where CkIP.IsPublic, IsInternal and CkWeb.IsPublicHost could judge the IPv6 benchmarking block 2001:2::/48, the IPv4-translated form ::ffff:0:a.b.c.d, the local-use NAT64 block 64:ff9b:1::/48, the IPv4-compatible form ::a.b.c.d and the ISATAP form …:5efe:a.b.c.d wrapping an internal IPv4 address public.
  • Fixed an issue where CkWeb.Url and RemoveQuery could hand out a URL longer than Url accepts.
  • Fixed an issue where CkWeb.Domain, IsPublicHost, IsIpHost, SameOrigin and InDomains could fail on a host that Url accepted.
  • Fixed an issue where CkWeb.Domain, SameOrigin and InDomains could include the zone id of an IPv6 host.
  • Fixed an issue where CkWeb.Url and the other CkWeb methods could accept a host that, once written in ASCII, holds a character no host name may hold, such as a | typed as its full-width look-alike.

[1.3.2]

Changed

  • Breaking. The library targets .NET 9 instead of .NET 8, so an application on .NET 8 can no longer reference it.
  • Changed CkSettings.DefaultAssumeZone: once set, every DateTime the library hands out is on that zone's clock instead of UTC, so a value read and saved again never shifts. Iso8601 and Unix still write the true moment. Left null, as shipped, nothing changes.

Fixed

  • Fixed an issue where a placeholder date such as 1900-01-01 could be read as a real date when an assumeZone was set.
  • Fixed an issue where CkDate.IsPlaceholder could disagree with the readers about a placeholder.

[1.3.1]

Changed

  • A zone or assumeZone the library does not know now counts as UTC instead of refusing the value.

Fixed

  • Fixed an issue where CkDictionary.ToDateTime handed back a DateTime not marked as UTC for a missing entry.
  • Fixed an issue where CkDictionary.ToDateTime and ToDateOnly could hand back a placeholder fallback such as 1900-01-01.
  • Fixed an issue where CkDateTime.IsIso8601 could accept a moment before year one.
  • Fixed an issue where CkDate.Explain, IsDate and IsPlaceholder could answer for the day before when given an assumeZone.
  • Fixed an issue where a CkDate method given a zone could accept a moment past the end of year 9999.

[1.3.0]

CkDate is split in two — CkDate for calendar days, the new CkDateTime for moments — a breaking change for callers of the methods that moved. CkMoney gains the calculations a payment needs.

Added

  • CkDateTime, for moments, handed out in UTC: the methods that moved from CkDate (see Changed), plus Add, AddYears, AddMonths, AddDays, AddHours, AddMinutes, AddSeconds, StartOfDay, StartOfNextDay, IsPast, IsFuture, IsBetween, IsDateTime, SameDay and Explain, all safe across daylight saving.
  • CkSettings.DefaultZone and DefaultAssumeZone — the application's time zone, set once — and a zone parameter on every CkDate method that answers a day and on CkDictionary.ToDateOnly.
  • CkDate.Add, AddDays, AddMonths, AddYears, AddWeekdays, MonthsBetween, WeekdaysBetween, WeekOfYear, StartOfWeek, EndOfWeek, StartOfQuarter, EndOfQuarter, StartOfYear and EndOfYear; CkSettings.MaxHolidays and MaxWeekdaysToAdd.
  • CkMoney.Allocate, Subtract, Divide, Convert, Display, Decimals, NumericCode and CurrencyOf; textCase on Currency; decimals and scale on MinorUnits, FromMinorUnits, Format and IsRounded, with CkSettings.MaxMoneyDecimals. Every currency parameter also reads the numeric code, such as "978".
  • The currencies XCG, VED and KPW.
  • CkCountry reads "Vatican" as VA.
  • CkIntl.CallingCode.
  • CkGeo.ToWkt, ToGeoJson, BoundsAround and Destination; CkSettings.BoundsMarginDegrees.

Changed

  • Breaking: CkDate is split in two. ToDateTime, ToDateTimeOrNull, ToTimeOnly, ToTimeOnlyOrNull, Unix, InZone, TimeAgo, HasTime, IsTime and IsIso8601 moved to CkDateTime: replace CkDate. with CkDateTime. at each call. Iso8601, Format, IsBefore and IsAfter are in both, to the day in CkDate and to the moment in CkDateTime.
  • Breaking for some calls. The new zone parameter of CkDate and country parameter of CkIntl's phone methods sit before the optional ones, so a call that passed those by position must now name them.
  • CkIntl.Phone, IsPhone, SamePhone, PhoneMask and Explain take a country for a national number: Phone("020 7946 0958", country: "GB") is "+442079460958". Phone also reads tel: links.
  • CkIntl.PostalCode and IsPostalCode know 181 countries and territories, up from 52.
  • CkGeo.TryParse, Latitude and Longitude read WKT and GeoJSON points.
  • CkMoney.Explain takes an optional currency.
  • When a key repeats in a JSON payload, the last value wins.
  • A bare number reads as a Unix timestamp up to the end of year 9999, where it stopped at 2099.
  • CkText.Between is capped at CkSettings.MaxHtmlInputLength.
  • CkFile.IsSafeFileName is false for a name that contains an invisible character.

Fixed

  • Breaking for some inputs. A date with no time of day is no longer moved to the day before by assumeZone.
  • Breaking for some inputs. CkMoney refuses an amount whose text names a different currency from the one asked for, instead of reading it with the wrong decimals, and SameAmount, IsAtLeast, IsAtMost, IsBetween and Total no longer mix currencies.
  • Fixed an issue where CkDateTime.ToDateTime, Add, AddDays, AddMonths, AddYears, StartOfDay and StartOfNextDay could answer a moment at the calendar's edge instead of refusing it.
  • Fixed an issue where assumeZone moved a moment written with a one-digit offset such as +2:00.
  • Fixed an issue where CkFile.FileName could cut an over-long name in the middle of a character.
  • Fixed an issue where CkFile.FromBase64 decoded text that IsBase64 refuses.
  • Fixed an issue where CkWeb.AddQuery could return a URL longer than Url accepts.
  • Fixed an issue where CkIP.Mask masked an IPv4 address written in IPv6 form as "0:0:0:***".
  • Fixed an issue where CkIP.IsPublic and CkWeb.IsPublicHost said true for some internal addresses.
  • Fixed an issue where some markup could survive CkText.String, Html, Name, Address and ToAscii.
  • Fixed an issue where CkText.Html kept some control characters.
  • Fixed an issue where CkText.Mask could leave an invisible character or an emoji visible.
  • Fixed an issue where an incomplete character could pass through the cleaners unchanged.
  • Fixed an issue where CkCountry could read a country out of a value that contains digits.
  • Fixed an issue where CkEmail accepted some look-alike domain names.
  • Fixed an issue where a JSON number too large for a double reached CkDictionary.Value and At as infinity.
  • Fixed an issue where a JSON payload with a broken escape was refused with an internal error message.
  • Fixed an issue where CkNumber.Clamp handed back NaN when a bound was NaN.

[1.2.1]

Fixed

  • Fixed an issue where a value padded with spaces past its reader's length limit was rejected; a padded "yes" reads as true again.
  • Fixed an issue where CkDictionary.String wrote nothing for nint and nuint, and CkSentinel.ToNull let their zero through.

[1.2.0]

Booleans get a class of their own, and the library one boolean rule.

Added

  • CkBool — a real bool, a word (true, yes, on, false, no, off and their short forms) or exactly 1 or 0; anything else is unreadable, never false. FromValue, FromNumber and FromText, each with an …OrNull twin; IsBool, IsTrue, IsFalse; Format with the new BoolFormat enum; Explain.
  • CkBoolException, CkSettings.MaxBoolInputLength and CkSettings.DefaultBoolFormat.

Changed

  • Breaking for some inputs. CkDictionary.Bool and CkText.BoolToString read through CkBool: 2 no longer reads as true, and "1.0" and "01" now do.

[1.1.0]

A validator beside every reader, an Explain on every class, the everyday helpers, and the library on .NET 8.

Added

  • Validators on every class — CkText.IsEmpty, CkEmail.IsAddress, CkNumber.IsBetween and the rest — for code that needs a yes or no rather than a cleaned value; the counters CkText.WordCount and CharacterCount; CkSettings.DefaultAdultAge and MaxDecimalPlaces.
  • Explain on every class with a reader: the reason as text, "" when the value passes.
  • CkDictionary reads dotted paths through nested maps; At, Has, MissingKeys.
  • CkDate.InZone, DaysBetween, StartOfMonth, EndOfMonth, Quarter, TimeAgo.
  • CkNumber.Clamp<T>, Round, Divide.
  • CkText.ToAscii, Initials, Between, Plural, Ordinal.
  • CkFile.Combine, SizeToString, MediaType, ToDataUri.
  • CkPayload.FromCsv and FromCsvMaps.
  • CkIP.Anonymize, CkUuid.NewV7, CkCountry.Flag, CkUS.IsPoBox, CkMoney.Multiply and Total, CkWeb.AddQuery and RemoveQuery.
  • CkIntl.PostalCode and IsPostalCode.
  • CkSettings.DefaultThrowIfInvalid, the default of every throwIfInvalid.
  • CkText.Truncate takes throwIfInvalid.

Changed

  • The library targets .NET 8 instead of .NET 10, so every .NET 8 or newer application can use it.
  • One package dependency, TimeZoneConverter, so time-zone ids resolve the same on every host.
  • The library is licensed under MIT, with the LICENSE file in the package.
  • Breaking for some inputs. Every reader composes accents (Unicode NFC) on the way in; a dotted CkDictionary key reads a nested map; and CkFile.RelativePath, CkUS.RoutingNumber, CkWeb.Url, CkIP.Address and CkNumber.Decimal refuse some values they accepted.
  • CkDate reads the ISO 8601 form written with a space, with fractions and an offset.
  • CkNumber reads a boxed Half or BigInteger; Clamp falls back to the lower bound when no fallback is given.

Fixed

  • Fixed an issue where assumeZone was skipped for a value whose format puts dashes after the clock.
  • Fixed an issue where CkDate.Age and IsAdult counted a birth with a time on the as-of day as after it.
  • Fixed an issue where CkEmail.HasDisplayName did not read a name before an address without brackets.
  • Fixed an issue where CkText.Html, CkIntl.Phone and CkUS.Phone could depend on the machine's language settings.

[1.0.0]

The first release: sixteen static helper classes that read, clean, validate and convert values on their way between the wire, the application and the database. Nothing throws unless asked — throwIfInvalid: true raises the class's own Ck*Exception — and a value that cannot be used comes back as the caller's fallback, an empty value or a declared sentinel instead. The …OrNull readers answer null.

  • Text and identity: CkText, CkEmail, CkUS, CkIntl, CkCountry, CkUuid, CkIP.
  • Numbers, money, time and place: CkNumber, CkMoney, CkDate, CkGeo.
  • Files and the web: CkFile, CkWeb.
  • Payloads: CkPayload (JSON, form bodies and query strings into one standard shape) and CkDictionary (typed values out of it).