From 741d21208635d1296c092ec44d3d4cc7861d4b36 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 14 Sep 2026 14:55:27 +0200 Subject: [PATCH] Note that init read-only presentation depends on the runtime's modreq IsInitOnly reads the IsExternalInit required modifier, which is unverified on Unity's Mono. Where it is not reported, init members show editable; reflection assigns them anyway, so edits still round-trip. No code change: no cheaper robust check exists. Co-Authored-By: Claude Opus 5 --- src/GameCult.Caching/CultInspectorModel.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/GameCult.Caching/CultInspectorModel.cs b/src/GameCult.Caching/CultInspectorModel.cs index 49a2da17..f40d9055 100644 --- a/src/GameCult.Caching/CultInspectorModel.cs +++ b/src/GameCult.Caching/CultInspectorModel.cs @@ -612,7 +612,8 @@ namespace GameCult.Caching private static int Ancestry(Type? type) => type == null ? 0 : 1 + Ancestry(type.BaseType); // `init` is a setter whose return carries the IsExternalInit modreq; the language contract, matched by name because - // netstandard2.1 does not ship the type. + // netstandard2.1 does not ship the type. A runtime that does not report the modreq (unverified on Unity's Mono) shows + // init members editable instead of read-only; SetValue still assigns them, so their edits round-trip either way. private static bool IsInitOnly(MethodInfo setter) => setter.ReturnParameter.GetRequiredCustomModifiers().Any(modifier => modifier.FullName == "System.Runtime.CompilerServices.IsExternalInit");