# Fast **Repository Path**: zhenlei520/Fast ## Basic Information - **Project Name**: Fast - **Description**: 轻量、高性能的 .NET 实用工具库 —— 扩展、网络、本地化、密码学、压缩与序列化等按需引用的组件包 - **Primary Language**: C# - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-14 - **Last Updated**: 2026-11-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Fast > 轻量、高性能的 .NET 实用工具库 —— 扩展、网络、本地化、密码学、压缩与序列化等按需引用的组件包。 [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE.md) [![NuGet](https://img.shields.io/nuget/v/Fast.System.svg)](https://www.nuget.org/packages/Fast.System) **语言:** [English](README.md) · [中文](README.zh-CN.md) 完整文档索引见 [`docs/README.md`](docs/README.md)。 --- ## NuGet 包 | 包名 | NuGet | 说明 | |------|-------|------| | `Fast.System` | [![NuGet](https://img.shields.io/nuget/v/Fast.System.svg)](https://www.nuget.org/packages/Fast.System) | 核心工具:扩展方法、集合、选取器、AOT 源生成特性 | | `Fast.System.Reflection` | [![NuGet](https://img.shields.io/nuget/v/Fast.System.Reflection.svg)](https://www.nuget.org/packages/Fast.System.Reflection) | 反射扩展与实例表达式助手(JIT;不标 AOT) | | `Fast.System.SourceGenerator` | [![NuGet](https://img.shields.io/nuget/v/Fast.System.SourceGenerator.svg)](https://www.nuget.org/packages/Fast.System.SourceGenerator) | Analyzer:工厂 / 枚举元数据 / 实现列表生成 | | `Fast.System.Net` | [![NuGet](https://img.shields.io/nuget/v/Fast.System.Net.svg)](https://www.nuget.org/packages/Fast.System.Net) | IP 规则引擎与本机服务器地址 | | `Fast.System.Net.AspNetCore` | [![NuGet](https://img.shields.io/nuget/v/Fast.System.Net.AspNetCore.svg)](https://www.nuget.org/packages/Fast.System.Net.AspNetCore) | ASP.NET Core:`HttpContext` 信任链解析客户端 IP | | `Fast.Localization.Abstractions` | [![NuGet](https://img.shields.io/nuget/v/Fast.Localization.Abstractions.svg)](https://www.nuget.org/packages/Fast.Localization.Abstractions) | 本地化抽象与静态入口 | | `Fast.Localization` | [![NuGet](https://img.shields.io/nuget/v/Fast.Localization.svg)](https://www.nuget.org/packages/Fast.Localization) | 本地化默认实现(RESX / JSON) | | `Fast.Security.Cryptography` | [![NuGet](https://img.shields.io/nuget/v/Fast.Security.Cryptography.svg)](https://www.nuget.org/packages/Fast.Security.Cryptography) | AES-GCM、RSA、信封(RSA + AES-GCM) | | `Fast.Data.Compression.Abstractions` | [![NuGet](https://img.shields.io/nuget/v/Fast.Data.Compression.Abstractions.svg)](https://www.nuget.org/packages/Fast.Data.Compression.Abstractions) | 压缩抽象;实现见 GZip / LZ4 / Zstandard / GZipStable.* | | `Fast.Data.Serialization.Abstractions` | [![NuGet](https://img.shields.io/nuget/v/Fast.Data.Serialization.Abstractions.svg)](https://www.nuget.org/packages/Fast.Data.Serialization.Abstractions) | 序列化抽象;实现见 Json / Newtonsoft / Utf8Json / Yaml | 压缩与序列化各算法/格式为独立包,按需安装。细节见 [数据压缩](docs/zh-cn/data-compression/README.md) 与 [数据序列化](docs/zh-cn/data-serialization/README.md)。 --- ## 快速开始 ```bash dotnet add package Fast.System dotnet add package Fast.System.Reflection dotnet add package Fast.System.Net dotnet add package Fast.System.Net.AspNetCore ``` ```csharp // 字符串安全转换 var port = "8080".ToInt32(3000); // 8080 var id = "abc".ToInt32OrNull(); // null // 懒加载线程安全缓存 var cache = new CustomConcurrentDictionary(); var user = cache.GetOrAdd("uid-1", id => LoadUser(id)); // 表达式树组合,构建动态查询 Expression> filter = u => u.IsActive; filter = filter.And(!string.IsNullOrEmpty(name), u => u.Name.Contains(name)); // IP 规则匹配(集合重载:OR 短路) var dispatcher = new IpRuleDispatcher( new CidrIpRuleMatcher(), new IpRangeRuleMatcher(), new ExactIpRuleMatcher()); string[] whitelist = ["10.0.0.0/8", "203.0.113.50"]; if (!dispatcher.TryIsMatch(clientIp, whitelist)) return Forbid(); // 本机服务器 IPv4(跳过 VPN 与宿主机虚拟网卡) if (IpServerHelper.TryGetAddress(out IPAddress? serverIp)) Use(serverIp); // ASP.NET Core:从 HttpContext 解析客户端 IP IPAddress? effective = httpContext.GetClientIp(dispatcher, ["10.0.0.0/8"]); ``` --- ## 文档目录 - [项目介绍](docs/zh-cn/introduction.md) - [代码规范](docs/zh-cn/coding-conventions.md) - [常见 FAQ](docs/zh-cn/faq.md) - [完整索引](docs/README.md) ### Fast.System | 组件 | 文档 | |------|------| | 集合工具 | [概览](docs/zh-cn/fast-system/collections/README.md) · [最佳实践](docs/zh-cn/fast-system/collections/best-practices.md) · [高级用法](docs/zh-cn/fast-system/collections/advanced.md) · [源码解析](docs/zh-cn/fast-system/collections/source-analysis.md) | | 字符串扩展 | [概览](docs/zh-cn/fast-system/string-extensions/README.md) · [最佳实践](docs/zh-cn/fast-system/string-extensions/best-practices.md) · [高级用法](docs/zh-cn/fast-system/string-extensions/advanced.md) · [源码解析](docs/zh-cn/fast-system/string-extensions/source-analysis.md) | | 字典扩展 | [概览](docs/zh-cn/fast-system/dictionary-extensions/README.md) · [最佳实践](docs/zh-cn/fast-system/dictionary-extensions/best-practices.md) · [高级用法](docs/zh-cn/fast-system/dictionary-extensions/advanced.md) · [源码解析](docs/zh-cn/fast-system/dictionary-extensions/source-analysis.md) | | 枚举扩展 | [概览](docs/zh-cn/fast-system/enum-extensions/README.md) · [最佳实践](docs/zh-cn/fast-system/enum-extensions/best-practices.md) · [高级用法](docs/zh-cn/fast-system/enum-extensions/advanced.md) · [源码解析](docs/zh-cn/fast-system/enum-extensions/source-analysis.md) | | 表达式扩展 | [概览](docs/zh-cn/fast-system/expression-extensions/README.md) · [最佳实践](docs/zh-cn/fast-system/expression-extensions/best-practices.md) · [高级用法](docs/zh-cn/fast-system/expression-extensions/advanced.md) · [源码解析](docs/zh-cn/fast-system/expression-extensions/source-analysis.md) | | 反射扩展 | [概览](docs/zh-cn/fast-system/reflection-extensions/README.md) · [最佳实践](docs/zh-cn/fast-system/reflection-extensions/best-practices.md) · [高级用法](docs/zh-cn/fast-system/reflection-extensions/advanced.md) · [源码解析](docs/zh-cn/fast-system/reflection-extensions/source-analysis.md) | | Task 扩展 | [概览](docs/zh-cn/fast-system/task-extensions/README.md) · [最佳实践](docs/zh-cn/fast-system/task-extensions/best-practices.md) · [高级用法](docs/zh-cn/fast-system/task-extensions/advanced.md) · [源码解析](docs/zh-cn/fast-system/task-extensions/source-analysis.md) | | 参数验证助手 | [概览](docs/zh-cn/fast-system/argument-helper/README.md) · [最佳实践](docs/zh-cn/fast-system/argument-helper/best-practices.md) · [高级用法](docs/zh-cn/fast-system/argument-helper/advanced.md) · [源码解析](docs/zh-cn/fast-system/argument-helper/source-analysis.md) | | 实例表达式助手 | [概览](docs/zh-cn/fast-system/instance-helper/README.md) · [最佳实践](docs/zh-cn/fast-system/instance-helper/best-practices.md) · [高级用法](docs/zh-cn/fast-system/instance-helper/advanced.md) · [源码解析](docs/zh-cn/fast-system/instance-helper/source-analysis.md) | | 字节相等比较 | [概览](docs/zh-cn/fast-system/byte-equality/README.md) | | 条目选取器 | [概览](docs/zh-cn/fast-system/item-selectors/README.md) | > 源生成(`Fast.System.SourceGenerator`)用法见 [枚举扩展](docs/zh-cn/fast-system/enum-extensions/README.md)、[实例助手](docs/zh-cn/fast-system/instance-helper/README.md)、[反射扩展](docs/zh-cn/fast-system/reflection-extensions/README.md)。 ### Fast.System.Net | 组件 | 文档 | |------|------| | IP 规则引擎 | [概览](docs/zh-cn/fast-system-net/ip-rule-engine/README.md) · [最佳实践](docs/zh-cn/fast-system-net/ip-rule-engine/best-practices.md) · [高级用法](docs/zh-cn/fast-system-net/ip-rule-engine/advanced.md) · [源码解析](docs/zh-cn/fast-system-net/ip-rule-engine/source-analysis.md) | | 本机服务器地址 | [概览](docs/zh-cn/fast-system-net/server-address/README.md) | ### Fast.System.Net.AspNetCore | 组件 | 文档 | |------|------| | HttpContext 客户端 IP | 见 [IP 规则引擎概览](docs/zh-cn/fast-system-net/ip-rule-engine/README.md) 中的 AspNetCore 示例 | ### Fast.Localization | 组件 | 文档 | |------|------| | 多语言 | [概览](docs/zh-cn/fast-localization/README.md) · [最佳实践](docs/zh-cn/fast-localization/best-practices.md) · [高级用法](docs/zh-cn/fast-localization/advanced.md) · [源码解析](docs/zh-cn/fast-localization/source-analysis.md) | ### Fast.Security.Cryptography | 组件 | 文档 | |------|------| | AES-GCM | [概览](docs/zh-cn/fast-security-cryptography/aes-gcm/README.md) | | RSA | [概览](docs/zh-cn/fast-security-cryptography/rsa/README.md) | | 信封(RSA + AES-GCM) | [概览](docs/zh-cn/fast-security-cryptography/envelope/README.md) | ### Fast.Data | 组件 | 文档 | |------|------| | 数据压缩 | [概览](docs/zh-cn/data-compression/README.md) | | 数据序列化 | [概览](docs/zh-cn/data-serialization/README.md) | --- ## 支持框架 多数库:`netstandard2.0` · `netstandard2.1` · `netcoreapp2.1` ~ `netcoreapp3.1` · `net5.0` ~ `net10.0`(以各包 `TargetFrameworks` 为准)。 `Fast.System.Net.AspNetCore`:`net6.0` · `net8.0` · `net9.0` · `net10.0`。 ## 许可证 [MIT](LICENSE.md) © zhenlei520