egametang/ET · error · SerializationException

Serialization_MissingValues

Error message

Serialization_MissingValues

What it means

Thrown during OnDeserialization when the stored CountName is non-zero but the ItemsName entry (the T[] payload) is missing/null. The stream is internally inconsistent: it claims elements exist but none were written. Surfaces as a SerializationException (Serialization_MissingValues).

Source

Thrown at Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs:1723

            {
                return; // Somebody had a dependency on this class and fixed us up before the ObjectManager got to it.
            }

            if (siInfo == null)
            {
                throw new SerializationException(SR.Serialization_InvalidOnDeser);
            }

            comparer = (IComparer<T>)siInfo.GetValue(ComparerName, typeof(IComparer<T>))!;
            int savedCount = siInfo.GetInt32(CountName);

            if (savedCount != 0)
            {
                T[] items = (T[])siInfo.GetValue(ItemsName, typeof(T[]));

                if (items == null)
                {
                    throw new SerializationException(SR.Serialization_MissingValues);
                }

                for (int i = 0; i < items.Length; i++)
                {
                    Add(items[i]);
                }
            }

            version = siInfo.GetInt32(VersionName);
            if (count != savedCount)
            {
                throw new SerializationException(SR.Serialization_MismatchedCount);
            }

            siInfo = null;
        }

        #endregion

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Re-serialize the source data with the current code so both Count and Items are written.
  2. Audit any custom GetObjectData/serialization surrogate to confirm it writes ItemsName when count > 0.
  3. If migrating formats, write a converter that replays elements via Add rather than trusting the raw stream.
Defensive patterns

Strategy: validation

Validate before calling

// Before trusting a serialized set, verify the payload has both count and items in your own writer.
// info.AddValue(CountName, set.Count); info.AddValue(ItemsName, set.ToArray());

Try / catch

try { /* deserialize */ } catch (SerializationException ex) when (ex.Message.Contains("Serialization_MissingValues")) { /* mark stream invalid, regenerate */ }

Prevention

When it happens

Trigger: Deserializing a SortedSet whose serialized payload was truncated; a surrogate/selectors that wrote Count but skipped Items; version skew between the serializing and deserializing code that changed the ItemsName key; corrupted stream.

Common situations: Cross-version persistence (old data written before ItemsName existed); hand-edited or partially copied binary blobs; a custom ISerializable wrapper that forwards Count but drops the items array.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/4d7b67f22a4430ec. Report an issue: GitHub.