Nothings 0.1.0
dotnet add package Nothings --version 0.1.0
NuGet\Install-Package Nothings -Version 0.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nothings" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nothings" Version="0.1.0" />
<PackageReference Include="Nothings" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nothings --version 0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Nothings, 0.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nothings@0.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nothings&version=0.1.0
#tool nuget:?package=Nothings&version=0.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Nothings
Nothings 是 Go 库 aid 的 C# 重实现,按模块逐个移植。
移植原则:贴近 C# 语言习惯,而非 1:1 照搬 Go。因此在保留原有功能语义的前提下,做了如下系统性取舍:
- 去掉 Go 的 functional-options 模式(
XxxAttr)——C# 有可选参数 / 命名参数 / 方法重载。 - 去掉为「面向接口」而生的冗余自定义接口——需要抽象时直接用 .NET 标准接口(
IReadOnlyList<T>、IReadOnlyDictionary<K,V>等)。 - 去掉纯数据结构上的读写锁——C# 容器默认非线程安全,由使用方决定并发策略(真正并发的模块如
Clock仍保留必要同步)。 - 错误处理遵循 C# 习惯:用异常取代 Go 的
(value, error)多返回与IfXxxError回调。 - 容量(
capacity)等 Go 切片底层概念不再暴露,交给 .NET 运行时自动管理。
环境要求
- .NET 10(
net10.0),C#latest - 测试:xUnit
模块一览
| 模块 | 命名空间 | 说明 | 文档 |
|---|---|---|---|
| anySlices | Nothings.AnySlices |
通用链式切片包装器 AnySlice<T>,提供过滤、集合运算、分块、排序、JSON 等约 50 个流式方法 |
README |
| anyMaps | Nothings.AnyMaps |
通用链式有序字典包装器 AnyMap<K,V>,保持插入顺序,提供键值查找、过滤、集合式增删、转换、JSON 等 |
README |
| clocks | Nothings.Clocks |
轻量任务调度器 Clock 与三类可调度任务(一次性 / 周期 / 按周规则),基于 Task + CancellationToken |
README |
| compressions | Nothings.Compressions |
统一 ICompressor 抽象下的 zlib / zstd / lz4 压缩器,级别由构造参数传入、非法即抛异常(zlib 用 BCL,zstd/lz4 用 ZstdSharp.Port、K4os.Compression.LZ4) |
README |
| fileSystems | Nothings.FileSystems |
面向路径的文件 / 目录操作:抽象基类 FileSystemNode + FileNode/DirNode 子类,PathKind 解析路径,读写 / 递归复制 / 删除 / Zip,基于 System.IO |
README |
| httpClients | Nothings.HttpClients |
流式 HTTP 客户端:Http 工厂 + HttpRequestBuilder 构建器 + HttpResponse 包装,支持各类请求体 / 压缩 / 加密 / 大文件有序切块上传 / 上传限速 / 超时 / 重试 / 自定义 TLS,基于 System.Net.Http |
README |
| secrets | Nothings.Secrets |
加解密全集:AES/SM4、RSA/RSA-OAEP/SM2/ECDSA/Ed25519、JWT;HttpClients 加密依赖 ISymmetric |
README |
| retries | Nothings.Retries |
通用重试器 Retry:线性 / 指数 / 抖动+指数,异步优先,CancellationToken 取消 |
README |
| structs | Nothings.Structs |
结构体字段覆盖(Cover)与比较(Compare/diff):静态泛型入口 Struct + FieldDiff,基于反射,[DisplayName] 作标签 |
README |
| tasks | Nothings.Tasks |
按优先级执行的任务池:PriorityTask + TaskPool,基于 BCL PriorityQueue,同步 Action、异常捕获到 Error |
README |
构建与测试
# 构建
dotnet build
# 运行全部单元测试
dotnet test
项目结构
Nothings.sln
Nothings/ # 主库
anySlices/ # AnySlice<T> + 静态工厂 AnySlice
anyMaps/ # AnyMap<K,V> + 静态工厂 AnyMap
clocks/ # Clock / IScheduledTask / OnceTask / RecurringTask / WeeklyTask
compressions/ # ICompressor / ZlibCompressor / ZstdCompressor / Lz4Compressor
fileSystems/ # FileSystemNode / FileNode / DirNode / PathKind / NodeKind
httpClients/ # Http / HttpRequestBuilder / HttpResponse / ContentTypes
secrets/ # AES/SM4、RSA/SM2/ECDSA/Ed25519、JWT
retries/ # Retry(Linear / Exponent / Jitter)
structs/ # Struct(Cover / Compare)/ FieldDiff
tasks/ # PriorityTask / TaskPool(优先级任务池)
Nothings.Tests/ # xUnit 测试工程
第三方依赖
绝大多数模块只依赖 .NET BCL。少数能力引入纯托管包:
| 包 | 用途 |
|---|---|
ZstdSharp.Port |
zstd 压缩 / 解压 |
K4os.Compression.LZ4.Streams |
lz4 帧格式压缩 / 解压 |
BouncyCastle.Cryptography |
国密 SM2/SM4 与 Ed25519 |
zlib / AES / RSA / ECDSA 使用 BCL,无需额外依赖。
许可证与归属
本项目采用 Apache License 2.0。
Nothings 是 Go 库 aid(Copyright aid297,同样以 Apache-2.0 许可)的 C# 移植衍生作品:在直接参照其源码的基础上,按 C# 语言习惯逐模块改写。各模块与原 Go 版的差异已在对应模块 README 的「与 Go 版差异」小节中说明(满足 Apache-2.0 §4(b) 的改动声明要求)。
注:本移植为社区重实现,未获原作者背书;如原作者对归属或许可有任何异议,请联系修正。
| 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 was computed. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- BouncyCastle.Cryptography (>= 2.6.2)
- K4os.Compression.LZ4.Streams (>= 1.3.8)
- ZstdSharp.Port (>= 0.8.8)
-
net8.0
- BouncyCastle.Cryptography (>= 2.6.2)
- K4os.Compression.LZ4.Streams (>= 1.3.8)
- ZstdSharp.Port (>= 0.8.8)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0 | 46 | 9/18/2026 |