From 5d549ff66a6462478c3cef32db77059394738d2c Mon Sep 17 00:00:00 2001 From: Coldsmile_7 Date: Sun, 25 Oct 2026 23:06:28 +0800 Subject: [PATCH] test: verify published release from launcher runtime --- tests/Check-LauncherRelease.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/Check-LauncherRelease.cs b/tests/Check-LauncherRelease.cs index 4e8f937..4a29ce2 100644 --- a/tests/Check-LauncherRelease.cs +++ b/tests/Check-LauncherRelease.cs @@ -2,6 +2,9 @@ using System; using System.IO; using System.Reflection; using System.Security.Cryptography; +using System.Threading.Tasks; + +[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] // Run under .NET Framework after compiling with the framework's csc.exe. // Uses the launcher's real release API parser without starting its main window. @@ -13,8 +16,11 @@ internal static class CheckLauncherRelease { Activator.CreateInstance(launcher.GetType("PCL.Application", true), true); Assembly core = Assembly.Load("MeloongCore"); core.GetType("MeloongCore.Main", true).GetMethod("Init").Invoke(null, new object[] { "PCL" }); + // Initialize the launcher's UI-thread identity on the main thread, + // as normal application startup does, before starting network work. + launcher.GetType("PCL.ModBase", true).GetMethod("RunInUi", Type.EmptyTypes).Invoke(null, null); Type module = launcher.GetType("PCL.ModSecret", true); - object info = module.GetMethod("GetLatestLauncherUpdate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null); + object info = Task.Run(() => module.GetMethod("GetLatestLauncherUpdate", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, null)).GetAwaiter().GetResult(); Type infoType = info.GetType(); string tag = (string)infoType.GetField("TagName").GetValue(info); string hash = (string)infoType.GetField("AssetHash").GetValue(info); @@ -32,6 +38,10 @@ internal static class CheckLauncherRelease { } } if (tag != "v0.1.1" || version != "0.1.1.0") throw new InvalidDataException("Unexpected test release version"); + bool newer = (bool)module.GetMethod("IsUpdateNewer", BindingFlags.Static | BindingFlags.NonPublic).Invoke(null, new object[] { info }); + bool expectedNewer = new Version(version) > launcher.GetName().Version; + if (newer != expectedNewer) throw new InvalidDataException("Unexpected update comparison result"); + Console.WriteLine("Installed: " + launcher.GetName().Version + ", update offered: " + newer); Console.WriteLine("PASS: launcher resolves published test release and checksum"); return 0; } catch (Exception ex) {