{"record":{"id":"926aeb15f05b6995","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-values","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'values')","messagePattern":"Value cannot be null\\. \\(Parameter 'values'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/Vector3.cs","lineNumber":137,"sourceCode":"    /// <param name=\"value\">A vector containing the values with which to initialize the X and Y components.</param>\n    /// <param name=\"z\">Initial value for the Z component of the vector.</param>\n    public Vector3(Vector2 value, float z)\n    {\n        X = value.X;\n        Y = value.Y;\n        Z = z;\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"Stride.Core.Mathematics.Vector3\"/> struct.\n    /// </summary>\n    /// <param name=\"values\">The values to assign to the X, Y, and Z components of the vector. This must be an array with three elements.</param>\n    /// <exception cref=\"ArgumentNullException\">Thrown when <paramref name=\"values\"/> is <c>null</c>.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\">Thrown when <paramref name=\"values\"/> contains more or less than three elements.</exception>\n    public Vector3(float[] values)\n    {\n        if (values == null)\n            throw new ArgumentNullException(nameof(values));\n        if (values.Length != 3)\n            throw new ArgumentOutOfRangeException(nameof(values), \"There must be three and only three input values for Vector3.\");\n\n        X = values[0];\n        Y = values[1];\n        Z = values[2];\n    }\n\n    /// <summary>\n    /// Gets a value indicting whether this instance is normalized.\n    /// </summary>\n    public readonly bool IsNormalized\n    {\n        get { return MathF.Abs((X * X) + (Y * Y) + (Z * Z) - 1f) < MathUtil.ZeroTolerance; }\n    }\n\n    /// <summary>\n    /// Gets or sets the component at the specified index.","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/Vector3.cs#L119-L155","documentation":"Thrown by the Vector3(float[] values) constructor when the values array is null. The constructor copies three elements (X, Y, Z) from the array, so null cannot be accepted. Documented as ArgumentNullException in the XML docs.","triggerScenarios":"Calling new Vector3(null), typically with an array read from config, a file, or a deserializer that returned null.","commonSituations":"Config/JSON parsing yielding null arrays for missing keys; interop code passing null float buffers; factory methods returning null on failure.","solutions":["Pass a non-null array with exactly three floats: new Vector3(new float[]{x, y, z})","Null-check before constructing and fall back to Vector3.Zero","Fix the upstream parser/loader that produced a null array"],"exampleFix":"// before\nvar v = new Vector3(values); // values may be null\n// after\nvar v = values != null && values.Length == 3 ? new Vector3(values) : Vector3.Zero;","handlingStrategy":"validation","validationCode":"if (values == null || values.Length != 3)\n    throw new ArgumentException(\"Vector3 requires a non-null 3-element array\");","typeGuard":"static bool IsValidVector3Values(float[] values) => values != null && values.Length == 3;","tryCatchPattern":"try { var v = new Vector3(values); }\ncatch (ArgumentNullException) { var v = Vector3.Zero; }","preventionTips":["Null-check parsed arrays before constructing vectors","Use the Vector3(x, y, z) component constructor when possible","Make loaders return empty arrays instead of null"],"tags":["csharp","null-argument","constructor"],"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"}