SmartUtilTools 3.1.1

dotnet add package SmartUtilTools --version 3.1.1
                    
NuGet\Install-Package SmartUtilTools -Version 3.1.1
                    
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="SmartUtilTools" Version="3.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SmartUtilTools" Version="3.1.1" />
                    
Directory.Packages.props
<PackageReference Include="SmartUtilTools" />
                    
Project file
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 SmartUtilTools --version 3.1.1
                    
#r "nuget: SmartUtilTools, 3.1.1"
                    
#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 SmartUtilTools@3.1.1
                    
#: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=SmartUtilTools&version=3.1.1
                    
Install as a Cake Addin
#tool nuget:?package=SmartUtilTools&version=3.1.1
                    
Install as a Cake Tool

SmartUtilTools 3.0

SmartUtilTools 是面向 .NET 8、.NET 9 和 .NET 10 的常用工具与基础设施类库。

3.0 破坏性变更

3.0 删除了重复或不能正确工作的公开扩展方法:

旧调用 新调用
task.WithRetryAsync(...) (ct => OperationAsync(ct)).WithRetryAsync(...)
value.ObjectToBool() value.ObjectToBoolean()
value.ObjectToJson() value.ToJsonString()
json.ToJson<T>() json.FromJson<T>()
text.ToMd5Fast() text.ToMd5()
text.ToUpperFirst() text.FirstCharToUpper()
value.ToEnumAlt<T>() value.ToEnum<T>()
bytes.FormatFileSize() bytes.ToSizeText()
自定义键选择器 IntersectBy / ExceptBy System.Linq.Enumerable 对应方法

重试 API 只接受可重新执行的操作工厂,并将取消令牌传给每次尝试:

var result = await (ct => LoadAsync(ct)).WithRetryAsync(
    new RetryOptions { MaxRetries = 3, TimeoutSeconds = 10 },
    cancellationToken: cancellationToken);

雪花 ID 生成器必须在首次生成前配置唯一 WorkerId:

GenerateIdHelper.ConfigureIdGenerator(workerId: 1);
long id = GenerateIdHelper.GetLongId();

腾讯智能体开发平台 ADP(3.1.0-preview.5)

服务端可调用 QuerySpacesAsync 查询空间,ListKnowledgeBasesAsync 按空间和零基页码查询知识库。管理员确认新建后调用 CreateSpaceAsync 或 CreateKnowledgeBaseAsync,读取云端返回的 SpaceId 或 KbId。创建请求超时后先查询资源。

通过 SmartUtilTools.Net.AdpHelper 调用 2026-05-20 管理接口及已发布应用的 HTTP SSE。服务端启动时注册:

services.AddTencentAdp(options => configuration.GetSection("TencentAdp").Bind(options));

配置项为 Region、SecretId、SecretKey、临时凭证 SessionToken 和独立的聊天 AppKey。从受控服务端密钥配置取值。业务服务注入 TencentAdpClient,先在本地验证主体与资源的归属,再调用:

var page = await adp.ListQaAsync(authorizedKbId, new AdpPage(0, 20), keyword: "耗材", ct: ct);
var search = await adp.SearchAsync(authorizedKbIds, question, ct);
await foreach (var item in adp.ChatAsync(requestId, ownedConversationId, visitorId, question, ct))
{
    // 分别处理 text.delta、text.replace、引用、error 和 response.completed。
}

ExecuteAsync 为服务端保留官方 Action 参数和响应字段,返回 Response 对象(含 RequestId)。客户端对每次云操作只发送一次。调用方维护计量、请求去重、失败后的对账及撤权,并验证生成应用的检索范围。业务端点须列举允许的动作,禁止将前端提交的 Action/KB ID 直接透传。

ImportDocumentsAsync 仅使用平台已经验证来源的腾讯文件服务 FileId,每批至多 20 个;返回的每项结果都需检查。原始本地文件上传尚需在目标账号验证取得 FileId 的同版本链路,应保持关闭。SSE 读取支持取消;未收到终止事件的断流抛 EndOfStreamException。云端计量方法保留明细实际单位、时间与未知字段。包提供离线契约测试,真实上传、计费维度、额度、应用知识隔离和撤回延迟应在测试空间核对后启用。

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
3.1.1 57 12/3/2026
2.0.8 187 6/11/2026
2.0.7 155 5/8/2026
2.0.6 147 5/8/2026
2.0.5 153 5/4/2026
2.0.4 173 4/10/2026
2.0.3 157 4/7/2026
2.0.2 155 4/4/2026
2.0.1 145 3/5/2026
2.0.0 155 2/27/2026
1.3.1 175 2/6/2026
1.3.0 159 2/6/2026
1.2.5 168 2/6/2026
1.2.4 173 1/26/2026
1.2.3 157 1/15/2026
1.2.2 171 1/4/2026
1.2.1 488 12/1/2025
1.2.0 255 11/24/2025
1.1.9 250 11/24/2025
1.1.8 419 11/21/2025
Loading failed