{"record":{"id":"19cf822a3adab73c","repo":"stride3d/stride","slug":"vertexbufferdata","errorCode":null,"errorMessage":"vertexBufferData","messagePattern":"vertexBufferData","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/VertexHelper.cs","lineNumber":38,"sourceCode":"\n        /// <summary>\n        /// Generates multi texture coordinates for an existing vertex buffer. See remarks.\n        /// </summary>\n        /// <param name=\"vertexDeclaration\">The vertex declaration.</param>\n        /// <param name=\"vertexBufferData\">The vertex buffer data.</param>\n        /// <param name=\"maxTexcoord\">The maximum texcoord.</param>\n        /// <returns>A new vertex buffer with additional texture coordinates.</returns>\n        /// <exception cref=\"System.ArgumentNullException\">\n        /// vertexDeclaration\n        /// or\n        /// vertexBufferData\n        /// </exception>\n        /// <remarks>The original vertex buffer must contain at least a TEXCOORD[0-9] attribute in order for this method to work.\n        /// This method will copy the value of the first existing TEXCOORD found in the vertex buffer to the newly created TEXCOORDS.</remarks>\n        public static unsafe VertexTransformResult GenerateMultiTextureCoordinates<T>(VertexDeclaration vertexDeclaration, T[] vertexBufferData, int maxTexcoord = 9) where T : unmanaged\n        {\n            if (vertexDeclaration == null) throw new ArgumentNullException(\"vertexDeclaration\");\n            if (vertexBufferData == null) throw new ArgumentNullException(\"vertexBufferData\");\n            var vertexStride = Unsafe.SizeOf<T>();\n            fixed (void* vertexBufferPtr = vertexBufferData)\n                return GenerateMultiTextureCoordinates(vertexDeclaration, (nint)vertexBufferPtr, vertexBufferData.Length, 0, vertexStride, maxTexcoord);\n        }\n\n        /// <summary>\n        /// Generates multi texture coordinates for an existing vertex buffer. See remarks.\n        /// </summary>\n        /// <param name=\"vertexDeclaration\">The vertex declaration.</param>\n        /// <param name=\"vertexBufferData\">The vertex buffer data.</param>\n        /// <param name=\"vertexStride\">The vertex stride.</param>\n        /// <param name=\"maxTexcoord\">The maximum texcoord.</param>\n        /// <returns>A new vertex buffer with additional texture coordinates.</returns>\n        /// <exception cref=\"System.ArgumentNullException\">\n        /// vertexDeclaration\n        /// or\n        /// vertexBufferData\n        /// </exception>","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/VertexHelper.cs#L20-L56","documentation":"The generic T[] overload of GenerateMultiTextureCoordinates throws ArgumentNullException('vertexBufferData') when the vertex data array is null. The array is pinned and scanned for TEXCOORD elements, so null data is unusable.","triggerScenarios":"Calling VertexHelper.GenerateMultiTextureCoordinates<T>(declaration, (T[])null) — e.g. a mesh whose vertex buffer array was never allocated or was set to null by a failed load.","commonSituations":"Mesh import returned no vertex data; array field default-initialized; asynchronous content loading finished out of order.","solutions":["Ensure the vertex data array is allocated and populated before calling the helper.","Add an explicit null/empty check with a clear error before the call.","Fix the loading path that produced the null array."],"exampleFix":"// before\nvar result = VertexHelper.GenerateMultiTextureCoordinates(declaration, vertices);\n// after\nif (vertices == null || vertices.Length == 0) throw new InvalidOperationException(\"Vertex data must be loaded first\");\nvar result = VertexHelper.GenerateMultiTextureCoordinates(declaration, vertices);","handlingStrategy":"validation","validationCode":"if (vertexBufferData is null || vertexBufferData.Length == 0) throw new InvalidOperationException(\"Vertex data array must be loaded and non-empty\");","typeGuard":"bool HasVertexData<T>(T[] data) where T : unmanaged => data is { Length: > 0 };","tryCatchPattern":"try { var r = VertexHelper.GenerateMultiTextureCoordinates(decl, data); } catch (ArgumentNullException ex) when (ex.ParamName == \"vertexBufferData\") { /* load mesh data first */ }","preventionTips":["Load vertex arrays before running vertex transformations","Check content-load results for null before proceeding","Keep buffer allocation and its consumers in the same initialization path"],"tags":["argument-validation","graphics","null-argument"],"backgroundTag":"null-argument","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"}