{"record":{"id":"a9bc6db6b9ea4886","repo":"stride3d/stride","slug":"value-must-be-in-between-1-and-32","errorCode":null,"errorMessage":"Value must be in between 1 and 32","messagePattern":"Value must be in between 1 and 32","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/PrimitiveTypeExtensions.cs","lineNumber":31,"sourceCode":"    /// <summary>\n    ///   Interpret the input vertex data type as a <strong>patch list</strong> for tesselation with a\n    ///   specific number of <strong>control points</strong>.\n    /// </summary>\n    /// <param name=\"controlPoints\">The number of control points. It must be a value in the range 1 to 32, inclusive.</param>\n    /// <returns>\n    ///   A <see cref=\"PrimitiveType\"/> value that represents a patch list with the specified number of control points.\n    /// </returns>\n    /// <exception cref=\"ArgumentException\">Control points apply only to <see cref=\"PrimitiveType.PatchList\"/>.</exception>\n    /// <exception cref=\"ArgumentOutOfRangeException\"><paramref name=\"controlPoints\"/> must be in the range 1 to 32, inclusive.</exception>\"\n    public static PrimitiveType ControlPointCount(this PrimitiveType primitiveType, int controlPoints)\n    {\n        if (primitiveType != PrimitiveType.PatchList)\n            throw new ArgumentException($\"Control points apply only to {nameof(PrimitiveType)}.{nameof(PrimitiveType.PatchList)}\", nameof(primitiveType));\n\n        const int MIN_CONTROL_POINTS = 1, MAX_CONTROL_POINTS = 32;\n\n        if (controlPoints < MIN_CONTROL_POINTS || controlPoints > MAX_CONTROL_POINTS)\n            throw new ArgumentOutOfRangeException(nameof(controlPoints), $\"Value must be in between {MIN_CONTROL_POINTS} and {MAX_CONTROL_POINTS}\");\n\n        return PrimitiveType.PatchList + controlPoints - 1;\n    }\n}\n","sourceCodeStart":13,"sourceCodeEnd":36,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/PrimitiveTypeExtensions.cs#L13-L36","documentation":"ControlPointCount converts a base PrimitiveType into a PatchList primitive type with the given number of control points. The library throws ArgumentOutOfRangeException because tessellation patches only support between 1 and 32 control points; anything outside that range cannot be mapped onto a valid primitive type enum value.","triggerScenarios":"Calling ControlPointCount with controlPoints < 1 or > 32, e.g. ControlPointCount(PrimitiveType.PatchList, 0) or 33.","commonSituations":"Configuring tessellation in rendering pipelines where the patch control-point count comes from a user-supplied asset or shader constant that was not clamped; off-by-one errors using 33 instead of 32.","solutions":["Pass a control-point count between 1 and 32 (inclusive), matching the count declared in your hull/domain shader","Clamp or validate the value before calling: Math.Clamp(controlPoints, 1, 32)","Check the source asset/shader for an incorrect control point count value"],"exampleFix":"// before\nvar type = ControlPointCount(PrimitiveType.PatchList, 40);\n// after\nvar type = ControlPointCount(PrimitiveType.PatchList, Math.Clamp(controlPoints, 1, 32));","handlingStrategy":"validation","validationCode":"if (controlPoints < 1 || controlPoints > 32) throw new ArgumentOutOfRangeException(nameof(controlPoints));","typeGuard":null,"tryCatchPattern":"try { type = ControlPointCount(PrimitiveType.PatchList, n); } catch (ArgumentOutOfRangeException) { type = PrimitiveType.TriangleList; }","preventionTips":["Clamp control-point counts from external data to [1,32] before use","Keep the count consistent with the hull shader's declared control points"],"tags":["graphics","argument-out-of-range","tessellation"],"backgroundTag":"value-out-of-range","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"}