{"record":{"id":"159cf292e119dab6","repo":"stride3d/stride","slug":"cannot-support-dimension-0-for-type-1-only-supporting","errorCode":null,"errorMessage":"Cannot support dimension [{0}] for type [{1}]. Only supporting dimension of 1","messagePattern":"Cannot support dimension \\[(.+?)\\] for type \\[(.+?)\\]\\. Only supporting dimension of 1","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Reflection/TypeDescriptors/ArrayDescriptor.cs","lineNumber":20,"sourceCode":"// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.\n\nusing Stride.Core.Yaml.Serialization;\n\nnamespace Stride.Core.Reflection;\n\n/// <summary>\n/// A descriptor for an array.\n/// </summary>\npublic class ArrayDescriptor : CollectionBaseDescriptor\n{\n    public ArrayDescriptor(ITypeDescriptorFactory factory, Type type, bool emitDefaultValues, IMemberNamingConvention namingConvention)\n        : base(factory, type, emitDefaultValues, namingConvention)\n    {\n        if (!type.IsArray) throw new ArgumentException(\"Expecting array type\", nameof(type));\n\n        if (type.GetArrayRank() != 1)\n        {\n            throw new ArgumentException(\"Cannot support dimension [{0}] for type [{1}]. Only supporting dimension of 1\".ToFormat(type.GetArrayRank(), type.FullName));\n        }\n\n        ElementType = type.GetElementType()!;\n    }\n\n    public override DescriptorCategory Category => DescriptorCategory.Array;\n\n    /// <summary>\n    /// Gets the type of the array element.\n    /// </summary>\n    /// <value>The type of the element.</value>\n    public Type ElementType { get; }\n\n    /// <summary>\n    /// Creates the equivalent of list type for this array.\n    /// </summary>\n    /// <returns>A list type with same element type than this array.</returns>\n    public Array CreateArray(int dimension)","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Reflection/TypeDescriptors/ArrayDescriptor.cs#L2-L38","documentation":"Stride's reflection layer only supports single-dimensional (rank-1) arrays in ArrayDescriptor. When the constructor sees type.GetArrayRank() != 1 — i.e. a multidimensional array like int[,] — it throws ArgumentException naming the unsupported dimension and type.","triggerScenarios":"Creating an ArrayDescriptor for typeof(int[,]), typeof(string[,,]) etc., or registering a multidimensional array type with the descriptor factory.","commonSituations":"Serializing/deserializing models that contain rectangular or jagged multidimensional arrays; legacy data structures using T[,]; unit tests exercising arbitrary Type instances through the descriptor factory.","solutions":["Replace multidimensional arrays with jagged arrays (int[][]) or List<List<int>>, which are supported.","Flatten the array to rank-1 (T[] with computed offsets) before it reaches the serialization/descriptor layer.","Implement a custom TypeDescriptor for multidimensional arrays if support is truly required."],"exampleFix":"// before\npublic int[,] Grid;\n// after\npublic int[][] Grid; // jagged array, supported by Stride serialization","handlingStrategy":"type-guard","validationCode":"if (type.IsArray && type.GetArrayRank() != 1)\n    throw new NotSupportedException(\"Multidimensional arrays are not supported; use jagged arrays.\");","typeGuard":"static bool IsSupportedArray(Type t) => t.IsArray && t.GetArrayRank() == 1;","tryCatchPattern":"try { var d = new ArrayDescriptor(factory, type, true, naming); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Only supporting dimension of 1\")) { /* use jagged arrays */ }","preventionTips":["Model grid data as jagged arrays (T[][]) or List<List<T>> instead of T[,].","Audit serialized models for multidimensional array fields during upgrades."],"tags":["unsupported-type","arrays","serialization"],"backgroundTag":"operation-not-supported","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"}