{"record":{"id":"09a15e7a67cb7648","repo":"stride3d/stride","slug":"there-must-be-three-and-only-three-input-values-for-double3","errorCode":null,"errorMessage":"There must be three and only three input values for Double3.","messagePattern":"There must be three and only three input values for Double3\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/Double3.cs","lineNumber":112,"sourceCode":"    /// <param name=\"z\">Initial value for the Z component of the vector.</param>\n    public Double3(Double2 value, double 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=\"Double3\"/> 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 Double3(double[] values)\n    {\n        ArgumentNullException.ThrowIfNull(values);\n        if (values.Length != 3)\n            throw new ArgumentOutOfRangeException(nameof(values), \"There must be three and only three input values for Double3.\");\n\n        X = values[0];\n        Y = values[1];\n        Z = values[2];\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"Double3\"/> struct.\n    /// </summary>\n    /// <param name=\"v\">The Vector3 to construct the Double3 from.</param>\n    public Double3(Vector3 v)\n    {\n        X = v.X;\n        Y = v.Y;\n        Z = v.Z;\n    }\n\n    /// <summary>","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/Double3.cs#L94-L130","documentation":"The Double3(double[] values) constructor requires exactly three elements and copies them into X, Y and Z. A null array throws ArgumentNullException; an array of any other length throws ArgumentOutOfRangeException. This guard guarantees the component fields are always initialized from a complete triple.","triggerScenarios":"Calling new Double3(double[]) with an array whose Length is not 3 (0, 1, 2, 4+ elements).","commonSituations":"Deserializing a vector from parsed text/CSV/config where the split produced an unexpected number of tokens; passing a byte or float buffer before slicing it to three values.","solutions":["Ensure the array has exactly 3 elements before constructing, e.g. if (arr.Length != 3) handle it","Slice or pad the data to three values first (arr.Take(3).ToArray() or extend a 2-element array)","For scattered data, build the vector explicitly: new Double3(arr[0], arr[1], arr[2]) after bounds checks"],"exampleFix":"// before\nvar v = new Double3(tokens);\n// after\nif (tokens.Length == 3)\n    var v = new Double3(tokens);\nelse\n    throw new FormatException($\"Expected 3 components, got {tokens.Length}\");","handlingStrategy":"validation","validationCode":"if (values == null) throw new ArgumentNullException(nameof(values));\nif (values.Length != 3) throw new FormatException($\"Double3 needs 3 components, got {values.Length}\");\nvar v = new Double3(values);","typeGuard":"static bool IsDouble3Array(double[]? a) => a is { Length: 3 };","tryCatchPattern":"try { var v = new Double3(values); }\ncatch (ArgumentOutOfRangeException) { /* handle malformed input: log, use default, or rethrow as data error */ }","preventionTips":["Validate parsed component counts at the deserialization boundary","Prefer the Double3(x, y, z) constructor with explicit bounds-checked element access","Store vector data in fixed-size formats (3-element tuples) to make length errors compile-time visible"],"tags":["argument-out-of-range","constructor","mathematics"],"backgroundTag":"invalid-constructor-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"}