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 <noreply@anthropic.com>
This commit is contained in:
parent
ccf9bd0c0c
commit
741d212086
1 changed files with 2 additions and 1 deletions
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue