Skip to content

Commit 052d8a5

Browse files
JusterZhuclaude
andcommitted
feat: upgrade all templates to GeneralUpdate v10.5.0-beta.4 API
BREAKING: Configinfo class removed upstream — replaced by UpdateRequest (GeneralUpdate.Core.Configuration namespace). Key changes: - Configinfo -> UpdateRequest across all 11 .cs template/example files - Namespaces: Common.Shared.Object -> Core.Configuration, Common.Download -> Core.Download, Common.Internal -> Core.Event - IsComplated -> IsCompleted (typo fixed in v10.5.0-beta.4) - NuGet version 5.* -> 10.5.0-beta.4 New API coverage: - SetSource(url, key) zero-config entry point - SetOption(Option.Silent, true) programmable option system - Hooks<T>() lifecycle hooks (IUpdateHooks) - Strategy<T>() custom strategy injection (IStrategy) - UseDiffPipeline(Action<DiffPipelineBuilder>) diff pipeline config - AddListenerProgress event (7th event) Template rewrites: - CustomHooks.cs: stub -> active IUpdateHooks implementation - CustomStrategy.cs: stub -> active IStrategy implementation - Bowlingration.cs: MonitorParameter -> BowlContext + LaunchAsync - SilentStrategy.cs: config -> SetSource + SetOption(Option.Silent) - DifferentialStrategy.cs: config -> SetSource + UseDiffPipeline() - CrossVersionStrategy.cs: config -> SetSource() Co-Authored-By: Claude <noreply@anthropic.com>
1 parent f267dc5 commit 052d8a5

38 files changed

Lines changed: 684 additions & 492 deletions

.claude/skills/generalupdate-advanced/SKILL.md

Lines changed: 100 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,28 @@ allowed-tools: "Read, Write, Edit, Glob"
2424

2525
涵盖扩展点架构、Pipeline 管道、差分引擎、Bowl 崩溃守护、事件系统、文件系统工具等。
2626

27-
> ⚠️ **API 版本说明**:本指南基于 **NuGet v10.4.6 稳定版**
28-
> 以下功能在稳定版中**不存在**(但在开发分支 v10.5.0-beta.2 中已有):
29-
> - `IUpdateHooks` 生命周期钩子
30-
> - `IProcessInfoProvider` IPC 替换接口
31-
> - `SilentPollOrchestrator` 静默轮询器
32-
> - `Option` 可编程配置系统(v10.4.6 仅使用 `Configinfo` 属性)
33-
> - `ISslValidationPolicy` SSL 策略接口
27+
> ⚠️ **API 版本说明**:本指南基于 **NuGet v10.5.0-beta.4**
28+
> 以下功能在 v10.5.0-beta.4 中全部**可用**
29+
> -`IUpdateHooks` 生命周期钩子(`Hooks<T>()`
30+
> -`IStrategy` 自定义策略注入(`Strategy<T>()`
31+
> -`SilentPollOrchestrator` 静默轮询器(`Option.Silent`
32+
> -`Option` 可编程配置系统
33+
> -`ISslValidationPolicy` SSL 策略接口
34+
> -`IHttpAuthProvider` HTTP 认证提供者
35+
> -`DiffPipelineBuilder` 差分管道配置
3436
>
35-
> 各功能的可用性在文中已标注
37+
> 各功能的命名空间和用法在文中已标注
3638
3739
---
3840

39-
## 1. Pipeline 管道系统(v10.4.6 可用)
41+
## 1. Pipeline 管道系统(v10.5.0-beta.4 可用)
4042

4143
GeneralUpdate 使用 Pipeline 管道模式处理更新包的校验、解压、补丁应用。
4244

4345
### PipelineBuilder API
4446

4547
```csharp
46-
using GeneralUpdate.Common.Internal.Pipeline;
47-
using GeneralUpdate.Common.Internal.Strategy;
48+
using GeneralUpdate.Core.Pipeline;
4849

4950
// 创建管道上下文
5051
var context = new PipelineContext();
@@ -59,7 +60,7 @@ context.Add("PatchEnabled", true);
5960
await new PipelineBuilder(context)
6061
.UseMiddleware<HashMiddleware>() // 哈希校验
6162
.UseMiddleware<CompressMiddleware>() // 解压
62-
.UseMiddleware<PatchMiddleware>() // 差分补丁(需安装 Differential 包)
63+
.UseMiddleware<PatchMiddleware>() // 差分补丁
6364
.Build();
6465
```
6566

@@ -72,35 +73,31 @@ await new PipelineBuilder(context)
7273

7374
---
7475

75-
## 2. 策略系统(v10.4.6 可用)
76+
## 2. 策略系统(v10.5.0-beta.4 可用)
7677

77-
GeneralUpdate 内置三种平台策略,通过 `AbstractStrategy` 模板方法模式实现
78+
GeneralUpdate 内置三种平台策略,通过 `IStrategy` 接口实现
7879

7980
| 策略 | 类名 | 平台 |
8081
|------|------|------|
8182
| Windows | `WindowsStrategy` | Windows |
8283
| Linux | `LinuxStrategy` | Linux |
8384
| OSS | `OSSStrategy` | 跨平台(对象存储) |
8485

85-
> ⚠️ 稳定版**不支持**通过 `bootstrap.Strategy<T>()` 注入自定义策略。
86-
> 自定义策略需要继承 `AbstractStrategy` 并直接调用
86+
> ✅ 支持通过 `bootstrap.Strategy&lt;T&gt;()` 注入自定义策略。
87+
> 自定义策略需要实现 `IStrategy` 接口
8788
8889
---
8990

90-
## 3. Bowl 崩溃守护(v10.4.6 存在但功能有限
91+
## 3. Bowl 崩溃守护(v10.5.0-beta.4
9192

9293
Bowl 是一个崩溃监控组件,通过 `MonitorParameter` 配置。
9394

94-
> ⚠️ **注意**:v10.4.6 的 Bowl 仅提供基础类型定义,`Bowl` 类没有公开的 `LaunchAsync` 方法。
95-
> 完整功能在开发分支(v10.5.0-beta.2)中。
96-
97-
### MonitorParameter 配置
95+
### BowlContext 配置
9896

9997
```csharp
10098
using GeneralUpdate.Bowl;
101-
using GeneralUpdate.Bowl.Strategys;
10299

103-
var param = new MonitorParameter
100+
var context = new BowlContext
104101
{
105102
ProcessNameOrId = "MyApp.exe",
106103
DumpFileName = "v1.0.0.0_fail.dmp",
@@ -109,22 +106,40 @@ var param = new MonitorParameter
109106
FailDirectory = @"C:\Program Files\MyApp\fail",
110107
BackupDirectory = @"C:\Program Files\MyApp\backup",
111108
WorkModel = "Upgrade",
109+
TimeoutMs = 30_000,
110+
AutoRestore = true,
111+
OnCrash = async (info, ct) => Console.WriteLine($"Crash: {info.DumpFilePath}"),
112112
};
113113

114-
// Bowl 实例(v10.4.6 无公开 LaunchAsync,此为占位)
115114
var bowl = new Bowl();
115+
var result = await bowl.LaunchAsync(context);
116+
Console.WriteLine($"Result: Success={result.Success}, Restored={result.Restored}");
116117
```
117118

118-
完整 Bowl 崩溃守护功能请关注 GeneralUpdate 后续版本。
119+
| 属性 | 类型 | 说明 | 默认值 |
120+
|------|------|------|--------|
121+
| `ProcessNameOrId` | string | 被监控的进程名或 PID | 必填 |
122+
| `TargetPath` | string | 应用安装根目录 | 必填 |
123+
| `DumpFileName` | string | Dump 文件名 | 必填 |
124+
| `FailFileName` | string | 故障报告文件名 | 必填 |
125+
| `FailDirectory` | string | 崩溃报告输出目录 | 必填 |
126+
| `BackupDirectory` | string | 备份目录 | 必填 |
127+
| `WorkModel` | string | "Upgrade" 或 "Normal" | "Upgrade" |
128+
| `TimeoutMs` | int | 监控超时(毫秒) | 30000 |
129+
| `AutoRestore` | bool | 崩溃后自动回滚 | false |
130+
| `DumpType` | DumpType | Mini / Full | Full |
131+
| `OnCrash` | delegate | 崩溃回调 | null |
132+
133+
> ⚠️ Bowl 和 Core 不能同时引用(CS0433)。使用 Bowl 时**只引用 `GeneralUpdate.Bowl`**,它传递依赖 Core 的所有功能。
119134
120135
---
121136

122-
## 4. EventManager 事件系统(v10.4.6 可用)
137+
## 4. EventManager 事件系统(v10.5.0-beta.4 可用)
123138

124139
EventManager 是一个全局单例,提供事件的发布和订阅:
125140

126141
```csharp
127-
using GeneralUpdate.Common.Internal.Event;
142+
using GeneralUpdate.Core.Event;
128143

129144
// 添加监听
130145
EventManager.Instance.AddListener((object? sender, UpdateInfoEventArgs e) =>
@@ -142,54 +157,79 @@ EventManager.Instance.Clear();
142157
EventManager.Instance.Dispose();
143158
```
144159

145-
> ⚠️ EventManager 是全局单例,`Dispose()``Instance` 仍然可访问(代码审计发现)
160+
> ⚠️ EventManager 是全局单例,`Dispose()``Instance` 仍然可访问。
146161
147162
---
148163

149-
## 5. 文件系统工具(v10.4.6 可用)
164+
## 5. 文件系统工具(v10.5.0-beta.4 可用)
150165

151166
### BlackList(黑名单)
152167

153-
`Configinfo` 支持通过以下属性排除文件:
168+
`UpdateRequest` 支持通过以下属性排除文件:
154169

155170
```csharp
156-
var config = new Configinfo
171+
var config = new UpdateRequest
157172
{
158173
// ...
159-
BlackFiles = new List<string> { "*.log", "*.tmp" },
160-
BlackFormats = new List<string> { ".pdb", ".vshost.exe" },
161-
SkipDirectorys = new List<string> { "logs", "cache", "temp" },
174+
Files = new List<string> { "*.log", "*.tmp" },
175+
Formats = new List<string> { ".pdb", ".vshost.exe" },
176+
Directories = new List<string> { "logs", "cache", "temp" },
162177
};
163178
```
164179

180+
黑名单内部通过 `ToBlackPolicy()` 转换为 `BlackPolicy` 记录。
181+
165182
### FileTree(文件树对比)
166183

167184
```csharp
168-
using GeneralUpdate.Common.FileBasic;
185+
using GeneralUpdate.Core.FileSystem;
169186

170187
var tree = new FileTree();
171188
var snapshot = tree.CreateSnapshot(@"C:\Program Files\MyApp");
172-
// 或从 StorageManager 获取比较结果
173189
```
174190

175191
---
176192

177-
## 6. 差分引擎(v10.4.6 可用,需安装 Differential 包
193+
## 6. 差分引擎(v10.5.0-beta.4 可用,无需额外安装包
178194

179-
安装 `GeneralUpdate.Differential` 包后可用:
195+
差分类型已内嵌在 `GeneralUpdate.Core` 中,**无需额外**安装 `GeneralUpdate.Differential` 包。
196+
197+
### DiffPipelineBuilder 方式(推荐)
180198

181199
```csharp
182-
// DifferentialCore 提供核心差分能力
183-
using GeneralUpdate.Differential;
200+
using GeneralUpdate.Core.Pipeline;
201+
202+
var pipeline = new DiffPipelineBuilder()
203+
.UseDiffer(new StreamingHdiffDiffer()) // 差分算法
204+
.UseCleanMatcher(new DefaultCleanMatcher()) // 文件匹配器(服务端)
205+
.UseDirtyMatcher(new DefaultDirtyMatcher()) // 文件匹配器(客户端)
206+
.WithParallelism(4)
207+
.WithStopOnFirstError(true)
208+
.WithProgress(new Progress<DiffProgress>(p =>
209+
Console.WriteLine($"[{p.Completed}/{p.Total}] {p.FileName}")))
210+
.Build();
184211

185-
// 清理模式(服务端):对比新旧版本生成补丁
186-
await DifferentialCore.CleanAsync(srcDir, tgtDir, patchDir);
212+
// 服务端:生成补丁
213+
await pipeline.CleanAsync(oldDir, newDir, patchDir);
187214

188-
// 脏模式(客户端):应用补丁
189-
await DifferentialCore.DirtyAsync(installDir, patchDir);
215+
// 客户端:应用补丁
216+
await pipeline.DirtyAsync(appDir, patchDir);
217+
```
218+
219+
### Bootstrap 集成方式
220+
221+
```csharp
222+
new GeneralUpdateBootstrap()
223+
.SetConfig(config)
224+
.UseDiffPipeline(pipeline =>
225+
{
226+
pipeline.WithParallelism(2)
227+
.WithStopOnFirstError(true);
228+
})
229+
.LaunchAsync();
190230
```
191231

192-
自定义匹配器(v10.4.6 可用):
232+
### 自定义匹配器
193233

194234
```csharp
195235
using GeneralUpdate.Differential.Matchers;
@@ -203,7 +243,7 @@ var dirtyMatcher = new DefaultDirtyMatcher(); // 或实现 IDirtyMatcher
203243

204244
## 7. AOT / NativeAOT 兼容性
205245

206-
GeneralUpdate.Core v10.4.6 支持 .NET Native AOT:
246+
GeneralUpdate.Core v10.5.0-beta.4 支持 .NET Native AOT`net8.0``net10.0`
207247

208248
```xml
209249
<PropertyGroup>
@@ -215,10 +255,10 @@ GeneralUpdate.Core v10.4.6 支持 .NET Native AOT:
215255
JSON 序列化上下文(减少 AOT 大小):
216256

217257
```csharp
218-
using GeneralUpdate.Common.Internal.JsonContext;
258+
using GeneralUpdate.Core.JsonContext;
219259

220260
// 使用内置的 JsonSerializerContext
221-
// VersionRespJsonContext, PacketJsonContext, ProcessInfoJsonContext
261+
// VersionRespJsonContext, ProcessContractJsonContext, HttpParameterJsonContext
222262
```
223263

224264
---
@@ -246,19 +286,19 @@ var result = GeneralDrivelution.InstallDriver(driverPath);
246286

247287
| 主题 | 可用性 | 参考 |
248288
|------|--------|------|
249-
| Pipeline 管道 | ✅ v10.4.6 | `GeneralUpdate.Common.Internal.Pipeline` |
250-
| 策略系统 | ✅ v10.4.6 | `GeneralUpdate.Common.Internal.Strategy` |
251-
| FileTree | ✅ v10.4.6 | `GeneralUpdate.Common.FileBasic` |
252-
| BlackList | ✅ v10.4.6 | `Configinfo.BlackFiles` 等属性 |
253-
| 差分引擎 |`GeneralUpdate.Differential` | `DifferentialCore` |
254-
| AOT | ✅ v10.4.6 | `JsonSerializerContext` 子类 |
255-
| EventManager | ✅ v10.4.6 | `GeneralUpdate.Common.Internal.Event` |
289+
| Pipeline 管道 | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.Pipeline` |
290+
| 策略系统 | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.Strategy` |
291+
| FileTree | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.FileSystem` |
292+
| BlackList | ✅ v10.5.0-beta.4 | `UpdateRequest.Files/Formats/Directories``ToBlackPolicy()` |
293+
| 差分引擎 |内嵌 Core | `DiffPipelineBuilder` / `DiffPipeline` |
294+
| AOT | ✅ v10.5.0-beta.4 | `JsonSerializerContext` 子类 |
295+
| EventManager | ✅ v10.5.0-beta.4 | `GeneralUpdate.Core.Event` |
256296
| Bowl 崩溃守护 | ⚠️ 基础类型 | `GeneralUpdate.Bowl.Bowl` |
257-
| IUpdateHooks | v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
258-
| 自定义 Strategy 注入 | v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
259-
| IPC 替换接口 |v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
260-
| SilentPollOrchestrator | v10.4.6 不支持 | 开发分支 v10.5.0-beta.2 中 |
261-
| Option 系统 | v10.4.6 不支持 | 仅 Configinfo 属性 |
297+
| IUpdateHooks | v10.5.0-beta.4 | `GeneralUpdate.Core.Hooks``Hooks<T>()` |
298+
| 自定义 Strategy 注入 | v10.5.0-beta.4 | `Strategy<T>()` |
299+
| IPC 替换接口 |暂不支持 | 使用 NamedPipe 替代方案 |
300+
| SilentPollOrchestrator | v10.5.0-beta.4 | `Option.Silent` + `SetOption()` |
301+
| Option 系统 | v10.5.0-beta.4 | `SetOption<T>(Option<T>, T)` |
262302

263303
---
264304

0 commit comments

Comments
 (0)