CoreEx 4.0.0-preview-1
dotnet add package CoreEx --version 4.0.0-preview-1
NuGet\Install-Package CoreEx -Version 4.0.0-preview-1
<PackageReference Include="CoreEx" Version="4.0.0-preview-1" />
<PackageVersion Include="CoreEx" Version="4.0.0-preview-1" />
<PackageReference Include="CoreEx" />
paket add CoreEx --version 4.0.0-preview-1
#r "nuget: CoreEx, 4.0.0-preview-1"
#:package CoreEx@4.0.0-preview-1
#addin nuget:?package=CoreEx&version=4.0.0-preview-1&prerelease
#tool nuget:?package=CoreEx&version=4.0.0-preview-1&prerelease
CoreEx
The foundational
CoreExpackage providing the core runtime primitives, patterns, and abstractions used across all other CoreEx libraries and consuming services.
Overview
CoreEx is the shared kernel of the CoreEx framework. It defines the types that all other packages depend on and that consuming applications interact with every day: semantic exception types, execution context, railway-oriented result types, entity contracts, mapping, JSON utilities, hosting infrastructure, caching abstractions, localization, and more.
The package is deliberately non-opinionated — nothing forces a particular architectural style and every capability is opt-in. Teams can adopt individual namespaces incrementally, composing only what they need without taking on the full framework surface area at once.
All other CoreEx packages (CoreEx.Events, CoreEx.Database, CoreEx.AspNetCore, etc.) depend on this package, making it the natural starting point when working with the CoreEx ecosystem.
Motivation
- Reduce boilerplate — recurring patterns such as exception-to-HTTP-status mapping, entity identity, ETag handling, and audit change-log tracking are defined once and reused everywhere rather than reimplemented per project.
- Standardize errors — a rich hierarchy of semantic exception types with built-in HTTP status codes and structured error payloads removes the need for bespoke error-handling middleware.
- Explicit, expected errors — the
Result/Result<T>types bring railway-oriented programming to service code, allowing known business errors to be propagated without the overhead and noise of exceptions. - Execution context — a consistent,
AsyncLocal-based ambient context carries user identity, tenant, timestamps, and operation type across the full call chain without threading them explicitly through every method signature. - Composability — DI registration attributes, invoker tracing, and host-settings primitives are intentionally thin so they integrate into any host model without dictating structure.
Key capabilities
- 🚨 Semantic exceptions: A hierarchy of typed exceptions (
ValidationException,NotFoundException,BusinessException,ConcurrencyException, etc.) each with a pre-mapped HTTP status code, structured error type, and configurable logging enablement. - 🔐 Execution context: An
AsyncLocal-scopedExecutionContextthat carries user identity (AuthenticationUser), tenant ID, operation type, request timestamp, and arbitrary attributes throughout the lifetime of a request. - 🚂 Railway-oriented results:
ResultandResult<T>value types that represent success or a typed error without throwing, enabling functional pipeline-style error propagation for expected business outcomes. - 📦 Entity contracts: Interfaces and types for identifiers (
IIdentifier<T>), ETags (IETag), audit change logs (IChangeLog), composite keys (CompositeKey), and entity cleaning/transformation — used as the common contract shape across all CoreEx layers. - 🗺️ Explicit mapping: Uni- and Bi-directional mapper base classes and a
Mapperutility for propagating standard contract properties (identity, ETags, change logs, tenant, partition) between source and destination types without a reflection-heavy mapping library. - 🔄 JSON utilities: RFC 7396 JSON Merge Patch (
JsonMergePatch), include/exclude JSON property filtering (JsonFilter), and custom converters for common CoreEx types. - 💉 DI lifetime attributes:
[ScopedService],[SingletonService], and[TransientService]attributes that mark implementation types for automatic discovery and registration viaAddDynamicServicesUsing<T>. - ⏱️ Hosting and work orchestration: Base classes for timer-driven and synchronized hosted services, plus
WorkOrchestratorfor tracking long-running distributed work states with pluggable storage. - ⚡ Caching abstractions:
IHybridCacheandICacheKeyProviderdecouple cache consumption from provider implementation, supporting both in-process and distributed cache strategies. - 🌐 Localization:
LTextandTextProviderprovide a lightweight, key-based localization abstraction used throughout validation messages, exception text, and reference data. - 🃏 Wildcard parsing:
Wildcardprovides standardized*and?wildcard parsing, validation, andRegexcompilation for consistent wildcard-based filtering. - 🏷️ Reference data interfaces: Core
IReferenceData,IReferenceDataCollection, andReferenceDataOrchestratortypes establish the reference data contract used byCoreEx.RefDataand data-layer packages. - 📐 Schema versioning:
SchemaAttributeandSchemautilities for associating a semantic version with entity types, supporting schema-aware messaging and validation.
Key types
| Type | Description |
|---|---|
ExecutionContext |
AsyncLocal-scoped ambient context carrying user identity, tenant ID, operation type, timestamp, and attributes for the lifetime of a request. |
Result |
Value type representing a successful or failed operation with no return value; the basis of railway-oriented programming in CoreEx. |
Result<T> |
Value type representing a successful operation with a value, or a typed error — used for functional pipeline-style error propagation. |
DataConsistencyException |
Non-error exception used to signal a potential data consistency issue without treating it as an application error. |
PrecisionTimeProvider |
TimeProvider implementation that truncates timestamps to a configurable fractional-second precision for database compatibility. |
OperationType |
Enum representing the CRUD operation type (Get, Create, Update, Delete, Query) carried on the ExecutionContext. |
ExtendedException |
Abstract base for all CoreEx semantic exceptions; provides HTTP status, error type, error code, detail, and configurable logging. |
IExtendedException |
Interface defining the extended exception contract: StatusCode, ErrorType, ErrorCode, IsError, and ShouldBeLogged. |
See the Extended Exceptions section below for the full list of semantic exception types.
Errors vs Exceptions
CoreEx distinguishes between expected and unexpected errors:
| Aspect | Errors (Expected) | Exceptions (Unexpected) |
|---|---|---|
| Use For | Validation failures, business rules, "not found" | System failures, infrastructure errors |
| Types | CoreEx semantic exceptions (implement IExtendedException) |
Standard .NET, and non-semantic, exceptions |
| Benefits | Explicit error handling | Rich diagnostics (stack traces) |
| Example | Customer not found | Database connection timeout |
Extended Exceptions
Semantic (error-oriented) exception types with automatic HTTP status mapping:
| Exception | Description | HTTP Status | Error Type |
|---|---|---|---|
AuthenticationException |
User not authenticated. | 401-Unauthorized | authentication |
AuthorizationException |
User lacks permissions. | 403-Forbidden | authorization |
BusinessException |
Business rule violation (message shown to consumer). | 400-Bad Request | business |
ConcurrencyException |
Data concurrency conflict (ETag mismatch). | 412-Precondition Failed | concurrency |
ConflictException |
Data conflict (e.g., identifier already exists on create). | 409-Conflict | conflict |
DuplicateException |
Duplicate value (e.g., unique code already in use). | 409-Conflict | duplicate |
NotFoundException |
Entity not found. | 404-Not Found | not-found |
TransientException |
Transient failure (retry candidate). | 503-Service Unavailable | transient |
ValidationException |
Validation failure with message collection. | 400-Bad Request | validation |
All inherit from ExtendedException<TSelf> implementing IExtendedException.
Additionally, these support With*-style methods to add additional context that is added to the resulting ProblemDetails:
throw new BusinessException($"Product '{movement.ProductId}' does not have sufficient quantity on hand.")
.WithErrorCode("insufficient-quantity")
.WithKey(movement.ProductId);
The above would result in the following ProblemDetails:
{
"type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
"title": "Product \u002700000001-0000-0000-0000-000000000000\u0027 does not have sufficient quantity on hand.",
"status": 400,
"traceId": "00-a8e8623ef74c2b53820d0ff5d799850d-df28b0bc787429f5-01",
"errorType": "business",
"errorCode": "insufficient-quantity",
"key": "00000001-0000-0000-0000-000000000000"
}
Namespaces
| Namespace | Description | Documentation |
|---|---|---|
CoreEx.Caching |
IHybridCache abstraction and ICacheKeyProvider for decoupled local and/or distributed caching. |
📖 README |
CoreEx.Data |
Lightweight data-access primitives: paging, query arguments, partition keys, tenant IDs, logical deletion, and ItemsResult<T>. |
📖 README |
CoreEx.DependencyInjection |
Service lifetime attributes ([ScopedService], [SingletonService], [TransientService]) for attribute-driven DI registration. |
📖 README |
CoreEx.Entities |
Entity contract interfaces and types: identifiers, ETags, change logs, composite keys, string transforms, and entity cleaning. | 📖 README |
CoreEx.Globalization |
TextInfoCasing and globalization extensions for culture-aware string casing transformations. |
📖 README |
CoreEx.HealthChecks |
Health check extensions and HealthCheckTags constants for standardizing CoreEx service health reporting. |
📖 README |
CoreEx.Hosting |
Timer and synchronized hosted service base classes, HostSettings, WorkOrchestrator, and distributed work state tracking. |
📖 README |
CoreEx.Http |
HTTP primitives: ProblemDetails, IdempotencyKeyHandler, HttpNames, and HTTP request/response extensions. |
📖 README |
CoreEx.Invokers |
Invocation pipeline abstractions providing automatic OpenTelemetry tracing and structured logging around service operations. | 📖 README |
CoreEx.Json |
JSON Merge Patch (RFC 7396), JSON property filtering, and custom converters for CoreEx entity types. | 📖 README |
CoreEx.Localization |
LText localization-agnostic text value and TextProvider for key-based message resolution. |
📖 README |
CoreEx.Mapping |
Explicit bi-directional mapper base classes, Mapper standard-property utilities, and IConverter value converters. |
📖 README |
CoreEx.Metadata |
RuntimeMetadata and IPropertyRuntimeMetadata for compile-time and reflection-based property introspection on contract types. |
📖 README |
CoreEx.RefData |
Core reference data interfaces, ReferenceDataOrchestrator, and provider abstractions consumed by CoreEx.RefData. |
📖 README |
CoreEx.Results |
Result and Result<T> railway-oriented types with a full suite of functional extension methods. |
📖 README |
CoreEx.Schemas |
SchemaAttribute and Schema utilities for associating semantic version metadata with entity types. |
📖 README |
CoreEx.Security |
AuthenticationUser record and AuthenticationType enum representing the authenticated user on the ExecutionContext. |
📖 README |
CoreEx.Text |
SentenceCase utility for converting identifier-style strings into human-readable sentence-case text. |
📖 README |
CoreEx.Validation |
Lightweight validation interfaces (IValidator<T>, MultiValidator) used as the validation contract across CoreEx. |
📖 README |
CoreEx.Wildcards |
Wildcard parser, validator, and Regex compiler for standardized * and ? wildcard-based text matching. |
📖 README |
Related Namespaces
CoreEx.AspNetCore- ASP.NET Core integration:WebApiHTTP helpers,IExtendedExceptionmiddleware, andExecutionContextmiddleware binding.CoreEx.Validation- Full validation rule engine built on top of theIValidator<T>contract defined in this package.CoreEx.Events- Event publishing and subscribing built on top of theExecutionContext,Result, and entity contracts from this package.CoreEx.Database- Database access layer built on the data primitives (PagingArgs,QueryArgs,IIdentifier) defined here.CoreEx.EntityFrameworkCore- Entity Framework Core integration consuming the entity contracts and mapping types from this package.CoreEx.RefData- Full reference data implementation extending theIReferenceDataandReferenceDataOrchestratortypes defined here.CoreEx.UnitTesting- Test helpers and fluent assertion extensions targeting the types and patterns from this package. (test only)
AI Usage Guide
An AGENTS.md file is included with this package. AI coding assistants (GitHub Copilot, Claude, Cursor, etc.) that support workspace-injected package documentation will automatically surface concise usage guidance, code examples, and Do Not rules for this package without requiring a local CoreEx checkout.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. 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
- Microsoft.Extensions.Caching.Memory (>= 10.0.3)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.3)
- Microsoft.Extensions.Http.Resilience (>= 10.3.0)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Process (>= 1.15.1-beta.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- System.Memory.Data (>= 10.0.3)
-
net8.0
- Microsoft.Extensions.Caching.Memory (>= 8.0.1)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.24)
- Microsoft.Extensions.Http.Resilience (>= 8.10.0)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Process (>= 1.15.1-beta.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- System.Memory.Data (>= 8.0.1)
-
net9.0
- Microsoft.Extensions.Caching.Memory (>= 9.0.13)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 9.0.13)
- Microsoft.Extensions.Http.Resilience (>= 9.10.0)
- OpenTelemetry.Extensions.Hosting (>= 1.15.3)
- OpenTelemetry.Instrumentation.Http (>= 1.15.1)
- OpenTelemetry.Instrumentation.Process (>= 1.15.1-beta.1)
- OpenTelemetry.Instrumentation.Runtime (>= 1.15.1)
- System.Memory.Data (>= 9.0.13)
NuGet packages (23)
Showing the top 5 NuGet packages that depend on CoreEx:
| Package | Downloads |
|---|---|
|
CoreEx.Database
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.Newtonsoft
CoreEx .NET Newtonsoft Extensions. |
|
|
CoreEx.Azure
CoreEx .NET Azure Extensions. |
|
|
CoreEx.Database.SqlServer
Core .NET extensions and abstractions for the development of backend services. |
|
|
CoreEx.Validation
Core .NET extensions and abstractions for the development of backend services. |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on CoreEx:
| Repository | Stars |
|---|---|
|
Avanade/Beef
The Business Entity Execution Framework (Beef) framework, and the underlying code generation, has been primarily created to support the industrialization of API development.
|
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.0-preview-1 | 44 | 6/20/2026 |
| 3.31.0 | 11,586 | 2/1/2025 |
| 3.30.2 | 919 | 12/11/2024 |
| 3.30.1 | 879 | 12/9/2024 |
| 3.30.0 | 7,438 | 11/21/2024 |
| 3.29.0 | 7,655 | 11/19/2024 |
| 3.28.0 | 924 | 11/9/2024 |
| 3.27.3 | 1,601 | 10/23/2024 |
| 3.27.2 | 840 | 10/17/2024 |
| 3.27.1 | 1,167 | 10/15/2024 |
| 3.27.0 | 1,861 | 10/11/2024 |
| 3.26.0 | 898 | 10/3/2024 |
| 3.25.6 | 1,497 | 10/2/2024 |
| 3.25.5 | 1,020 | 9/25/2024 |
| 3.25.4 | 1,045 | 9/24/2024 |
| 3.25.3 | 1,721 | 9/18/2024 |
| 3.25.2 | 913 | 9/17/2024 |
| 3.25.1 | 1,155 | 9/16/2024 |
| 3.25.0 | 1,052 | 9/10/2024 |
| 3.24.1 | 1,218 | 8/7/2024 |