{"record":{"id":"b21d0c0d27b3a519","repo":"stride3d/stride","slug":"array-cannot-be-empty-or-null","errorCode":null,"errorMessage":"Array cannot be empty or null.","messagePattern":"Array cannot be empty or null\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Mathematics/BoundingSphere.cs","lineNumber":194,"sourceCode":"    /// <summary>\n    /// Determines whether the current objects contains a <see cref=\"BoundingSphere\"/>.\n    /// </summary>\n    /// <param name=\"sphere\">The sphere to test.</param>\n    /// <returns>The type of containment the two objects have.</returns>\n    public ContainmentType Contains(ref readonly BoundingSphere sphere)\n    {\n        return CollisionHelper.SphereContainsSphere(ref this, in sphere);\n    }\n\n    /// <summary>\n    /// Constructs a <see cref=\"BoundingSphere\"/> that fully contains the given points.\n    /// </summary>\n    /// <param name=\"points\">The points that will be contained by the sphere.</param>\n    /// <param name=\"result\">When the method completes, contains the newly constructed bounding sphere.</param>\n    public static unsafe void FromPoints(Vector3[] points, out BoundingSphere result)\n    {\n        ArgumentNullException.ThrowIfNull(points);\n        if (points.Length == 0) throw new ArgumentException(\"Array cannot be empty or null.\", nameof(points));\n        fixed (void* pointsPtr = points)\n        {\n            FromPoints((IntPtr)pointsPtr, 0, points.Length, Unsafe.SizeOf<Vector3>(), out result);\n        }\n    }\n\n    /// <summary>\n    /// Constructs a <see cref=\"Stride.Core.Mathematics.BoundingSphere\" /> that fully contains the given unmanaged points.\n    /// </summary>\n    /// <param name=\"vertexBufferPtr\">A pointer to of vertices containing points.</param>\n    /// <param name=\"vertexPositionOffsetInBytes\">The point offset in bytes starting from the vertex structure.</param>\n    /// <param name=\"vertexCount\">The verterx vertexCount.</param>\n    /// <param name=\"vertexStride\">The vertex stride (size of vertex).</param>\n    /// <param name=\"result\">When the method completes, contains the newly constructed bounding sphere.</param>\n    public static unsafe void FromPoints(IntPtr vertexBufferPtr, int vertexPositionOffsetInBytes, int vertexCount, int vertexStride, out BoundingSphere result)\n    {\n        if (vertexBufferPtr == IntPtr.Zero)\n        {","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Mathematics/BoundingSphere.cs#L176-L212","documentation":"BoundingSphere.FromPoints(Vector3[]) computes the minimal bounding sphere from an array of points and requires at least one point. Null is rejected with ArgumentNullException and an empty array with this ArgumentException, since no sphere can be derived from zero points.","triggerScenarios":"Calling BoundingSphere.FromPoints with an empty array (points.Length == 0), typically from data sources that produced no vertices, filtered-out points, or an uninitialized buffer.","commonSituations":"Mesh loading where a submesh has zero vertices; point clouds after aggressive culling; deserialized geometry lists that are empty by default.","solutions":["Check points != null && points.Length > 0 before calling; pick a defined fallback for the empty case.","Skip sphere computation entirely when there are no points.","Fix the upstream data source that produces the empty point list.","If degenerate input is possible, wrap in try-catch ArgumentException and substitute a default sphere."],"exampleFix":"// before\nBoundingSphere.FromPoints(points, out var sphere); // throws when points is empty\n// after\nvar sphere = points.Length > 0\n    ? BoundingSphere.FromPoints(points)\n    : new BoundingSphere(Vector3.Zero, 0f);","handlingStrategy":"validation","validationCode":"if (points is not { Length: > 0 })\n    throw new ArgumentException(\"points must contain at least one vertex.\", nameof(points));","typeGuard":"bool HasPoints(Vector3[]? p) => p is { Length: > 0 };","tryCatchPattern":"try { BoundingSphere.FromPoints(points, out var s); }\ncatch (ArgumentException) { var s = new BoundingSphere(Vector3.Zero, 0f); }","preventionTips":["Validate geometry lists at load boundaries","Define a documented degenerate-sphere fallback","Skip empty submeshes before spatial computations"],"tags":["math","geometry","empty-input"],"backgroundTag":"empty-required-field","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"}