Zonit.Extensions 10.0.0-preview.2

This is a prerelease version of Zonit.Extensions.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Zonit.Extensions --version 10.0.0-preview.2
                    
NuGet\Install-Package Zonit.Extensions -Version 10.0.0-preview.2
                    
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="Zonit.Extensions" Version="10.0.0-preview.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zonit.Extensions" Version="10.0.0-preview.2" />
                    
Directory.Packages.props
<PackageReference Include="Zonit.Extensions" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zonit.Extensions --version 10.0.0-preview.2
                    
#r "nuget: Zonit.Extensions, 10.0.0-preview.2"
                    
#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.
#:package Zonit.Extensions@10.0.0-preview.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zonit.Extensions&version=10.0.0-preview.2&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Zonit.Extensions&version=10.0.0-preview.2&prerelease
                    
Install as a Cake Tool

Zonit.Extensions

Lightweight, framework-agnostic value-object foundation for the Zonit.Extensions ecosystem. AOT-safe, trim-safe, no external dependencies beyond the BCL.

NuGet Downloads

dotnet add package Zonit.Extensions

What's inside

Category Types
Identity / Auth Identity, Credential, Permission, Role
Tenancy Organization, Project
Localization Culture, Translated
Money Price, Money, Currency
Text Title, Description, Content, UrlSlug, Url
Visual / files Color (OKLCH), Asset (signature-based MIME), FileSize
Time Schedule

Plus utilities:

  • Exceptions/ — Structured exception handling with i18n hooks and strongly-typed parameters.
  • Reflection/ — Discovery of assemblies / types implementing a given base.
  • Xml/ — Lossless object ↔ XML serialization helper.

Value object pattern

Every VO follows the same shape so that consumers can treat them uniformly:

  • readonly struct, IEquatable<T>, IParsable<T>
  • Empty static, HasValue flag (semantically distinct from default)
  • Hand-written JsonConverter (no reflection, AOT-safe)
  • TypeConverter for ASP.NET Core model binding / IConfiguration
  • Implicit conversion to/from primitive (Guid, string) where it makes sense
  • Persist only the Id for composite VOs; rehydrate the snapshot via the consumer's database extension

Highlights

Permission (wildcard authorization tokens)

Permission read   = "orders.read";
Permission writeAll = "orders.*";
bool ok = writeAll.Implies(read);   // true — wildcards expand

Used by Zonit.Extensions.Auth to drive [RequirePermission("orders.read")].

Identity (lightweight actor snapshot)

var actor = new Identity(
    id: userId,
    name: new Title("Alice"),
    roles: [new Role("admin")],
    permissions: [Permission.Create("orders.*")]);

actor.IsInRole(new Role("admin"));        // true
actor.HasPermission("orders.read");       // true (via implicit string→Permission)

Equality by Id only — two snapshots referring to the same user compare equal regardless of hydration completeness.

Credential (auto-detect kind)

new Credential("alice@example.com").Kind;        // CredentialKind.Email
new Credential("+48 600 100 200").Kind;          // CredentialKind.Phone
new Credential(Guid.NewGuid()).Kind;             // CredentialKind.Id
new Credential("alice").Kind;                    // CredentialKind.Username

Color (OKLCH)

Color c = "#3498db";                  // implicit conversion
c.Lighten(0.1).Hex;                   // "#5BB0E5"
c.Mix(Color.FromHex("#e74c3c"), 0.5); // perceptually uniform blend

Asset (signature-based MIME)

using var fs = File.OpenRead("upload.jpg");
Asset a = fs;
a.Signature;   // SignatureType.WebP — file is actually WebP, despite extension
a.MediaType;   // "image/webp"
a.Size.Megabytes;

Persistence (EF Core)

VOs that wrap a Guid (Identity, Organization, Project) are designed to persist as a single column. Use a ValueConverter to extract the id, and a domain-side IDatabaseExtension<T> to rehydrate the snapshot when needed:

// store
modelBuilder.Entity<Order>()
    .Property(o => o.Author)
    .HasConversion(v => v.Id, id => new Identity(id));

// hydrate on demand
await repo.Extension(o => o.Author).LoadAsync();

Without the explicit Extension(...) call, Author.HasSnapshot is false and only Author.Id is populated — VOs do no implicit I/O and have no lazy-load surprise.

See also

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (9)

Showing the top 5 NuGet packages that depend on Zonit.Extensions:

Package Downloads
Zonit.Extensions.Ai.Abstractions

Core abstractions and interfaces for Zonit.Extensions.Ai. Use this package when you only need the interfaces without implementation, perfect for defining prompts in domain layers.

Zonit.Extensions.Website

ASP.NET Core and Blazor web extensions providing base components (PageBase, PageEditBase, PageViewBase), navigation services, breadcrumbs management, toast notifications, cookie handling, and data protection utilities for building modern web applications.

Zonit.Extensions.Databases.SqlServer

SQL Server provider for Zonit.Extensions.Databases - Entity Framework Core repository with fluent query API, ThenInclude, DTO mapping, and full-text search support.

Zonit.Extensions.Cultures

Culture, language and translation services for Zonit applications. Provides ICultureProvider, ILanguageProvider, translation repositories, and ASP.NET Core middleware. Built on top of Zonit.Extensions value objects (Culture, Translated).

Zonit.Extensions.Organizations

Organization (tenant / workspace) services for Zonit applications. Provides IWorkspaceProvider, IOrganizationManager, organization repositories and middleware. Built on top of Zonit.Extensions value objects (Organization).

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
10.0.0-preview.9 0 5/16/2026
10.0.0-preview.6 33 5/15/2026
10.0.0-preview.2 57 5/12/2026
10.0.0-preview.1 68 5/8/2026
0.2.12 148 5/8/2026
0.2.11 2,792 4/19/2026
0.2.10 2,437 1/22/2026
0.2.9 442 1/21/2026
0.2.8 657 1/21/2026
0.2.7 2,241 1/16/2026
0.2.6 138 1/15/2026
0.2.4 147 1/15/2026
0.2.3 145 1/15/2026
0.2.2 131 1/15/2026
0.2.1 181 1/11/2026
0.2.0 132 1/11/2026
0.1.54 179 1/6/2026
0.1.53 184 1/4/2026
0.1.52 137 1/4/2026
0.1.51 163 1/2/2026
Loading failed