Headless.Core
0.4.15
dotnet add package Headless.Core --version 0.4.15
NuGet\Install-Package Headless.Core -Version 0.4.15
<PackageReference Include="Headless.Core" Version="0.4.15" />
<PackageVersion Include="Headless.Core" Version="0.4.15" />
<PackageReference Include="Headless.Core" />
paket add Headless.Core --version 0.4.15
#r "nuget: Headless.Core, 0.4.15"
#:package Headless.Core@0.4.15
#addin nuget:?package=Headless.Core&version=0.4.15
#tool nuget:?package=Headless.Core&version=0.4.15
Headless.Core
Core abstractions and utilities for building applications with multi-tenancy, user context, and cross-cutting concerns.
Problem Solved
Provides standardized interfaces for common cross-cutting concerns (clock, user, tenant, locale, timezone conversion) and utilities (retry logic, compression, structured logging) enabling consistent patterns across all application layers.
Key Features
Abstractions:
IClock- Testable time abstraction (wrapsTimeProvider)ICurrentUser- Current authenticated user context with roles and claimsICurrentTenant- Multi-tenancy support with scoped tenant switchingITenantWriteGuardBypass- Explicit bypass scope for audited host/admin tenant writesCrossTenantWriteException- Non-transient exception for blocked tenant-owned writesICurrentLocale- Localization context (language, locale, culture)ICurrentTimeZone- Timezone handlingICurrentPrincipalAccessor- ScopedClaimsPrincipalaccess with temporary switchingIPasswordGenerator- Configurable secure password generationICancellationTokenProvider- Cancellation token access with fallback logicITimezoneProvider- Windows/IANA timezone conversion and listingIApplicationInformationAccessor/IBuildInformationAccessor- Application metadata and build infoIEnumLocaleAccessor- Localized enum display valuesIHaveLogger/IHaveTimeProvider- Mixin interfaces for logger and time provider access
Utilities:
Run- Retry helper with exponential backoff (WithRetriesAsync,DelayedAsync)SnappyCompressor- Snappy compression/decompression with JSON serialization (AOT-compatible)LogState/LoggerExtensions- Structured logging with fluent state builder, tags, and scoped properties
Installation
dotnet add package Headless.Core
Quick Start
public sealed class OrderService(IClock clock, ICurrentUser user, ICurrentTenant tenant)
{
public Order CreateOrder(CreateOrderRequest request)
{
return new Order
{
Id = Guid.NewGuid(),
UserId = user.UserId!.Value,
TenantId = tenant.Id,
CreatedAt = clock.UtcNow,
Total = new Money(request.Amount, request.Currency)
};
}
}
Structured Logging
logger.LogInformation(
s => s.Tag("orders").Property("orderId", orderId),
"Order {OrderId} created",
orderId
);
Retry with Backoff
var result = await Run.WithRetriesAsync(
async ct => await httpClient.GetAsync(url, ct),
maxAttempts: 3,
logger: logger
);
Configuration
No configuration required. Implementations are registered by Headless.Api or other host packages.
Dependencies
Headless.ChecksHeadless.ExtensionsHeadless.Serializer.JsonMicrosoft.Extensions.Logging.AbstractionsSnappier
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.Extensions (>= 0.4.15)
- Headless.Serializer.Json (>= 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)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.8)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.8)
- morelinq (>= 4.4.0)
- Nito.AsyncEx (>= 5.1.2)
- Nito.Disposables (>= 2.5.0)
- Polly.Core (>= 8.6.6)
- Snappier (>= 1.3.1)
- System.Reactive (>= 6.1.0)
- TimeZoneConverter (>= 7.2.0)
NuGet packages (7)
Showing the top 5 NuGet packages that depend on Headless.Core:
| Package | Downloads |
|---|---|
|
Headless.Api.Abstractions
Package Description |
|
|
Headless.Blobs.Azure
Package Description |
|
|
Headless.Features.Core
Package Description |
|
|
Headless.Api.Core
Package Description |
|
|
Headless.Blobs.Aws
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.