{"record":{"id":"798710b285693bc0","repo":"stride3d/stride","slug":"multi-dimensional-arrays-are-not-supported","errorCode":null,"errorMessage":"Multi-dimensional arrays are not supported.","messagePattern":"Multi-dimensional arrays are not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Serialization/YamlAssemblyRegistry.cs","lineNumber":446,"sourceCode":"            }\n            if (genericArguments != null || arrayNesting > 0)\n            {\n                var genericType = shortAssemblyQualifiedName.Substring(0, firstBracket) + shortAssemblyQualifiedName.Substring(lastBracket + 1);\n                return genericType;\n            }\n            return shortAssemblyQualifiedName;\n        }\n\n        private static void DoGetShortAssemblyQualifiedName(Type type, StringBuilder sb, bool appendAssemblyName = true)\n        {\n            // namespace\n            sb.Append(type.Namespace).Append(\".\");\n            // check if it's an array, store the information, and work on the element type\n            var arrayNesting = 0;\n            while (type.IsArray)\n            {\n                if (type.GetArrayRank() != 1)\n                    throw new NotSupportedException(\"Multi-dimensional arrays are not supported.\");\n                type = type.GetElementType();\n                ++arrayNesting;\n            }\n            // nested declaring types\n            var declaringType = type.DeclaringType;\n            if (declaringType != null)\n            {\n                var declaringTypeName = string.Empty;\n                do\n                {\n                    declaringTypeName = declaringType.Name + \"+\" + declaringTypeName;\n                    declaringType = declaringType.DeclaringType;\n                } while (declaringType != null);\n                sb.Append(declaringTypeName);\n            }\n            // type\n            sb.Append(type.Name);\n            // generic arguments","sourceCodeStart":428,"sourceCodeEnd":464,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Serialization/YamlAssemblyRegistry.cs#L428-L464","documentation":"YamlAssemblyRegistry.DoGetShortAssemblyQualifiedName throws NotSupportedException when generating a short assembly-qualified type name for a multi-dimensional array (GetArrayRank() != 1). Only single-dimensional (possibly jagged) arrays are supported in the serialized type name format.","triggerScenarios":"Serializing a type such as int[,] or string[,,] where the serializer needs a short assembly-qualified name (e.g. emitting type tags or registering assemblies). Jagged arrays int[][] pass because their element types are traversed.","commonSituations":"Models containing rectangular 2D grids (matrices, tile maps) serialized to YAML for save files or asset pipelines; switching a property from int[][] to int[,] during refactoring; data-structure code ported from languages where multidimensional arrays are idiomatic.","solutions":["Replace the multi-dimensional array with a jagged array (T[][]) in the model.","Replace with a single-dimensional array plus explicit width/height fields, reconstructing the grid on load.","Wrap the data in a serializable class (e.g. a Matrix/Grid type with rows as lists).","Serialize the flat data as int[] with dimension metadata."],"exampleFix":"// before\npublic int[,] Grid { get; set; }\n// after\npublic int[][] Grid { get; set; } // or store width/height + flat int[]","handlingStrategy":"type-guard","validationCode":"static void AssertYamlSerializableShape(Type t) { if (t.IsArray && t.GetArrayRank() != 1) throw new NotSupportedException($\"{t} is a multi-dimensional array; YAML serializer supports only single-dimensional arrays\"); }","typeGuard":"static bool IsSupportedArrayType(Type t) => !t.IsArray || t.GetArrayRank() == 1;","tryCatchPattern":"try { serializer.Serialize(writer, graph); } catch (NotSupportedException ex) when (ex.Message.Contains(\"Multi-dimensional arrays\")) { throw new NotSupportedException(\"Replace T[,] with T[][] or a wrapper class before YAML serialization\", ex); }","preventionTips":["Avoid rectangular arrays (T[,]) in serializable models; use jagged arrays or wrapper classes.","Add a model audit that scans for GetArrayRank() != 1 before enabling YAML persistence.","Store grids as flat arrays plus dimension metadata.","Test serialize/deserialize round-trips for all model types."],"tags":["yaml","serialization","arrays","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}