From 366580112b00fb3ff769091a62cf0bfa27dccfed Mon Sep 17 00:00:00 2001 From: JusterZhu Date: Mon, 25 May 2026 15:21:54 +0800 Subject: [PATCH 1/2] Remove AOT conditional exclusions for SignalR and delete deprecated methods - Remove #define AOT constant and SignalR Compile Remove entries from csproj - Remove Condition on SignalR.Client PackageReference for AOT builds - Remove #if !AOT blocks in GeneralUpdateBootstrap.cs (HubDownloadSource + LaunchSilentAsync) - Delete deprecated abstract/override methods (ExecuteStrategy, ExecuteStrategyAsync, StrategyFactory) Closes #402 --- .../Bootstrap/GeneralUpdateBootstrap.cs | 16 +--------------- .../Configuration/AbstractBootstrap.cs | 3 --- .../GeneralUpdate.Core/GeneralUpdate.Core.csproj | 14 +++++--------- 3 files changed, 6 insertions(+), 27 deletions(-) diff --git a/src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs b/src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs index afb23486..482f6283 100644 --- a/src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs @@ -96,8 +96,7 @@ private async Task LaunchWithStrategy(IStrategy roleStra // Resolve DownloadSource from extension registry (Hub, custom, etc.) var resolvedSource = ResolveExtension(); - // Inject SignalR Hub download source if configured (not available in AOT) -#if !AOT + // Inject SignalR Hub download source if configured if (resolvedSource == null) { var hubConfig = GetOption(UpdateOptions.Hub); @@ -110,7 +109,6 @@ private async Task LaunchWithStrategy(IStrategy roleStra GeneralTracer.Info("GeneralUpdateBootstrap: HubDownloadSource started from HubConfig."); } } -#endif clientStrat.DownloadSource = resolvedSource; if (_updatePrecheck != null) clientStrat.UseUpdatePrecheck(_updatePrecheck); @@ -316,11 +314,9 @@ private void ApplyRuntimeOptions() /// Silent update mode — starts a background poll loop and returns immediately. /// The orchestrator checks for updates periodically and prepares them. /// When the host process exits, the prepared update is applied. - /// Not available in AOT builds (SignalR dependency). /// private async Task LaunchSilentAsync() { -#if !AOT GeneralTracer.Info("GeneralUpdateBootstrap: starting silent update mode."); var pollMinutes = GetOption(UpdateOptions.SilentPollIntervalMinutes); @@ -341,10 +337,6 @@ private async Task LaunchSilentAsync() await orchestrator.StartAsync().ConfigureAwait(false); GeneralTracer.Info("GeneralUpdateBootstrap: silent update mode started, returning to caller."); -#else - GeneralTracer.Warn("GeneralUpdateBootstrap: silent update not available in AOT builds."); - await Task.CompletedTask; -#endif } private void InitBlackList() @@ -396,12 +388,6 @@ private static bool IsOssUpgrade(string clientVersion, string serverVersion) // Strategy & Events // ════════════════════════════════════════════════════════════════ - protected override GeneralUpdateBootstrap StrategyFactory() - => throw new NotImplementedException("Role strategies handle this."); - - protected override Task ExecuteStrategyAsync() => throw new NotImplementedException(); - protected override void ExecuteStrategy() => throw new NotImplementedException(); - private GeneralUpdateBootstrap AddListener(Action action) where TArgs : EventArgs { if (action is null) throw new ArgumentNullException(nameof(action)); diff --git a/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs b/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs index d202dffa..d8c8b7f8 100644 --- a/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs +++ b/src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs @@ -26,9 +26,6 @@ protected internal AbstractBootstrap() } public abstract Task LaunchAsync(); - protected abstract void ExecuteStrategy(); - protected abstract Task ExecuteStrategyAsync(); - protected abstract TBootstrap StrategyFactory(); public TBootstrap Option(UpdateOption option, T value) { diff --git a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj index 5ab6a93e..cf93fe4e 100644 --- a/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj +++ b/src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj @@ -14,8 +14,7 @@ netstandard2.0;net8.0;net10.0 true true - - $(DefineConstants);AOT + @@ -23,24 +22,21 @@ - + - + - + - - - - + From 84fc9bdc794c26373f34618b65d83421c400b4d4 Mon Sep 17 00:00:00 2001 From: JusterZhu Date: Mon, 25 May 2026 15:34:28 +0800 Subject: [PATCH 2/2] Fix HubDownloadSource AOT support and Hub start silent failure - Add PacketDTO to HttpParameterJsonContext for source-generated AOT deserialization - Replace reflection-based Deserialize with source-gen version in HubDownloadSource - Remove try/catch in UpgradeHubService.StartAsync so hub connection failures propagate --- .../Download/Sources/HubDownloadSource.cs | 2 +- src/c#/GeneralUpdate.Core/Hubs/UpgradeHubService.cs | 13 +++---------- .../JsonContext/HttpParameterJsonContext.cs | 3 +++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/c#/GeneralUpdate.Core/Download/Sources/HubDownloadSource.cs b/src/c#/GeneralUpdate.Core/Download/Sources/HubDownloadSource.cs index dc0e3a16..1c7ebf63 100644 --- a/src/c#/GeneralUpdate.Core/Download/Sources/HubDownloadSource.cs +++ b/src/c#/GeneralUpdate.Core/Download/Sources/HubDownloadSource.cs @@ -51,7 +51,7 @@ private void OnReceiveMessage(string json) { try { - var packet = System.Text.Json.JsonSerializer.Deserialize(json); + var packet = System.Text.Json.JsonSerializer.Deserialize(json, HttpParameterJsonContext.Default.PacketDTO); if (packet != null) { var asset = DownloadPlanBuilder.MapToAsset(packet); diff --git a/src/c#/GeneralUpdate.Core/Hubs/UpgradeHubService.cs b/src/c#/GeneralUpdate.Core/Hubs/UpgradeHubService.cs index 3996e137..c7181b34 100644 --- a/src/c#/GeneralUpdate.Core/Hubs/UpgradeHubService.cs +++ b/src/c#/GeneralUpdate.Core/Hubs/UpgradeHubService.cs @@ -55,16 +55,9 @@ public void AddListenerClosed(Func closeCallback) public async Task StartAsync() { - try - { - GeneralTracer.Info($"UpgradeHubService.StartAsync: connecting to SignalR hub. State={_connection?.State}"); - await _connection!.StartAsync(); - GeneralTracer.Info($"UpgradeHubService.StartAsync: SignalR hub connection established. State={_connection?.State}"); - } - catch (Exception e) - { - GeneralTracer.Error("The StartAsync method in the UpgradeHubService class throws an exception." , e); - } + GeneralTracer.Info($"UpgradeHubService.StartAsync: connecting to SignalR hub. State={_connection?.State}"); + await _connection!.StartAsync(); + GeneralTracer.Info($"UpgradeHubService.StartAsync: SignalR hub connection established. State={_connection?.State}"); } public async Task StopAsync() diff --git a/src/c#/GeneralUpdate.Core/JsonContext/HttpParameterJsonContext.cs b/src/c#/GeneralUpdate.Core/JsonContext/HttpParameterJsonContext.cs index 9e19e68f..4e8083e7 100644 --- a/src/c#/GeneralUpdate.Core/JsonContext/HttpParameterJsonContext.cs +++ b/src/c#/GeneralUpdate.Core/JsonContext/HttpParameterJsonContext.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Text.Json.Serialization; +using GeneralUpdate.Core.Download.Abstractions; namespace GeneralUpdate.Core.JsonContext; @@ -9,4 +10,6 @@ namespace GeneralUpdate.Core.JsonContext; [JsonSerializable(typeof(int?))] [JsonSerializable(typeof(string))] [JsonSerializable(typeof(Dictionary))] +[JsonSerializable(typeof(PacketDTO))] +[JsonSerializable(typeof(List))] public partial class HttpParameterJsonContext: JsonSerializerContext; \ No newline at end of file