NewLife.Core
Core library of NewLife framework. Provides high-performance infrastructure for building scalable applications: logging (file/network), configuration (XML/JSON/HTTP), cache (memory/distributed), network (TCP/UDP/HTTP/WebSocket), serialization (binary/XML/JSON), APM tracing, IoC container, actor model, timer scheduler, plugin framework, and more. Supports .NET Framework 4.5 to .NET 10. 核心组件库,为构建可扩展应用程序提供高性能基础设施。提供日志(文件/网络)、配置(XML/JSON/HTTP)、缓存(内存/分布式)、网络(TCP/UDP/HTTP/WebSocket)、序列化(Binary/XML/JSON)、APM性能追踪、对象容器、并行模型、定时调度、插件框架等。支持.NET Framework 4.5至.NET 10全版本。
Install
| Product | Versions |
|---|---|
| .NET | |
| .NET Standard | |
| Other |
README
NewLife.Core - Core Library
🌐 简体中文 | 繁體中文 | Español | Deutsch | 日本語 | Français | Português | Русский | 한국어 | العربية
NewLife framework is a comprehensive .NET component ecosystem that provides high-performance infrastructure for building scalable applications. It offers essential capabilities such as logging, networking, serialization, caching, and multithreading, serving as the foundation for a range of applications from web services to IoT devices.
Core library tutorial: https://newlifex.com/core
Contents: Framework Overview · Why NewLife.Core · Quick Start · Main Features · Documentation Index · Repository layout · Build and test · NewLife Project Matrix · Contributing and feedback · License
Framework Overview
NewLife is composed of multiple component libraries, with NewLife.Core providing the foundation. The framework supports multiple target frameworks from net45 to net10.0 (.NET Framework 4.5 through .NET 10.0), thereby achieving broad compatibility across different environments.
NativeAOT: The core path is supported (measured in 31 scenarios + CI regression protection); dynamic capabilities such as plugins and scripting are not supported by design, see AOT Compatibility Analysis (中文) for the boundaries.
Why NewLife.Core
- One package for common infrastructure: logging, configuration, caching, networking, serialization, scheduling, object container and DI — a single reference is enough.
- Broad version coverage: 11 target frameworks in one package (net45 → net10.0, including Windows variants), the same API for legacy systems and new projects.
- NativeAOT ready: 31 core scenarios measured and guarded by a multi-RID CI smoke matrix; boundaries in AOT Compatibility Analysis.
- Restrained dependencies, permissive license: BCL and Microsoft compatibility packages only; MIT, so you can modify and rebrand (see License).
Quick Start
Install
dotnet add package NewLife.Core
Minimal example
using NewLife.Caching;
using NewLife.Log;
XTrace.UseConsole(); // console log (also writes to file)
XTrace.WriteLine("Hello NewLife");
var cache = new MemoryCache(); // in-memory cache
cache.Set("key", "value", 60); // expires in 60 seconds
var value = cache.Get<String>("key"); // read back
Template scaffolding
Run the following commands in a command line to quickly experience NewLife components:
dotnet new install NewLife.Templates
dotnet new nconsole --name test
cd test
dotnet run
Build and customize
The team has always maintained an open attitude: it not only supports opening the solution and compiling in VisualStudio (latest release), but is also compatible with dotnet build command-line compilation. The project files abandon complex features in pursuit of simplicity and ease of use, truly ready to use out of the box.
We publish the strong-name certificate newlife.snk to support compiling and replacing assemblies on your own.
NewLife components have been co-created by the community for more than 20 years and use the MIT open source license. Anyone can modify and redistribute them at will (no need to indicate the source)! Many enterprises build internal development frameworks based on this, and can even achieve private customization by batch-replacing all NewLife strings in the source code with their company name.
Documentation Index
Usage docs
- Core Library Contents (中文): Index of core component articles
- AOT Compatibility Analysis (中文): NativeAOT support scope, measured conclusions (smoke test 31/31), usage guidance, and known boundaries
Development docs
The repository's Doc/ directory maintains a capability documentation system (requirements definition → feature tracking → architecture design):
- Requirements (中文): Vision, core goals, and functional requirements
- Feature List (中文): Implementation/test/comment status tracking for all feature points
- Architecture Design (中文): Layering, module components, and key design decisions
Main Features
Basic Extensions (9)
| Feature | Key Characteristics |
|---|---|
| Type Conversion Utility | Provides efficient type conversion with support for various formats and exception handling. |
| String Extensions StringHelper | Includes various string operations such as truncation, encoding, and formatting. |
| Path Extensions PathHelper | Intelligently handles multiple path formats to achieve cross-platform compatibility of code. |
| Data Extensions IOHelper | Optimizes IO operations, providing efficient conversion between data streams and byte arrays. |
| Process Extensions ProcessHelper | Simplifies process operations with convenient methods for obtaining and managing process information. |
| Runtime Information Runtime | Provides simple methods to obtain application runtime information, convenient for debugging and diagnostics. |
| Disposable DisposeBase | Provides a standard resource release pattern that effectively prevents memory and resource leaks. |
| Reflection Extensions Reflect | High-performance reflection tooling for fast reading and writing of object members. |
| Security Extensions SecurityHelper | Integrates RSA/AES/DES/MD5 and other encryption and decryption algorithms, simplifying security operations. |
Logging and Tracing (2)
| Feature | Key Characteristics |
|---|---|
| Logging ILog | Supports multiple log output methods and provides powerful asynchronous writing. |
| Tracing ITracer | Powerful APM performance tracing with support for integration with the Stardust platform. |
Scheduling (3)
| Feature | Key Characteristics |
|---|---|
| Advanced Timer TimerX | High-precision timer supporting Cron scheduling and asynchronous periodic execution. |
| Cron Expressions | Provides Linux Cron-like scheduled tasks with second-level matching. |
| Time Provider TimeProvider | Unified time abstraction and high-precision elapsed time calculation, convenient for cross-version compatibility. |
Configuration System (4)
| Feature | Key Characteristics |
|---|---|
| Configuration System Config | Unified configuration framework supporting multiple formats, multiple sources, and hot reload. |
| Configuration Provider IConfigProvider | Unified configuration interface supporting callbacks and a configuration node model. |
| Core Configuration Setting | Manages core component configuration, controlling basic behaviors such as logging and networking. |
| System Configuration SysConfig | Manages application system configuration with support for local, distributed, and encrypted configuration. |
Serialization (7)
| Feature | Key Characteristics |
|---|---|
| Json Serialization | High-performance Json tool supporting serialization in various complex scenarios. |
| Xml Serialization | Provides XML serialization and deserialization, supporting conversion between objects and XML. |
| Binary Serialization | High-performance binary serialization supporting complex object graphs and version control. |
| Advanced Binary Serialization | An advanced guide to zero-allocation encoding and decoding throughout protocol messages. |
| Csv Parser CsvFile | Fast reading and writing of CSV files with support for custom delimiters and data binding. |
| Csv Database CsvDb | Uses CSV files as a database, supporting basic create, read, update, and delete operations. |
| Lightweight Excel Reader ExcelReader | Reads Excel quickly without Office dependencies, supporting large data volumes. |
Caching (7)
| Feature | Key Characteristics |
|---|---|
| Unified Cache Interface ICache | Defines standard cache operations, providing multiple implementations such as memory and Redis. |
| Cache Architecture ICacheProvider | Manages and provides ICache instances, supporting multiple coexisting caches. |
| Memory Cache MemoryCache | High-performance standalone memory cache supporting expiration and capacity policies. |
| Object Pool ObjectPool | Reuses expensive objects to improve performance and reduce GC pressure. |
| Object Pool Pool | CAS-based high-performance general-purpose object pool that reduces GC pressure. |
| Distributed Cache NewLife.Redis | Redis-based distributed cache implementation supporting multiple data structures. |
| Vector Store IVectorStore | Vector collection management interface supporting Top-K similarity search, providing vector retrieval infrastructure for AI applications. |
High-Performance Buffers (7)
| Feature | Key Characteristics |
|---|---|
| Data Packet IPacket | Core data packet interface for zero-copy slicing and chained packets. |
| Buffers | High-performance buffer operation library aggregating components such as Span and pooled writers. |
| Pooled Writer PooledByteBufferWriter | ArrayPool-based pooled buffer writer supporting dynamic expansion. |
| Span Reader SpanReader | Zero-allocation high-performance binary stream parser supporting little/big endian. |
| Span Writer SpanWriter | Zero-allocation high-performance binary data writer supporting little/big endian. |
| Span Helper SpanHelper | A collection of Span/ReadOnlySpan extension methods that simplifies memory operations. |
| Sequence Reader SequenceReader | Cross-segment sequential reader (patched with shims for older frameworks, available on all 11 TFMs). |
Application Framework (16)
| Feature | Key Characteristics |
|---|---|
| Object Container ObjectContainer | Lightweight dependency injection supporting multiple lifetimes and injection patterns. |
| Lightweight Application Host Host | Simplifies application hosting to easily build long-running background services. |
| Plugin Framework IPlugin | Provides a standardized plugin management mechanism for modular application development. |
| Parallel Model Actor | Simplified concurrent programming model that improves throughput through message queue processing. |
| Pipeline Model Pipeline ⚠️ Retired, replaced by the protocol pattern (frame pump) | Bidirectional processing chain model unifying the Read/Write/Open/Close flow. |
| Deferred Queue DeferredQueue | Aggregates high-frequency changes and persists them in batches, reducing write amplification. |
| Event Bus EventBus | In-process event dispatch supporting topic routing and queue-style messages. |
| Weak Reference Delegate WeakAction | Solves the memory leak problem of event subscriptions and enables safe event handling. |
| Script Engine ScriptEngine | Supports dynamic C# compilation and execution, providing flexible scripting extensibility. |
| Compression and Decompression | Integrates multiple compression algorithms and provides a unified interface for data compression. |
| Archive Compression Tar and 7Zip | Covers advanced archive compression usage for Tar/Tar.Gz and 7Zip. |
| Machine Information MachineInfo | Comprehensively obtains hardware information with support for Windows and Linux systems. |
| Pinyin Library PinYin | Efficient Chinese character to Pinyin library supporting full and abbreviated spelling with superior performance. |
| Data Table DbTable | An in-memory data table for convenient data processing and analysis. |
| Paging Parameter PageParameter | Encapsulates paging logic, supporting pagination in various scenarios such as Web and API. |
| Snowflake Algorithm Snowflake | Distributed unique ID generation algorithm guaranteeing ID uniqueness under high concurrency. |
Security and Tokens (3)
| Feature | Key Characteristics |
|---|---|
| Distributed Digital Signature Token TokenProvider | Generates and validates distributed tokens, ensuring security between multiple nodes. |
| Web General Token JwtBuilder | Provides generation, decoding, and validation of JWT tokens, simplifying Web authentication. |
| Token HTTP Filter TokenHttpFilter | Automatically injects tokens into HTTP requests, intercepting 401/403 for automatic renewal. |
Cloud Services (1)
| Feature | Key Characteristics |
|---|---|
| Latitude/Longitude Hash GeoHash | Encodes latitude and longitude into strings for nearby location search. |
Networking (15)
| Feature | Key Characteristics |
|---|---|
| Network Server NetServer | High-performance TCP/UDP/Unix domain socket server encapsulating sessions and data handling. |
| Network Client NetClient | Unified TCP/UDP/Unix network client that simplifies connection and send/receive. |
| Message IMessage | Request-response message contract carrying direction semantics and frame read/write. |
| Message Protocol Stack MessagePump | Frame pump + stateless codec single stack supporting large streaming frame bodies and backpressure. |
| Data Pipeline Pipe | Zero-copy data pipeline aligned with the System.IO.Pipelines shape. |
| Simple Remote Message Exchange Protocol SRMP | Lightweight RPC protocol supporting binary serialization and UDP transport. |
| Load Balancing and Failover LoadBalancer | Provides three multi-node scheduling strategies: Failover, polling, and racing. |
| RPC Communication ApiServer | ⚠️ Moved to NewLife.Remoting |
| RPC Communication ApiClient | ⚠️ Moved to NewLife.Remoting |
| HTTP Client ApiHttpClient | Based on an HttpClient wrapper, simplifying the calling and handling of Web APIs. |
| HTTP Server HttpServer (Embedded Devices) | Lightweight Http server supporting middleware pipelines, parameterized routing, and static file serving. |
| Network Download WebClientX | Enhanced WebClient supporting multi-threaded and resumable downloads. |
| WebSocket Server (a powerful tool for IoT downlink notifications) | High-performance WebSocket server suitable for IoT message push. |
| WebSocket Bidirectional Communication | Introduces practices for handshake, frame handling, heartbeat, and connection close. |
| File Storage Client EasyClient | HTTP file storage client for EasyIO or OSS. |
⚠️ Baidu Maps/AMap have been extracted into separate NuGet packages.
Repository layout
| Directory | Description |
|---|---|
NewLife.Core/ |
Core library sources (logging, networking, caching, serialization, …) |
NewLife.Core.SourceGenerator/ |
Source generator shipped as analyzers/ inside the package |
Doc/ |
Capability docs and article index |
Samples/ |
Console / service / Http / IoT / mobile samples |
Benchmark/ |
BenchmarkDotNet performance benchmarks |
XUnitTest.Core/ |
Main unit tests (net10.0) |
XUnitTest.Compat/, XUnitTest.Net6/ |
Cross-version compatibility tests |
AotSmoke/ |
NativeAOT smoke project |
Build and test
dotnet build NewLife.Core/NewLife.Core.csproj -c Release
dotnet test XUnitTest.Core -c Release
- Full parallel run:
run-tests.ps1(multi-host parallel + timeout + trx summary) - NativeAOT smoke:
AotSmoke/, CI in.github/workflows/aot.yml - Benchmarks:
Benchmark/(BenchmarkDotNet)
NewLife Project Matrix
All projects support net10.0/netstandard2.1/netstandard2.0/net462/net4.5 by default; older versions (2024.0801) support net4.0/net2.0
| Project | Year | Description |
|---|---|---|
| Basic Components | Supports other middleware and product projects | |
| NewLife.Core | 2002 | Core library: logging, configuration, caching, networking, serialization, APM performance tracing |
| NewLife.XCode | 2005 | Big data middleware, single tables at the tens-of-billions scale, MySql/SQLite/SqlServer/Oracle/PostgreSql/DaMeng, automatic table sharding, read-write splitting |
| NewLife.Net | 2005 | Networking library, tens of millions of throughput per machine (22.66 million tps), millions of connections per machine (4 million long-lived TCP connections) |
| NewLife.Remoting | 2011 | Protocol communication library providing a CS application communication framework, supporting Http/RPC communication frameworks, high throughput, low overhead and easy access for IoT devices |
| NewLife.Cube | 2010 | Cube rapid development platform integrating user permissions, SSO login, OAuth server, etc., validated on a project with 10 billion records in a single table |
| NewLife.Agent | 2008 | Service management component that installs applications as operating system daemons: Windows services and Linux systemd |
| NewLife.Zero | 2020 | Zero-generation scaffolding, the NewLife.Templates project template based on the NewLife component ecosystem: Web, WebApi, Service |
| Middleware | Connects to well-known middleware platforms | |
| NewLife.Redis | 2017 | Redis client with microsecond-level latency, millions-level throughput, rich message queues, validated on a project with tens of billions of records |
| NewLife.RocketMQ | 2018 | Pure managed RocketMQ client supporting Apache RocketMQ and Alibaba Cloud Message Queue, validated on billion-level projects |
| NewLife.MQTT | 2019 | IoT messaging protocol, MqttClient/MqttServer, the client supports Alibaba Cloud IoT |
| NewLife.IoT | 2022 | IoT standard library defining various communication protocol standards and specifications in the IoT field |
| NewLife.Modbus | 2022 | ModbusTcp/ModbusRTU/ModbusASCII, implemented based on the IoT standard library, supporting the ZeroIoT platform and IoTEdge gateway |
| NewLife.Siemens | 2022 | Siemens PLC protocol, implemented based on the IoT standard library, supporting the IoT platform and IoTEdge |
| NewLife.Map | 2022 | Map component library wrapping Baidu Maps, AMap, Tencent Maps, and Tianditu |
| NewLife.Audio | 2023 | Audio codec library, PCM/ADPCMA/G711A/G722U/WAV/AAC |
| Product Platforms | Product platform level, ready to use after compilation and deployment, with personalized customization | |
| Stardust | 2018 | Stardust, distributed service platform: node management, APM monitoring center, configuration center, registration center, release center |
| AntJob | 2019 | AntJob, distributed big data computing platform (real-time/offline), ant-moving sharding concept, validated on a project with trillions of records |
| NewLife.ERP | 2021 | Enterprise ERP: product management, customer management, sales management, supplier management |
| CrazyCoder | 2006 | CrazyCoder, numerous developer tools: networking, serial ports, encryption/decryption, regular expressions, Modbus, MQTT |
| EasyIO | 2023 | Simple file storage, supporting centralized file storage in distributed systems. |
| XProxy | 2005 | Product-grade reverse proxy, NAT proxy, Http proxy |
| HttpMeter | 2022 | Http stress testing tool |
| GitCandy | 2015 | Git source code management system |
| SmartOS | 2014 | Embedded operating system, completely independent and self-developed, supporting the ARM Cortex-M chip architecture |
| SmartA2 | 2019 | Embedded industrial computer, IoT edge gateway, high-performance .NET8 host, applied in industry, agriculture, transportation, and healthcare |
| FIoT IoT Platform | 2020 | Complete IoT solutions for buildings, environmental protection, and agriculture, integrating software, hardware, and big data analysis, validated on a project with 100,000-level points per machine |
NewLife Development Team

The NewLife team (NewLife) was founded in 2002 and is an IoT industry solution provider for the new era, dedicated to providing software and hardware application solution consulting, system architecture planning, and development services. 5.23 million+ cumulative NuGet downloads. The team's core components (XCode / Redis / Stardust / AntJob / IoT, etc.) have been applied at scale in industries such as power, industry, transportation, environmental protection, healthcare, and cultural heritage.
We continue to improve, striving to become a long-term trusted .NET / IoT / distributed technology partner.
Website: https://newlifex.com Open source organization: https://github.com/NewLifeX
WeChat Official Account:
Contributing and feedback
- Before submitting, make sure
dotnet buildand the relevant unit tests pass; see the repository conventions for code style and commit messages. - Report bugs and suggestions via Issue; Stars and PRs are welcome.
- See ChangeLog.md for release notes.
License
This project is licensed under MIT; the strong-name certificate newlife.snk is published so you can build and replace assemblies yourself.
If this project is helpful to you, welcome to Star it, share it with your team, or provide improvement suggestions via Issue/PR.
Changes from Previous Version
Adoption Assessment
Assess this package against its supported frameworks, license, maintenance signals and dependency graph before making it a project standard.
Related Guides & Workflows
Learn how to evaluate, integrate, or audit this package in your .NET project.