Files
frameledger/tests/FrameLedger.Domain.Tests/UnityVersionTests.cs
poli0981andClaude Opus 5.5 a53ebee683 feat(detection): the engine version of Unity, Godot and RPG Maker games, read from their own files (beta.19 PR-3) (#294)
The owner's request of 2026-10-12. Rules 2026.10.1 gave: Unity's
pe_file_version stored UnityPlayer.dll's FileVersion string as it is
(2022.3.39.5118735 - the build number where the release letter belongs);
Godot's strings_regex scanned the executable's first 8 MiB while the
"Godot Engine v..." string sits 57-78 MB into both exports on the owner's
disk, so it never read one; both RPG Maker rules had version: null.

Measured read-only on 23 installs first (spike-notes section 17), then decided
in code as Unreal's is since beta.10:

- Rules 2026.10.2: unity_build, godot_build, rpgmaker_build - extractor types
  that take no parameter (the schema's enum beside unreal_build).
  StaticGameDetector makes one second read for the engine that matched;
  RuleEvaluator answers null for them as for unreal_build.
- Domain: UnityVersion (player ProductVersion, else the data file's header,
  else the player's numeric version), GodotVersion (a data pack's header,
  beside the executable or appended to it, else the executable's version
  while it is still Godot's; a zero patch dropped, as Godot names it),
  RpgMakerVersion (MZ/MV core-script header; the RGSS library Game.ini names
  -> XP/VX/VX Ace, its version or the one its name carries). New
  EngineVersionSource ids name the witness - and the maker.
- Infrastructure: UnityBuildReader, GodotBuildReader, RpgMakerBuildReader -
  version resources and at most a few kilobytes of any file; RPG Maker's files
  beside the executable or up to two folders above, as RpgMakerTitle looks.
- App: Formats.Engine(id, source) and EngineWithVersion - "RPG Maker MZ
  1.10.0", "RPG Maker VX Ace (RGSS 3.0.1)", "Unity 2022.3.39f1", "Godot 4.4.1"
  on the page, the subtitle and the card; the Engine version row says what
  each was read from, and "Not found in the game's files" once read. Strings
  en/vi/ja (ja marked review).
- Privacy Policy 2.8: section 4 names the version marks an engine keeps in its
  own files (the owner-approved wording), which also covers two reads that were
  never stated (UnityPlayer.dll's version, an RPG Maker title). The accuracy
  block, LIMITATIONS, 05_DETECTION, 06_DATA_MODEL, 08_UI and
  legal-drift-history say the same.

The shipped pipeline over the owner's installs (read-only): Unity 15 of 15,
Godot 2 of 2, RPG Maker 6 of 6, every one as measured; 24 ms to 4.1 s per
entry on the USB drive, nearly all of it the install's walk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-12 15:40:00 +07:00

63 lines
4.3 KiB
C#

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FluentAssertions;
using FrameLedger.Domain.Detection;
namespace FrameLedger.Domain.Tests;
/// <summary>
/// The Unity version ladder (beta.19). The cases are the owner's fifteen Unity installs, measured read-only on 2026-10-12
/// (<c>05_DETECTION</c> §Engine version — Unity, Godot, RPG Maker) — their numbers only, never their files.
/// </summary>
public sealed class UnityVersionTests
{
public static TheoryData<string, string?, int[]?, string?, string?, string?> Measured => new()
{
// title, UnityPlayer.dll ProductVersion, its numeric file version, data header version, → version, source
{ "A Space for the Unbound - Prologue", "2019.4.1.15122501", [2019, 4, 1, 15122501], "2019.4.1f1", "2019.4.1f1", EngineVersionSource.UnityData },
{ "DONT GO", "2022.3.39f1 (4e1b0f82c39a)", [2022, 3, 39, 5118735], "2022.3.39f1", "2022.3.39f1", EngineVersionSource.UnityPlayer },
{ "Dialoop", "6000.3.3f1 (ef04196de0d6)", [6000, 3, 3, 15664153], "6000.3.3f1", "6000.3.3f1", EngineVersionSource.UnityPlayer },
{ "Broken Shell Demo", "6000.0.58f2 (92dee566b325)", [6000, 0, 58, 9625317], "6000.0.58f2", "6000.0.58f2", EngineVersionSource.UnityPlayer },
{ "Deadly Heart Gambit", "2022.3.32f1 (c8300dc0a3fa)", [2022, 3, 32, 13119501], "2022.3.32f1", "2022.3.32f1", EngineVersionSource.UnityPlayer },
{ "DreadFields", "6000.3.17f1 (cf0352b38e81)", [6000, 3, 17, 13566802], "6000.3.17f1", "6000.3.17f1", EngineVersionSource.UnityPlayer },
{ "GIRLS' FRONTLINE 2: EXILIUM", "2019.4.40.16762411", [2019, 4, 40, 16762411], null, "2019.4.40", EngineVersionSource.UnityPlayerFile },
{ "Kemono Teatime", "2022.3.51f1 (9f9d16c45e54)", [2022, 3, 51, 10460438], "2022.3.51f1", "2022.3.51f1", EngineVersionSource.UnityPlayer },
{ "March Out! Playtest", "2022.3.62f3 (96770f904ca7)", [2022, 3, 62, 9860879], "2022.3.62f3", "2022.3.62f3", EngineVersionSource.UnityPlayer },
{ "Umamusume: Pretty Derby", "2022.3.62f2 (7670c08855a9)", [2022, 3, 62, 7762112], "2022.3.62f2", "2022.3.62f2", EngineVersionSource.UnityPlayer },
{ "Walto", "6000.3.2f1 (a9779f353c9b)", [6000, 3, 2, 11106207], "6000.3.2f1", "6000.3.2f1", EngineVersionSource.UnityPlayer },
{ "Yasha: Legends of the Demon Blade", "2022.3.54f1 (129125d4e700)", [2022, 3, 54, 1216805], "2022.3.54f1", "2022.3.54f1", EngineVersionSource.UnityPlayer },
{ "Yu-Gi-Oh! Master Duel", "6000.0.61f1 (74a0adb02c31)", [6000, 0, 61, 7643309], null, "6000.0.61f1", EngineVersionSource.UnityPlayer },
{ "帰路", "6000.0.58f2 (92dee566b325)", [6000, 0, 58, 9625317], "6000.0.58f2", "6000.0.58f2", EngineVersionSource.UnityPlayer },
{ "Legends of Runeterra", "2022.3.62f2 (ac7faeb0984d)", [2022, 3, 62, 11304878], "2022.3.62f2", "2022.3.62f2", EngineVersionSource.UnityPlayer },
};
[Theory]
[MemberData(nameof(Measured))]
public void TheFifteenMeasuredInstallsReadAsMeasured(string title, string? product, int[]? fileVersion, string? header, string? version, string? source)
{
EngineVersionReading r = UnityVersion.Decide(new UnityBuildFacts { PlayerProductVersion = product, PlayerFileVersion = fileVersion, DataHeaderVersion = header });
r.Version.Should().Be(version, title);
r.Source.Should().Be(source, title);
}
[Theory]
[InlineData("2022.3.39f1 (4e1b0f82c39a)", "2022.3.39f1")]
[InlineData("6000.0.58f2", "6000.0.58f2")]
[InlineData("5.6.4p2", "5.6.4p2")]
[InlineData("2019.4.1.15122501", null)]
[InlineData("10.0.29648.1000", null)]
[InlineData("1.2.3f1", null)]
[InlineData("", null)]
[InlineData(null, null)]
public void OnlyAnEditorVersionOfAMajorUnityShippedIsOne(string? text, string? expected) =>
UnityVersion.EditorVersion(text).Should().Be(expected);
/// <summary>A library's numbers that no Unity release carries — a system DLL's — are nothing, not a Unity version.</summary>
[Fact]
public void NumbersNoUnityReleaseCarriesAreNoVersion() =>
UnityVersion.Decide(new UnityBuildFacts { PlayerProductVersion = "10.0.29648.1000", PlayerFileVersion = [10, 0, 29648, 1000] })
.Should().Be(EngineVersionReading.None);
}