{"record":{"id":"3149a39ba3562e7b","repo":"tui-cs/Terminal.Gui","slug":"start-must-be-greater-than-or-equal-to-0","errorCode":null,"errorMessage":"start must be greater than or equal to 0","messagePattern":"start must be greater than or equal to 0","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Drawing/Ruler.cs","lineNumber":32,"sourceCode":"    public int Length { get; set; }\n\n    /// <summary>Gets or sets whether the ruler is drawn horizontally or vertically. The default is horizontally.</summary>\n    public Orientation Orientation { get; set; }\n\n    private string _hTemplate { get; } = \"|123456789\";\n    private string _vTemplate { get; } = \"-123456789\";\n\n    /// <summary>Draws the <see cref=\"Ruler\"/>.</summary>\n    /// <param name=\"driver\">Optional Driver. If not provided, driver will be used.</param>\n    /// <param name=\"location\">The location to start drawing the ruler, in screen-relative coordinates.</param>\n    /// <param name=\"start\">The start value of the ruler.</param>\n    public void Draw (IDriver? driver, Point location, int start = 0)\n    {\n        ArgumentNullException.ThrowIfNull (driver);\n\n        if (start < 0)\n        {\n            throw new ArgumentException (\"start must be greater than or equal to 0\");\n        }\n\n        if (Length < 1)\n        {\n            return;\n        }\n\n        if (Orientation == Orientation.Horizontal)\n        {\n            string hrule =\n                _hTemplate.Repeat ((int)Math.Ceiling (Length + 2 / (double)_hTemplate.Length))! [start..(Length + start)];\n\n            // Top\n            driver?.Move (location.X, location.Y);\n            driver?.AddStr (hrule);\n        }\n        else\n        {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Drawing/Ruler.cs#L14-L50","documentation":"Thrown by Ruler.Draw when the start parameter is negative. The ruler draws from a template substring indexed by start, so a negative index is invalid. It is an ArgumentException. The Ruler class is internal, so this is reached via Terminal.Gui's own rendering helpers rather than directly by application code.","triggerScenarios":"Calling ruler.Draw(driver, location, start: -1) or passing a computed start that underflows below zero.","commonSituations":"Internal callers computing a scroll/offset start that goes negative on small viewports, or negative coordinates from layout arithmetic.","solutions":["Ensure start >= 0 before calling Draw (clamp to 0).","Guard upstream offsets so they never go negative.","Return early when Length < 1 (Draw already does) to avoid drawing with bad offsets."],"exampleFix":"// before\nruler.Draw(driver, location, start: offset);\n\n// after\nruler.Draw(driver, location, start: Math.Max(0, offset));","handlingStrategy":"validation","validationCode":"int s = Math.Max(0, offset);","typeGuard":"static bool IsValidRulerStart(int start) => start >= 0;","tryCatchPattern":"try { ruler.Draw(driver, location, start); } catch (ArgumentException) { ruler.Draw(driver, location, 0); }","preventionTips":["Clamp ruler start to non-negative values.","Guard scroll/offset computations against underflow.","Ruler is internal; ensure any wrapping code validates offsets."],"tags":["ruler","drawing","internal","validation","argument-exception"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}