logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    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
    object
    UnitySerializedFieldSeeds
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.Tests.Shared
    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
    Type Description
    object

    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
    Type Description
    object
    In this article
    © 2026 Serenity. All Rights Reserved