{"record":{"id":"344d58d2d3a74f8e","repo":"stride3d/stride","slug":"the-type-typeof-t-fullname-cannot-be-only-be-used-for-clone","errorCode":null,"errorMessage":"The type [{typeof(T).FullName}] cannot be only be used for clone serialization","messagePattern":"The type \\[(.+?)\\] cannot be only be used for clone serialization","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/assets/Stride.Core.Assets/AssetCloner.cs","lineNumber":353,"sourceCode":"        {\n            parentSerializer = serializerSelector.GetSerializer(typeof(T).BaseType!);\n        }\n\n        public override void PreSerialize(ref T obj, ArchiveMode mode, SerializationStream stream)\n        {\n            var invariantObjectList = stream.Context.Get(InvariantObjectListProperty)!;\n            if (mode == ArchiveMode.Serialize)\n            {\n                stream.Write(invariantObjectList.Count);\n                invariantObjectList.Add(obj);\n            }\n            else\n            {\n                var index = stream.Read<int>();\n\n                if (index >= invariantObjectList.Count)\n                {\n                    throw new InvalidOperationException($\"The type [{typeof(T).FullName}] cannot be only be used for clone serialization\");\n                }\n\n                if (invariantObjectList[index] is not T invariant)\n                {\n                    throw new InvalidOperationException($\"Unexpected null {typeof(T).FullName} while cloning\");\n                }\n\n                // Create a new object to avoid exception in case its identity is important\n                obj = (T)Activator.CreateInstance(typeof(T), invariant.TypeName, invariant.AssemblyName, invariant.Error, invariant.ParsingEvents)!;\n            }\n        }\n\n        public override void Serialize(ref T obj, ArchiveMode mode, SerializationStream stream)\n        {\n            // Process with parent serializer first\n            object parentObj = obj;\n            parentSerializer?.Serialize(ref parentObj, mode, stream);\n            obj = (T)parentObj;","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/assets/Stride.Core.Assets/AssetCloner.cs#L335-L371","documentation":"Internal clone-serialization consistency error in AssetCloner.PreSerialize (deserialization side): the index read from the stream is beyond the count of the invariant-object list gathered during serialization. This clone-serialization helper type can only be used through the cloner, so this indicates mismatched or corrupted clone streams rather than a user-input problem.","triggerScenarios":"Thrown at sources/assets/Stride.Core.Assets/AssetCloner.cs:353 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the same cloner configuration produces and consumes the stream","Avoid reusing/persisting clone streams across versions or configurations","Report as an engine bug if it reproduces with a self-contained clone operation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}