Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ private async Task<GeneralUpdateBootstrap> LaunchWithStrategy(IStrategy roleStra
// Resolve DownloadSource from extension registry (Hub, custom, etc.)
var resolvedSource = ResolveExtension<Download.Abstractions.IDownloadSource>();

// Inject SignalR Hub download source if configured (not available in AOT)
#if !AOT
// Inject SignalR Hub download source if configured
if (resolvedSource == null)
Comment on lines 96 to 100
{
var hubConfig = GetOption(UpdateOptions.Hub);
Expand All @@ -110,7 +109,6 @@ private async Task<GeneralUpdateBootstrap> LaunchWithStrategy(IStrategy roleStra
GeneralTracer.Info("GeneralUpdateBootstrap: HubDownloadSource started from HubConfig.");
}
}
#endif
clientStrat.DownloadSource = resolvedSource;
if (_updatePrecheck != null)
clientStrat.UseUpdatePrecheck(_updatePrecheck);
Expand Down Expand Up @@ -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).
/// </summary>
private async Task LaunchSilentAsync()
{
#if !AOT
GeneralTracer.Info("GeneralUpdateBootstrap: starting silent update mode.");

var pollMinutes = GetOption(UpdateOptions.SilentPollIntervalMinutes);
Expand All @@ -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()
Expand Down Expand Up @@ -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<TArgs>(Action<object, TArgs> action) where TArgs : EventArgs
{
if (action is null) throw new ArgumentNullException(nameof(action));
Expand Down
3 changes: 0 additions & 3 deletions src/c#/GeneralUpdate.Core/Configuration/AbstractBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ protected internal AbstractBootstrap()
}

public abstract Task<TBootstrap> LaunchAsync();
protected abstract void ExecuteStrategy();
protected abstract Task ExecuteStrategyAsync();
protected abstract TBootstrap StrategyFactory();

public TBootstrap Option<T>(UpdateOption<T> option, T value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ private void OnReceiveMessage(string json)
{
try
{
var packet = System.Text.Json.JsonSerializer.Deserialize<PacketDTO>(json);
var packet = System.Text.Json.JsonSerializer.Deserialize(json, HttpParameterJsonContext.Default.PacketDTO);
if (packet != null)
{
var asset = DownloadPlanBuilder.MapToAsset(packet);
Expand Down
14 changes: 5 additions & 9 deletions src/c#/GeneralUpdate.Core/GeneralUpdate.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,29 @@
<TargetFrameworks>netstandard2.0;net8.0;net10.0</TargetFrameworks>
<IsAotCompatible Condition="'$(TargetFramework)' != 'netstandard2.0'">true</IsAotCompatible>
<EnableTrimAnalyzer Condition="'$(TargetFramework)' != 'netstandard2.0'">true</EnableTrimAnalyzer>
<!-- AOT constant for conditional compilation (exclude SignalR, etc.) -->
<DefineConstants Condition="'$(PublishAot)' == 'true'">$(DefineConstants);AOT</DefineConstants>

</PropertyGroup>

<!-- Compatibility packages for netstandard2.0 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.1" />
<PackageReference Include="System.Collections.Immutable" Version="10.0.1" />
<PackageReference Include="System.Text.Json" Version="10.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.1" Condition="'$(PublishAot)' != 'true'" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.1" />
</ItemGroup>

<!-- Packages only needed for net8.0 (built-in in net10.0) -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" Condition="'$(PublishAot)' != 'true'" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.1" Condition="'$(PublishAot)' != 'true'" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="10.0.1" />
</ItemGroup>

<ItemGroup>
<!-- IsExternalInit is built-in for net8.0+ (C# 9 records) -->
<Compile Remove="Configuration\IsExternalInit.cs" Condition="'$(TargetFramework)' != 'netstandard2.0'" />
<!-- SignalR Hub code excluded in AOT builds -->
<Compile Remove="Hubs\*.cs" Condition="'$(PublishAot)' == 'true'" />
<Compile Remove="Download\Sources\HubDownloadSource.cs" Condition="'$(PublishAot)' == 'true'" />
<Compile Remove="Silent\SilentPollOrchestrator.cs" Condition="'$(PublishAot)' == 'true'" />

</ItemGroup>
Comment on lines 37 to 41
</Project>
13 changes: 3 additions & 10 deletions src/c#/GeneralUpdate.Core/Hubs/UpgradeHubService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,9 @@ public void AddListenerClosed(Func<Exception?, Task> 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()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using GeneralUpdate.Core.Download.Abstractions;

namespace GeneralUpdate.Core.JsonContext;

Expand All @@ -9,4 +10,6 @@ namespace GeneralUpdate.Core.JsonContext;
[JsonSerializable(typeof(int?))]
[JsonSerializable(typeof(string))]
[JsonSerializable(typeof(Dictionary<string, object>))]
[JsonSerializable(typeof(PacketDTO))]
[JsonSerializable(typeof(List<PacketDTO>))]
public partial class HttpParameterJsonContext: JsonSerializerContext;
Loading