Conversation
Agent-Logs-Url: https://github.com/GeneralLibrary/GeneralUpdate-Samples/sessions/e10ca60a-5f1b-4e53-b802-81efa3b6c626 Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
|
@copilot |
…feedback Agent-Logs-Url: https://github.com/GeneralLibrary/GeneralUpdate-Samples/sessions/0945523e-807f-4b34-bb38-c0ea25fdbc50 Co-authored-by: JusterZhu <11714536+JusterZhu@users.noreply.github.com>
已在 commit
Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This PR updates the GeneralUpdate sample solution and documentation to align with GeneralUpdate 10.4.6, addressing breaking API changes (notably DifferentialCore) and tightening null-safety in sample event handlers and DTOs.
Changes:
- Bump all sample project/package references (and the
dotnet10_scripts/upgrade.csscript) to GeneralUpdate 10.4.6. - Update samples to match 10.x APIs (e.g.,
DifferentialCorestatic usage + strategies; new ClientCore listeners). - Improve null-safety and DTO initialization, and rewrite
UpgradeHubdocumentation with expanded examples/reference.
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| website/docs/doc/UpgradeHub.md | Major rewrite into a comprehensive UpgradeHubService reference + examples |
| src/Upgrade/UpgradeSample.csproj | Update GeneralUpdate.Core to 10.4.6 |
| src/Upgrade/Program.cs | Null-safe logging for version?.Version in event handlers |
| src/Server/Program.cs | Avoid passing null to HttpResponseDTO.Success by returning Enumerable.Empty<>() |
| src/Server/DTOs/VerificationResultDTO.cs | Initialize non-nullable Format with string.Empty |
| src/Server/DTOs/HttpResponseDTO.cs | Initialize non-nullable Message with string.Empty |
| src/Push/PushSample.csproj | Update GeneralUpdate.ClientCore to 10.4.6 |
| src/Push/Program.cs | Rewrite Push sample to demonstrate full UpgradeHubService lifecycle + listeners |
| src/OSS/OSSUpgradeSample/OSSUpgradeSample.csproj | Update GeneralUpdate.Core to 10.4.6 |
| src/OSS/OSSClientSample/OSSClientSample.csproj | Update GeneralUpdate.ClientCore to 10.4.6 |
| src/Extension/ExtensionSample/ExtensionSample.csproj | Update GeneralUpdate.Extension to 10.4.6 |
| src/Drivelution/DrivelutionSample/DrivelutionSample.csproj | Update GeneralUpdate.Drivelution to 10.4.6 |
| src/dotnet10_scripts/upgrade.cs | Update script package ref to 10.4.6 + null-safe version logging |
| src/Diff/Program.cs | Fix DifferentialCore API break by using static methods + explicit strategies/matchers |
| src/Diff/DiffSample.csproj | Update GeneralUpdate.Core to 10.4.6 |
| src/Compress/CompressSample/CompressSample.csproj | Update GeneralUpdate.Core to 10.4.6 |
| src/Client/Program.cs | Align Client sample with new listeners (UpdateInfo, UpdatePrecheck) + null-safe version logging |
| src/Client/ClientSample.csproj | Update GeneralUpdate.ClientCore to 10.4.6 |
| src/Bowl/BowlSample/BowlSample.csproj | Update GeneralUpdate.Bowl to 10.4.6 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // 建立 SignalR 连接 | ||
| await hub.StartAsync(); | ||
|
|
||
| //2. In projects with dependency injection capability, you can also use dependency injection, for example: Prism | ||
| Console.WriteLine("已连接,等待服务端推送..."); | ||
| Console.ReadLine(); | ||
|
|
||
| // 停止连接(可在应用进入后台时调用,保留重连能力) | ||
| await hub.StopAsync(); | ||
|
|
||
| // 释放资源(不可再复用) | ||
| await hub.DisposeAsync(); |
There was a problem hiding this comment.
在“快速开始”示例里,StartAsync() 后直接执行 ReadLine(),随后再调用 StopAsync()/DisposeAsync();如果 StartAsync() 期间抛异常或示例被提前中断,会导致连接/资源释放不被执行。建议将 StopAsync + DisposeAsync 放入 try/finally(或使用 await using)以保证清理逻辑始终执行。
| public MainWindowViewModel(IUpgradeHubService hubService) | ||
| { | ||
| service.StartAsync(); | ||
| //... | ||
| hubService.AddListenerReceive((message) => | ||
| { | ||
| Console.WriteLine($"收到推送: {message}"); | ||
| }); | ||
| _ = hubService.StartAsync(); | ||
| } |
There was a problem hiding this comment.
Prism/DI 示例在构造函数内使用 _ = hubService.StartAsync(); 丢弃返回的 Task,异常可能变成未观察到的异常且不易定位。建议在可 await 的生命周期方法(如初始化/Loaded 回调)里启动连接,或至少保存并显式处理该任务的异常(例如记录日志)。
| // 停止连接(可在应用进入后台时调用,保留重连能力) | ||
| await hub.StopAsync(); | ||
|
|
||
| // 释放资源(不可再复用) | ||
| await hub.DisposeAsync(); |
There was a problem hiding this comment.
快速开始示例在 StopAsync() 上方的注释写到“保留重连能力”,但紧接着又调用了 DisposeAsync()(释放后不可复用),这会让读者误以为 Stop+Dispose 仍可重连。建议调整注释或拆成两种退出路径:仅 StopAsync(可恢复) vs DisposeAsync(彻底释放)。
| // 停止连接(可在应用进入后台时调用,保留重连能力) | |
| await hub.StopAsync(); | |
| // 释放资源(不可再复用) | |
| await hub.DisposeAsync(); | |
| // 退出方式 1:仅停止连接(例如应用进入后台时),后续仍可重新调用 StartAsync() | |
| await hub.StopAsync(); | |
| // 退出方式 2:彻底释放资源(例如应用退出时),释放后当前实例不可再复用 | |
| // await hub.DisposeAsync(); |
All GeneralUpdate sample projects were referencing stale package versions (9.1.4–10.2.1). This updates every project to 10.4.6, fixes breaking API changes, and improves sample code and documentation to align with the current GeneralUpdate API.
Package updates
GeneralUpdate.ClientCoreGeneralUpdate.CoreGeneralUpdate.BowlGeneralUpdate.ExtensionGeneralUpdate.Drivelutiondotnet10_scripts/upgrade.csGeneralUpdate.CoreBreaking API fix —
DifferentialCoreThe
Instancesingleton was removed in 10.x.Clean/Dirtyare now static and require explicit strategy objects:Null-safety fixes
dotnet10_scripts/upgrade.csused unsafeversion.Versionafter anascast — changed toversion?.Version.stringproperties without initializers — added= string.Empty.HttpResponseDTO.Success(null, …)replaced withEnumerable.Empty<>()to avoid passing a null where non-nullable is expected.PushSample enhancements
Rewrote
src/Push/Program.csto demonstrate the fullUpgradeHubServiceAPI:AddListenerReceive— receive server-pushed version update messagesAddListenerOnline— online/offline status notificationsAddListenerReconnected— reconnection notificationsAddListenerClosed— connection closed notificationsStartAsync/StopAsync/DisposeAsync— full connection lifecycle managementClient sample API alignment
Updated
src/Client/Program.csto match the current GeneralUpdate API:BlackDirectoriescomment — the correct field name isSkipDirectorysAddListenerUpdateInfo— receives the fullVersionRespDTOreturned by the server after update checkAddListenerUpdatePrecheck— callback to skip or proceed with the update before downloading begins (forcibly-required versions always proceed regardless)UpgradeHub documentation rewrite
Rewrote
website/docs/doc/UpgradeHub.mdfrom a minimal English stub into a comprehensive Chinese-language reference doc matching the style of all other component docs (GeneralUpdate.Core.md,GeneralUpdate.Bowl.md, etc.). Includes:GeneralClientBootstrap)