From f267050982338d84f39f596bb718e04d7a937d22 Mon Sep 17 00:00:00 2001 From: "OpenGenesis (MPL 2.0)" <153564363+opengenesislink@users.noreply.github.com> Date: Sat, 7 Nov 2026 19:26:17 +0100 Subject: [PATCH] test(yengine): find inherited private migration fields during runtime regression --- .../Program.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/ci/YEngineBinaryFormatterRegression/Program.cs b/tools/ci/YEngineBinaryFormatterRegression/Program.cs index ec3d3784..7f010e08 100644 --- a/tools/ci/YEngineBinaryFormatterRegression/Program.cs +++ b/tools/ci/YEngineBinaryFormatterRegression/Program.cs @@ -23,10 +23,20 @@ static XMRInstance Fake() } static void SetField(XMRInstance instance, string name, object value) { - FieldInfo field = typeof(XMRInstance).GetField(name, - BindingFlags.Instance | BindingFlags.NonPublic) - ?? throw new Exception("Missing YEngine field " + name); - field.SetValue(instance, value); + // Runtime fields belong to the private base XMRInstAbstract, not the + // concrete XMRInstance. Reflection must explicitly walk the hierarchy. + for (Type type = typeof(XMRInstance); type != null; type = type.BaseType) + { + FieldInfo field = type.GetField(name, + BindingFlags.Instance | BindingFlags.NonPublic | + BindingFlags.DeclaredOnly); + if (field != null) + { + field.SetValue(instance, value); + return; + } + } + throw new Exception("Missing YEngine field " + name); } static byte[] WriteStateValue(object value) {