{"record":{"id":"48f032357970eb45","repo":"stride3d/stride","slug":"there-must-be-two-and-only-two-input-values-for-double2","errorCode":null,"errorMessage":"There must be two and only two input values for Double2.","messagePattern":"There must be two and only two input values for Double2\\.","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/Double2.cs","lineNumber":86,"sourceCode":"    /// <param name=\"x\">Initial value for the X component of the vector.</param>\n    /// <param name=\"y\">Initial value for the Y component of the vector.</param>\n    public Double2(double x, double y)\n    {\n        X = x;\n        Y = y;\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"Double2\"/> struct.\n    /// </summary>\n    /// <param name=\"values\">The values to assign to the X and Y components of the vector. This must be an array with two 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 two elements.</exception>\n    public Double2(double[] values)\n    {\n        ArgumentNullException.ThrowIfNull(values);\n        if (values.Length != 2)\n            throw new ArgumentOutOfRangeException(nameof(values), \"There must be two and only two input values for Double2.\");\n\n        X = values[0];\n        Y = values[1];\n    }\n\n    /// <summary>\n    /// Initializes a new instance of the <see cref=\"Double2\"/> struct.\n    /// </summary>\n    /// <param name=\"v\">The Vector2 to construct the Double2 from.</param>\n    public Double2(Vector2 v)\n    {\n        X = v.X;\n        Y = v.Y;\n    }\n\n    /// <summary>\n    /// Gets a value indicting whether this instance is normalized.\n    /// </summary>","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/Double2.cs#L68-L104","documentation":"The Double2(double[] values) constructor requires the input array to contain exactly two elements (X and Y). The library throws ArgumentOutOfRangeException when the array length differs from 2, after a separate null check.","triggerScenarios":"Calling new Double2(someArray) where someArray.Length != 2, e.g. passing an empty array, a single-element array, or a larger buffer.","commonSituations":"Building vectors from parsed config/file data where the split produced fewer or more tokens; passing a raw data buffer instead of a 2-element slice; upstream data schema changes altering array length.","solutions":["Validate values.Length == 2 before constructing; slice or pad the array as needed.","If you have more data, extract exactly two elements: new Double2(data[0], data[1]).","Use the Double2(x, y) constructor instead of the array constructor when components are known individually."],"exampleFix":"// before\nvar v = new Double2(tokens);\n// after\nif (tokens.Length != 2) throw new FormatException(\"Expected 2 components\");\nvar v = new Double2(tokens[0], tokens[1]);","handlingStrategy":"validation","validationCode":"if (values is null) throw new ArgumentNullException(nameof(values));\nif (values.Length != 2) throw new ArgumentException(\"Double2 requires exactly 2 values\", nameof(values));\nvar v = new Double2(values);","typeGuard":"bool IsPair(double[]? a) => a is { Length: 2 };","tryCatchPattern":"try { var v = new Double2(values); }\ncatch (ArgumentOutOfRangeException ex) { /* handle malformed input array */ }","preventionTips":["Slice or validate input arrays to exactly 2 elements before constructing.","Prefer the Double2(x, y) constructor when components are known.","Validate parsed/config data lengths at the parsing boundary."],"tags":["argument-out-of-range","constructor","csharp","vector"],"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"}