{"record":{"id":"03b600662fbd85a1","repo":"stride3d/stride","slug":"slot-must-be-in-the-range-0-15","errorCode":null,"errorMessage":"slot must be in the range [0, 15]","messagePattern":"slot must be in the range \\[0, 15\\]","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs","lineNumber":80,"sourceCode":"        {\n            Initialize(context);\n        }\n\n        /// <summary>\n        /// Gets or sets a boolean to enable GraphicsDevice.SetDepthAndRenderTargets from output. Default is <c>true</c>.\n        /// </summary>\n        /// <value>A boolean to enable GraphicsDevice.SetDepthAndRenderTargets from output. Default is <c>true</c></value>\n        protected bool EnableSetRenderTargets { get; set; }\n\n        /// <summary>\n        /// Sets an input texture\n        /// </summary>\n        /// <param name=\"slot\">The slot.</param>\n        /// <param name=\"texture\">The texture.</param>\n        public void SetInput(int slot, Texture texture)\n        {\n            if (slot < 0 || slot >= inputTextures.Length)\n                throw new ArgumentOutOfRangeException(nameof(slot), \"slot must be in the range [0, 15]\");\n\n            inputTextures[slot] = texture;\n            if (slot > maxInputTextureIndex)\n            {\n                maxInputTextureIndex = slot;\n            }\n        }\n\n        /// <summary>\n        /// Resets the state of this effect.\n        /// </summary>\n        public override void Reset()\n        {\n            base.Reset();\n\n            maxInputTextureIndex = -1;\n            Array.Clear(inputTextures, 0, inputTextures.Length);\n            outputDepthStencilView = null;","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Rendering/Rendering/Images/ImageEffect.cs#L62-L98","documentation":"A validation guard in ImageEffect.SetInput: the slot parameter is outside the supported range [0, 15]. Input textures are stored in a fixed-size array of 16 slots; indexing beyond it would throw a raw out-of-range error or corrupt state, so the method validates the slot and throws with the message 'slot must be in the range [0, 15]'.","triggerScenarios":"Calling SetInput with a negative slot or a slot >= 16, e.g. building inputs in a loop without a bound, or a hardcoded slot from a mismatched effect definition.","commonSituations":"Loops that iterate over a list longer than the effect's max inputs; copy-pasted slot indices from another effect; generic image-effect composition code assuming more inputs than supported.","solutions":["Use a slot index between 0 and 15","Check inputTextures.Length / the effect's actual max inputs before assigning","Add a bounds check or clamping around the SetInput call"],"exampleFix":"// before\nfor (int i = 0; i < inputs.Count; i++)\n    effect.SetInput(i, inputs[i]);\n// after\nfor (int i = 0; i < Math.Min(inputs.Count, 16); i++)\n    effect.SetInput(i, inputs[i]);","handlingStrategy":"validation","validationCode":"if (slot < 0 || slot > 15) throw new ArgumentException(\"slot must be in [0, 15]\"); effect.SetInput(slot, texture);","typeGuard":"bool IsValidInputSlot(int slot) => slot >= 0 && slot < 16;","tryCatchPattern":"try { effect.SetInput(slot, texture); } catch (ArgumentOutOfRangeException) { /* clamp or log: invalid slot */ }","preventionTips":["Bound any input-assignment loop by the effect's max input count (16)","Define named slot constants instead of magic numbers","Verify slot indices when porting effects between shader stages"],"tags":["csharp","argumentoutofrange","texture","rendering"],"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-23T08:17:48.524Z"}