Class UnitySerializedFieldSeeds
Seed-value helpers for a "seed every field, force a rollback, assert it all comes back" test — shared
because the scalar/enum/Object-reference/LayerMask branches of that type switch were previously
duplicated byte-for-byte across fifteen field-walk test suites. Each suite keeps only the parts that are
genuinely its own: resolving which id or alternate reference a given field maps to, and building any
nested composite type (a spawn entry, a sync-map row, a signal parameter…) the walked type embeds.
Inheritance
UnitySerializedFieldSeeds
Assembly: Tests.dll
Syntax
public static class UnitySerializedFieldSeeds
Methods
SeedEnumValueDistinctFrom(Type, object)
Picks the first defined member of enumType that differs from
currentValue — fails loudly when the enum has no alternate value, so a
single-member enum cannot silently go unseeded.
Declaration
public static object SeedEnumValueDistinctFrom(Type enumType, object currentValue)
Parameters
| Type |
Name |
Description |
| Type |
enumType |
|
| object |
currentValue |
|
Returns
SeedValueDistinctFrom(FieldInfo, object, string, Object)
Writes a value distinct from currentValue for every scalar field kind a
field-walk suite has to seed — bool negates, int/float/double/LayerMask offset, string returns
seedText verbatim, and enum defers to SeedEnumValueDistinctFrom(Type, object).
A field assignable from UnityEngine.Object (or an array of one) returns
alternateObjectReference when the caller supplies one — a single alternate
reference is all a suite with exactly one Object-typed field kind needs; a suite that must tell
several Object-typed fields apart resolves its own alternates and never reaches this branch.
Returns null for every other field kind — a nested composite type, or a field this walk has
no alternate for — so the caller's own Assert.Fail names the field that slipped through.
currentValue must be the field's actual current value for bool/int/float/double/
LayerMask/enum fields: a null there would unbox to a NullReferenceException, or —
for an enum, whose distinct-value search treats a non-matching candidate.Equals(currentValue) as
"keep looking" — silently pick a member that happens to equal the field's real current value, leaving
it unseeded. This throws instead of letting either happen quietly.
Declaration
public static object SeedValueDistinctFrom(FieldInfo field, object currentValue, string seedText, Object alternateObjectReference = null)
Parameters
| Type |
Name |
Description |
| FieldInfo |
field |
|
| object |
currentValue |
|
| string |
seedText |
|
| Object |
alternateObjectReference |
|
Returns