{"record":{"id":"ce6bb97834f3da6e","repo":"tui-cs/Terminal.Gui","slug":"0-length-lines-are-not-supported","errorCode":null,"errorMessage":"0 length lines are not supported","messagePattern":"0 length lines are not supported","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"warning","filePath":"Terminal.Gui/Drawing/LineCanvas/StraightLineExtensions.cs","lineNumber":190,"sourceCode":"    /// <summary>\n    ///     <para>\n    ///         Calculates the single digit point where a line ends on the differing axis i.e. the maximum (controlling for\n    ///         negative lengths).\n    ///     </para>\n    ///     <para>\n    ///         For lines with <see cref=\"Orientation.Horizontal\"/> this is an x coordinate. For lines that are\n    ///         <see cref=\"Orientation.Vertical\"/> this is a y coordinate.\n    ///     </para>\n    /// </summary>\n    /// <param name=\"start\">Where the line starts</param>\n    /// <param name=\"length\">Length of the line</param>\n    /// <param name=\"orientation\">Orientation of the line</param>\n    /// <returns>The maximum x or y (whichever is differing) point on the line, controlling for negative lengths. </returns>\n    private static int GetLineEndOnDiffAxis (Point start, int length, Orientation orientation)\n    {\n        if (length == 0)\n        {\n            throw new ArgumentException (@\"0 length lines are not supported\", nameof (length));\n        }\n\n        int sub = length > 0 ? 1 : -1;\n\n        if (orientation == Orientation.Vertical)\n        {\n            // Points on line differ by y\n            return Math.Max (start.Y + length - sub, start.Y);\n        }\n\n        // Points on line differ by x\n        return Math.Max (start.X + length - sub, start.X);\n    }\n\n    /// <summary>\n    ///     <para>\n    ///         Calculates the single digit point where a line starts on the differing axis i.e. the minimum (controlling for\n    ///         negative lengths).","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Drawing/LineCanvas/StraightLineExtensions.cs#L172-L208","documentation":"Thrown by the private helper GetLineEndOnDiffAxis when a line's length is exactly zero. Zero-length lines have no extent on the differing axis, so endpoint computation is undefined. It is an ArgumentException. In normal Exclude flow, zero-length exclusion lines and zero-length collection lines are filtered out before this helper runs, so this guard is effectively an internal invariant that should be unreachable through public API use.","triggerScenarios":"Directly causing a StraightLine with Length == 0 to reach endpoint computation. Under the public Exclude API this is guarded (length==0 returns early; collection lines with Length==0 are skipped), so it indicates either an internal bug or a future caller bypassing the guards.","commonSituations":"Constructing StraightLine instances with Length 0 and passing them into LineCanvas operations that compute endpoints; or a regression in the Exclude guard logic.","solutions":["Do not create StraightLine objects with Length == 0; use Length >= 1 or omit the line.","Filter zero-length lines from your collection before calling LineCanvas/Exclude.","If hit unexpectedly, file a bug: the public API is supposed to guard this."],"exampleFix":"// before\ncanvas.AddLine(new StraightLine(start, 0, Orientation.Horizontal, style));\n\n// after\nif (length > 0)\n    canvas.AddLine(new StraightLine(start, length, Orientation.Horizontal, style));","handlingStrategy":"validation","validationCode":"lines = lines.Where(l => l.Length != 0);","typeGuard":"static bool HasNoZeroLengthLines(IEnumerable<StraightLine> lines) => lines.All(l => l.Length != 0);","tryCatchPattern":null,"preventionTips":["Never add a zero-length StraightLine to a LineCanvas.","Filter zero-length lines out of collections before line operations.","If reached via public API, report it as an internal-invariant bug."],"tags":["linecanvas","drawing","invariant","argument-exception"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}