{"record":{"id":"740f25036cf15dd4","repo":"tui-cs/Terminal.Gui","slug":"steps-must-be-greater-than-0","errorCode":null,"errorMessage":"Steps must be greater than 0.","messagePattern":"Steps must be greater than 0\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Drawing/Gradient.cs","lineNumber":79,"sourceCode":"    {\n        _stops = stops.ToList ();\n\n        if (_stops.Count < 1)\n        {\n            throw new ArgumentException (\"At least one color stop must be provided.\");\n        }\n\n        _steps = steps.ToList ();\n\n        // If multiple colors and only 1 step assume same distance applies to all steps\n        if (_stops.Count > 2 && _steps.Count == 1)\n        {\n            _steps = Enumerable.Repeat (_steps.Single (), _stops.Count () - 1).ToList ();\n        }\n\n        if (_steps.Any (step => step < 1))\n        {\n            throw new ArgumentException (\"Steps must be greater than 0.\");\n        }\n\n        if (_steps.Count != _stops.Count - 1)\n        {\n            throw new ArgumentException (\"Number of steps must be N-1\");\n        }\n\n        _loop = loop;\n        Spectrum = GenerateGradient (_steps);\n    }\n\n    /// <summary>\n    ///     Returns the color to use at the given part of the spectrum\n    /// </summary>\n    /// <param name=\"fraction\">\n    ///     Proportion of the way through the spectrum, must be between\n    ///     0 and 1 (inclusive).  Returns the last color if <paramref name=\"fraction\"/> is\n    ///     <see cref=\"double.NaN\"/>.","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Drawing/Gradient.cs#L61-L97","documentation":"Thrown by the Gradient constructor when any value in the steps collection is less than 1. Steps define how many interpolated colors to generate between adjacent stops, so zero or negative steps are meaningless. It is an ArgumentException. Note a single step value is auto-expanded across all stop pairs when there are more than two stops.","triggerScenarios":"Calling new Gradient(stops, new[] { 0 }), new Gradient(stops, new[] { -1 }), or a steps list where any element is <= 0.","commonSituations":"Computing step counts from sizes/dimensions that can be zero (e.g. width-1 on a 1-cell area), config providing 0, or arithmetic underflow.","solutions":["Clamp each step to at least 1: steps = steps.Select(s => Math.Max(1, s)).","Validate step values before constructing the Gradient.","Ensure the source dimension used to derive steps is >= 2."],"exampleFix":"// before\nvar g = new Gradient(stops, new[] { width - 1 });\n\n// after\nint step = Math.Max(1, width - 1);\nvar g = new Gradient(stops, new[] { step });","handlingStrategy":"validation","validationCode":"steps = steps.Select(s => Math.Max(1, s)).ToList();","typeGuard":"static bool AllStepsPositive(IEnumerable<int> steps) => steps.All(s => s >= 1);","tryCatchPattern":"try { g = new Gradient(stops, steps); } catch (ArgumentException) { g = new Gradient(stops, Enumerable.Repeat(1, stops.Count()-1)); }","preventionTips":["Clamp step counts to a minimum of 1.","Watch for size-derived step values that can be zero on tiny areas.","Validate step values before constructing the Gradient."],"tags":["gradient","drawing","validation","argument-exception"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}