{"record":{"id":"e46a21badf3e2d7e","repo":"stride3d/stride","slug":"vertexdeclaration","errorCode":null,"errorMessage":"vertexDeclaration","messagePattern":"vertexDeclaration","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/VertexHelper.cs","lineNumber":37,"sourceCode":"        // TODO: Write some unit tests!\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=\"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","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/VertexHelper.cs#L19-L55","documentation":"GenerateMultiTextureCoordinates requires a non-null VertexDeclaration describing the vertex layout; the library throws ArgumentNullException('vertexDeclaration') at entry if null is passed. The declaration is needed to locate the existing TEXCOORD attribute and compute strides, so it cannot proceed without it.","triggerScenarios":"Calling VertexHelper.GenerateMultiTextureCoordinates(null, vertexBufferData) (any of the T[], byte[], or IntPtr overloads) with an uninitialized/null VertexDeclaration.","commonSituations":"VertexDeclaration loaded lazily or from a failed mesh import; a member field never assigned before use; refactoring moved declaration creation after the call.","solutions":["Construct or obtain the VertexDeclaration before calling (e.g. VertexDeclaration.New(...) or from the existing mesh's VertexBuffer.Binding).","Guard with a null check or assert before invoking the helper.","Fix the code path that returns null for the declaration (failed asset load, uninitialized field)."],"exampleFix":"// before\nvar result = VertexHelper.GenerateMultiTextureCoordinates(declaration, vertexData);\n// after\nif (declaration == null) throw new InvalidOperationException(\"Vertex declaration must be built before generating multi texture coordinates\");\nvar result = VertexHelper.GenerateMultiTextureCoordinates(declaration, vertexData);","handlingStrategy":"validation","validationCode":"if (vertexDeclaration is null) throw new InvalidOperationException(\"vertexDeclaration must be provided before calling GenerateMultiTextureCoordinates\");","typeGuard":"bool HasDeclaration(VertexDeclaration d) => d is not null;","tryCatchPattern":"try { var r = VertexHelper.GenerateMultiTextureCoordinates(decl, data); } catch (ArgumentNullException ex) when (ex.ParamName == \"vertexDeclaration\") { /* build/assign declaration and retry */ }","preventionTips":["Always derive the declaration from the source mesh's vertex buffer binding","Assert non-null declarations in mesh preprocessing pipelines","Construct declarations with VertexDeclaration.New next to buffer creation"],"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"}