Skip to content

Gap fill v2: enums, type safety, Hub wiring, CI#389

Merged
JusterZhu merged 11 commits into
masterfrom
fill-gaps-v2
May 24, 2026
Merged

Gap fill v2: enums, type safety, Hub wiring, CI#389
JusterZhu merged 11 commits into
masterfrom
fill-gaps-v2

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

Summary

Second pass — fills architectural gaps from deep-dive analysis: enum type safety, Hub wiring, CI.

Changes

Enums — type-safe enums replace const-int classes:

  • PlatformType: class → enum { Unknown=0, Windows=1, Linux=2, MacOS=3 }
  • AppType: class → enum { Client=1, Upgrade=2, OSS=3 }
  • OssProvider: new enum { AliYun=1, AWS=2, MinIO=3, Tencent=4 }

Type safety propagation:

  • UpdateOptions.Platform: int?PlatformType?
  • UpdateOptions.AppType: intAppType
  • UpdateOptions.OssProvider: int?OssProvider?
  • VersionService.Validate(): parameters → AppType/PlatformType
  • HttpDownloadSource: constructor/field → PlatformType
  • IUpdateHooks.UpdateContext: int AppTypeAppType AppType
  • IUpdateReporter.UpdateReport: int AppTypeAppType AppType
  • GetPlatform(): return type intPlatformType everywhere

SignalR Hub wiring:

  • ClientUpdateStrategy: added DownloadSource property for injection
  • GeneralUpdateBootstrap: auto-creates HubDownloadSource when UpdateOptions.Hub is configured
  • Hub-enabled: silent polling + push-based download both supported

CI:

  • New ci.yml workflow: build + test on windows/ubuntu + AOT publish verification

Build + Tests

  • dotnet build — 0 errors
  • dotnet test CoreTest — 79/80 pass (1 pre-existing BackupRestore issue)

Closes #389

Changes:
- PlatformType: class -> enum (adds MacOS, Unknown)
- AppType: class -> enum (Client, Upgrade, OSS name clean-up)
- OssProvider: new enum (AliYun, AWS, MinIO, Tencent)
- UpdateOptions: Platform/OssProvider use enum types (not int)
- VersionService: Validate() takes AppType/PlatformType (not int)
- HttpDownloadSource: uses AppType/PlatformType (not int)
- IUpdateHooks/UpdateContext: AppType uses enum (not int)
- IUpdateReporter/UpdateReport: AppType uses enum (not int)
- ClientUpdateStrategy: add DownloadSource property for Hub injection
- GeneralUpdateBootstrap: HubConfig -> HubDownloadSource wiring
- CI: new ci.yml with build+test (win+ubuntu) + AOT verify

dotnet build: 0 errors
dotnet test: 79/80 pass (1 pre-existing BackupRestore issue)

Closes #389
Copilot AI review requested due to automatic review settings May 24, 2026 12:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens type safety across the update pipeline by replacing several const-int “enum classes” with real enums, propagating those types through configuration/options and network validation, and adds initial wiring for a SignalR Hub-based download source alongside a new multi-OS CI workflow.

Changes:

  • Replaced integer-based role/platform/provider identifiers with enum types (AppType, PlatformType, new OssProvider) and propagated them through options, hooks, reporting, download sources, and version validation APIs.
  • Added Hub download source wiring (bootstrap injection + strategy-level DownloadSource override point) to support push-based update asset discovery.
  • Introduced a new GitHub Actions CI workflow to build/test on Windows+Ubuntu and verify AOT publish.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/CoreTest/Hooks/HooksTests.cs Updates hook tests to use AppType enum in UpdateContext.
tests/CoreTest/Hooks/HooksIntegrationTests.cs Updates integration tests to use AppType enum and asserts enum equality.
src/c#/GeneralUpdate.Core/Strategy/UpgradeUpdateStrategy.cs Updates role documentation and UpdateContext construction to use AppType.Upgrade.
src/c#/GeneralUpdate.Core/Strategy/OSSUpdateStrategy.cs Updates UpdateContext construction to use AppType.OSS.
src/c#/GeneralUpdate.Core/Strategy/ClientUpdateStrategy.cs Adds injectable DownloadSource, uses it when present, and changes platform detection return type to PlatformType.
src/c#/GeneralUpdate.Core/Silent/SilentPollOrchestrator.cs Changes platform detection return type to PlatformType.
src/c#/GeneralUpdate.Core/Network/VersionService.cs Updates Validate signature to accept AppType/PlatformType and casts internally to the existing int-based request payload.
src/c#/GeneralUpdate.Core/Hooks/IUpdateHooks.cs Updates UpdateContext.AppType to be strongly typed (Configuration.AppType).
src/c#/GeneralUpdate.Core/Download/Sources/HttpDownloadSource.cs Updates to accept/store PlatformType and use new enum-based VersionService.Validate.
src/c#/GeneralUpdate.Core/Download/Reporting/IUpdateReporter.cs Makes UpdateReport.AppType strongly typed (AppType).
src/c#/GeneralUpdate.Core/Configuration/UpdateOptions.cs Switches option types to AppType, PlatformType?, OssProvider?.
src/c#/GeneralUpdate.Core/Configuration/PlatformType.cs Converts PlatformType from const-int class to enum (adds Unknown + MacOS).
src/c#/GeneralUpdate.Core/Configuration/OssProvider.cs Adds new OssProvider enum.
src/c#/GeneralUpdate.Core/Configuration/AppType.cs Converts AppType from const-int class to enum (Client, Upgrade, OSS).
src/c#/GeneralUpdate.Core/Bootstrap/GeneralUpdateBootstrap.cs Updates role selection to enum and injects HubDownloadSource when Hub config is set.
.github/workflows/ci.yml Adds CI workflow for build/test on Windows+Ubuntu + AOT publish verification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +97 to +103
// Inject SignalR Hub download source if configured
var hubConfig = GetOption(UpdateOptions.Hub);
if (hubConfig != null && !string.IsNullOrEmpty(hubConfig.Url))
{
clientStrat.DownloadSource = new Download.Sources.HubDownloadSource(
hubConfig.Url, GetOption(UpdateOptions.Token), GetOption(UpdateOptions.AppSecretKey));
GeneralTracer.Info("GeneralUpdateBootstrap: HubDownloadSource injected from HubConfig.");
private static PlatformType GetPlatform()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return PlatformType.Windows;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return PlatformType.Linux;
private static PlatformType GetPlatform()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return PlatformType.Windows;
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) return PlatformType.Linux;
Comment thread .github/workflows/ci.yml Outdated
Comment on lines +32 to +36
run: dotnet test ./src/c#/GeneralUpdate.slnx -c Release --no-build --filter "FullyQualifiedName!~ConfiginfoBuilderTests"

- name: Test (Ubuntu)
if: runner.os == 'Linux'
run: dotnet test ./src/c#/GeneralUpdate.slnx -c Release --no-build --filter "FullyQualifiedName!~ConfiginfoBuilderTests&FullyQualifiedName!~BowlTest"
@@ -55,11 +55,11 @@ public static Task Report(string url, int recordId, int status, int? type,
}

public static Task<VersionRespDTO> Validate(string url, string version,
public Hooks.IUpdateHooks Hooks { get; set; } = new Hooks.NoOpUpdateHooks();
/// <summary>Update status reporter injected by the bootstrap.</summary>
public Download.Reporting.IUpdateReporter Reporter { get; set; } = new Download.Reporting.NoOpUpdateReporter();
/// <summary>Download source (e.g., HTTP, SignalR Hub). Override via <c>.DownloadSource&lt;T&gt;()</c>.</summary>
JusterZhu added 9 commits May 24, 2026 21:05
…eanup

- HubDownloadSource: call StartAsync() on injection, dispose in finally
- GetPlatform(): add OSPlatform.OSX -> PlatformType.MacOS in both locations
- VersionService.Validate: keep int overload for backward binary compat
- ClientUpdateStrategy: DownloadSource resolved from extension registry + comment fix
- SharedMemoryProvider: catch broader exceptions on Linux (non-Windows MMF)
- CI: document ConfiginfoBuilderTests exclusion rationale
- Deleted: Configinfo.cs, ConfiginfoBuilder.cs, ConfiginfoBuilder-Example.cs
- Bootstrap: SetConfig(Configinfo) -> SyncConfigFromOptions() (from UpdateOptions)
- ConfigurationMapper: removed MapToGlobalConfigInfo(), kept MapToProcessInfo()
- Deleted tests: ConfiginfoBuilderTests.cs (API no longer exists)
- User config now exclusively via .Option() on GeneralUpdateBootstrap

Build: 0 errors, 0 warnings
@JusterZhu JusterZhu merged commit 1f89aa1 into master May 24, 2026
3 checks passed
@JusterZhu JusterZhu deleted the fill-gaps-v2 branch May 24, 2026 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants