{"record":{"id":"5c60c26e35e2bd9c","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-source-vector3","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'source')","messagePattern":"Value cannot be null\\. \\(Parameter 'source'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/Vector3.cs","lineNumber":1044,"sourceCode":"    /// list.</para>\n    /// <para>Because this method uses the modified Gram-Schmidt process, the resulting vectors\n    /// tend to be numerically unstable. The numeric stability decreases according to the vectors\n    /// position in the list so that the first vector is the most stable and the last vector is the\n    /// least stable.</para>\n    /// </remarks>\n    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"source\"/> or <paramref name=\"destination\"/> is <c>null</c>.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">Thrown when <paramref name=\"destination\"/> is shorter in length than <paramref name=\"source\"/>.</exception>\n    public static void Orthogonalize(Vector3[] destination, params Vector3[] source)\n    {\n        //Uses the modified Gram-Schmidt process.\n        //q1 = m1\n        //q2 = m2 - ((q1 ⋅ m2) / (q1 ⋅ q1)) * q1\n        //q3 = m3 - ((q1 ⋅ m3) / (q1 ⋅ q1)) * q1 - ((q2 ⋅ m3) / (q2 ⋅ q2)) * q2\n        //q4 = m4 - ((q1 ⋅ m4) / (q1 ⋅ q1)) * q1 - ((q2 ⋅ m4) / (q2 ⋅ q2)) * q2 - ((q3 ⋅ m4) / (q3 ⋅ q3)) * q3\n        //q5 = ...\n\n        if (source == null)\n            throw new ArgumentNullException(nameof(source));\n        if (destination == null)\n            throw new ArgumentNullException(nameof(destination));\n        if (destination.Length < source.Length)\n            throw new ArgumentOutOfRangeException(nameof(destination), \"The destination array must be of same length or larger length than the source array.\");\n\n        for (int i = 0; i < source.Length; ++i)\n        {\n            Vector3 newvector = source[i];\n\n            for (int r = 0; r < i; ++r)\n            {\n                newvector -= (Vector3.Dot(destination[r], newvector) / Vector3.Dot(destination[r], destination[r])) * destination[r];\n            }\n\n            destination[i] = newvector;\n        }\n    }\n","sourceCodeStart":1026,"sourceCodeEnd":1062,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/Vector3.cs#L1026-L1062","documentation":"Thrown by a Vector3 array-transform method (Gram-Schmidt orthogonalization helper) when the source array is null. The method loops over source elements to build orthogonal vectors, so a null source is rejected immediately with ArgumentNullException.","triggerScenarios":"Calling the transform/orthonormalize API with a null source array, e.g. from an uninitialized vertex/normal array or a null return from a mesh loader.","commonSituations":"Mesh processing pipelines where an empty attribute loaded as null; refactoring that moved array creation after the transform call.","solutions":["Allocate the source array before calling, e.g. new Vector3[n]","Null-check and early-return when there is no data to transform","Fix the loader that returned null instead of an empty array"],"exampleFix":"// before\nVector3Helper.Orthonormalize(source, destination); // source null\n// after\nif (source == null || source.Length == 0) return;\nVector3Helper.Orthonormalize(source, destination);","handlingStrategy":"validation","validationCode":"if (source == null || source.Length == 0) return; // nothing to transform","typeGuard":"static bool HasData(Vector3[] a) => a != null && a.Length > 0;","tryCatchPattern":"try { Transform(source, destination); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"source\") { /* skip or allocate */ }","preventionTips":["Check mesh/vertex arrays for null before batch math","Make loaders return empty arrays instead of null","Assert non-null arrays in debug builds before transforms"],"tags":["csharp","null-argument","vector-math"],"backgroundTag":"null-argument","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"}