{"record":{"id":"4d7b67f22a4430ec","repo":"egametang/ET","slug":"serialization-missingvalues","errorCode":null,"errorMessage":"Serialization_MissingValues","messagePattern":"Serialization_MissingValues","errorType":"exception","errorClass":"SerializationException","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs","lineNumber":1723,"sourceCode":"            {\n                return; // Somebody had a dependency on this class and fixed us up before the ObjectManager got to it.\n            }\n\n            if (siInfo == null)\n            {\n                throw new SerializationException(SR.Serialization_InvalidOnDeser);\n            }\n\n            comparer = (IComparer<T>)siInfo.GetValue(ComparerName, typeof(IComparer<T>))!;\n            int savedCount = siInfo.GetInt32(CountName);\n\n            if (savedCount != 0)\n            {\n                T[] items = (T[])siInfo.GetValue(ItemsName, typeof(T[]));\n\n                if (items == null)\n                {\n                    throw new SerializationException(SR.Serialization_MissingValues);\n                }\n\n                for (int i = 0; i < items.Length; i++)\n                {\n                    Add(items[i]);\n                }\n            }\n\n            version = siInfo.GetInt32(VersionName);\n            if (count != savedCount)\n            {\n                throw new SerializationException(SR.Serialization_MismatchedCount);\n            }\n\n            siInfo = null;\n        }\n\n        #endregion","sourceCodeStart":1705,"sourceCodeEnd":1741,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.core/Scripts/Core/Share/Collection/SortedSet.cs#L1705-L1741","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-serialize the source data with the current code so both Count and Items are written.","Audit any custom GetObjectData/serialization surrogate to confirm it writes ItemsName when count > 0.","If migrating formats, write a converter that replays elements via Add rather than trusting the raw stream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before trusting a serialized set, verify the payload has both count and items in your own writer.\n// info.AddValue(CountName, set.Count); info.AddValue(ItemsName, set.ToArray());","typeGuard":null,"tryCatchPattern":"try { /* deserialize */ } catch (SerializationException ex) when (ex.Message.Contains(\"Serialization_MissingValues\")) { /* mark stream invalid, regenerate */ }","preventionTips":["Write all three keys (Comparer, Count, Items) together in custom surrogates.","Regenerate persisted data after schema/format changes.","Round-trip test serialization of non-empty sets in CI."],"tags":["sortedset","serialization","data-corruption","csharp"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}