Headless.Extensions 0.4.15

dotnet add package Headless.Extensions --version 0.4.15
                    
NuGet\Install-Package Headless.Extensions -Version 0.4.15
                    
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="Headless.Extensions" Version="0.4.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Headless.Extensions" Version="0.4.15" />
                    
Directory.Packages.props
<PackageReference Include="Headless.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 Headless.Extensions --version 0.4.15
                    
#r "nuget: Headless.Extensions, 0.4.15"
                    
#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 Headless.Extensions@0.4.15
                    
#: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=Headless.Extensions&version=0.4.15
                    
Install as a Cake Addin
#tool nuget:?package=Headless.Extensions&version=0.4.15
                    
Install as a Cake Tool

Headless.Extensions

Foundational utility library providing extension methods, primitives, helpers, and common abstractions used throughout the framework.

Problem Solved

Eliminates repetitive utility code across projects by providing a comprehensive set of battle-tested extensions, helpers, and primitives for common operations (strings, collections, dates, IO, reflection, etc.).

Key Features

  • Result Pattern:

    • ApiResult / ApiResult<T> - Success/failure with built-in error factories (NotFound, Conflict, Forbidden, Unauthorized, ValidationFailed)
    • Result<TValue, TError> / Result<TError> - Flexible result types with custom error types
    • ResultError hierarchy - NotFoundError, UnauthorizedError, ForbiddenError, ConflictError, ValidationError, AggregateError
    • ErrorDescriptor - Standardized error reporting with code, description, severity, and params
  • Primitives (Source-generated with JSON/TypeConverter support):

    • UserId / AccountId - Strongly-typed identifiers
    • Money - Currency-aware decimal with arithmetic operators
    • Month - Month representation
    • PhoneNumber - E.164 phone number
    • Image / File - Media metadata
    • PageMetadata - SEO metadata
    • TenantInformation - Tenant data
  • Domain Value Objects: Currency, GeoCoordinate, FullGeoCoordinate, Range<T>, PreferredLocale, OrderBy, NameValue<T>, ExtraProperties, Locales, TimeUnit

  • ID Generation: IGuidGenerator (sequential GUIDs for SQL Server/MySQL/Oracle), ILongIdGenerator (SnowflakeId)

  • Pagination: IndexPageRequest/IndexPage<T> and ContinuationPageRequest/ContinuationPage<T>

  • Collections: ParallelForEachAsync, DetectChanges, EquatableArray<T>, ComparerFactory, TypeList

  • LINQ: PredicateBuilder for composing EF Core expressions (And, Or, Not)

  • Dates & Time: Fluent date manipulation, TimeProvider extensions, timezone conversion, ChangeableTimezoneTimeProvider

  • Strings: Humanize integration, truncation, manipulation helpers

  • Constants: RegexPatterns (email, URL, IP, etc.), ContentTypes, HttpHeaderNames, JwtClaimTypes, UserClaimTypes, LanguageCodes

  • Reflection: Fast property accessors, type scanning, IL emit helpers, AssemblyInformation

  • HTTP: BasicAuthenticationValue, HttpStatusCodeExtensions

  • Exceptions: EntityNotFoundException, ConflictException

  • Validation: MobilePhoneNumberValidator, GeoCoordinateValidator, EmailValidator, EgyptianNationalIdValidator

  • Helpers: OsHelper, DisposableFactory, IpAddressHelper

Installation

dotnet add package Headless.Extensions

Quick Start

Result Pattern

public async Task<ApiResult<User>> GetUserAsync(Guid id)
{
    var user = await _repo.GetByIdAsync(id);
    if (user is null)
        return ApiResult<User>.NotFound();

    return ApiResult<User>.Ok(user);
}

Collection Extensions

await users.ParallelForEachAsync(
    async user => await ProcessUserAsync(user),
    maxDegreeOfParallelism: 5
);

Change Detection

var (added, removed, existing) = oldItems.DetectChanges(
    newItems,
    areSameEntity: (old, @new) => old.Id == @new.Id
);

Expression Composition

var filter = PredicateBuilder.True<Product>()
    .And(p => p.Price > 0)
    .And(p => p.IsActive);

var products = await dbContext.Products.Where(filter).ToListAsync();

Configuration

No configuration required.

Dependencies

  • Headless.Checks
  • Headless.Generator.Primitives (source generator)
  • Headless.Generator.Primitives.Abstractions
  • CommunityToolkit.HighPerformance
  • Humanizer.Core
  • IdGen
  • libphonenumber-csharp
  • Microsoft.Bcl.TimeProvider
  • MimeTypes
  • morelinq
  • Nito.AsyncEx
  • Nito.Disposables
  • Polly.Core
  • System.Reactive
  • TimeZoneConverter

Side Effects

None.

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 (6)

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

Package Downloads
Headless.DistributedLocks.Abstractions

Package Description

Headless.Blobs.Abstractions

Package Description

Headless.FluentValidation

Package Description

Headless.Core

Package Description

Headless.Caching.Abstractions

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.15 77 5/18/2026
0.4.14 84 5/18/2026