Headless.Extensions
0.4.15
dotnet add package Headless.Extensions --version 0.4.15
NuGet\Install-Package Headless.Extensions -Version 0.4.15
<PackageReference Include="Headless.Extensions" Version="0.4.15" />
<PackageVersion Include="Headless.Extensions" Version="0.4.15" />
<PackageReference Include="Headless.Extensions" />
paket add Headless.Extensions --version 0.4.15
#r "nuget: Headless.Extensions, 0.4.15"
#:package Headless.Extensions@0.4.15
#addin nuget:?package=Headless.Extensions&version=0.4.15
#tool nuget:?package=Headless.Extensions&version=0.4.15
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 typesResultErrorhierarchy -NotFoundError,UnauthorizedError,ForbiddenError,ConflictError,ValidationError,AggregateErrorErrorDescriptor- Standardized error reporting with code, description, severity, and params
Primitives (Source-generated with JSON/TypeConverter support):
UserId/AccountId- Strongly-typed identifiersMoney- Currency-aware decimal with arithmetic operatorsMonth- Month representationPhoneNumber- E.164 phone numberImage/File- Media metadataPageMetadata- SEO metadataTenantInformation- Tenant data
Domain Value Objects:
Currency,GeoCoordinate,FullGeoCoordinate,Range<T>,PreferredLocale,OrderBy,NameValue<T>,ExtraProperties,Locales,TimeUnitID Generation:
IGuidGenerator(sequential GUIDs for SQL Server/MySQL/Oracle),ILongIdGenerator(SnowflakeId)Pagination:
IndexPageRequest/IndexPage<T>andContinuationPageRequest/ContinuationPage<T>Collections:
ParallelForEachAsync,DetectChanges,EquatableArray<T>,ComparerFactory,TypeListLINQ:
PredicateBuilderfor composing EF Core expressions (And,Or,Not)Dates & Time: Fluent date manipulation,
TimeProviderextensions, timezone conversion,ChangeableTimezoneTimeProviderStrings: Humanize integration, truncation, manipulation helpers
Constants:
RegexPatterns(email, URL, IP, etc.),ContentTypes,HttpHeaderNames,JwtClaimTypes,UserClaimTypes,LanguageCodesReflection: Fast property accessors, type scanning, IL emit helpers,
AssemblyInformationHTTP:
BasicAuthenticationValue,HttpStatusCodeExtensionsExceptions:
EntityNotFoundException,ConflictExceptionValidation:
MobilePhoneNumberValidator,GeoCoordinateValidator,EmailValidator,EgyptianNationalIdValidatorHelpers:
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.ChecksHeadless.Generator.Primitives(source generator)Headless.Generator.Primitives.AbstractionsCommunityToolkit.HighPerformanceHumanizer.CoreIdGenlibphonenumber-csharpMicrosoft.Bcl.TimeProviderMimeTypesmorelinqNito.AsyncExNito.DisposablesPolly.CoreSystem.ReactiveTimeZoneConverter
Side Effects
None.
| Product | Versions 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. |
-
net10.0
- CommunityToolkit.HighPerformance (>= 8.4.2)
- Headless.Checks (>= 0.4.15)
- Headless.Generator.Primitives.Abstractions (>= 0.4.15)
- Humanizer.Core (>= 3.0.10)
- IdGen (>= 3.0.7)
- JetBrains.Annotations (>= 2025.2.4)
- libphonenumber-csharp (>= 9.0.30)
- Microsoft.Bcl.TimeProvider (>= 10.0.8)
- morelinq (>= 4.4.0)
- Nito.AsyncEx (>= 5.1.2)
- Nito.Disposables (>= 2.5.0)
- Polly.Core (>= 8.6.6)
- System.Reactive (>= 6.1.0)
- TimeZoneConverter (>= 7.2.0)
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.