{"record":{"id":"e57be6b43c252b7c","repo":"spectreconsole/spectre.console","slug":"size-must-be-equal-to-or-greater-than-1","errorCode":null,"errorMessage":"Size must be equal to or greater than 1","messagePattern":"Size must be equal to or greater than 1","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Widgets/Layout/Layout.cs","lineNumber":76,"sourceCode":"            _minimumSize = value;\n        }\n    }\n\n    /// <summary>\n    /// Gets or sets the width.\n    /// </summary>\n    /// <remarks>\n    /// Defaults to <c>null</c>.\n    /// Must be greater than <c>0</c>.\n    /// </remarks>\n    public int? Size\n    {\n        get => _size;\n        set\n        {\n            if (value < 1)\n            {\n                throw new InvalidOperationException(\"Size must be equal to or greater than 1\");\n            }\n\n            _size = value;\n        }\n    }\n\n    /// <summary>\n    /// Gets or sets a value indicating whether or not the layout should\n    /// be visible or not.\n    /// </summary>\n    /// <remarks>Defaults to <c>true</c>.</remarks>\n    public bool IsVisible { get; set; } = true;\n\n    /// <summary>\n    /// Gets the splitter used for this layout.\n    /// </summary>\n    internal LayoutSplitter Splitter => _splitter;\n","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Widgets/Layout/Layout.cs#L58-L94","documentation":"Thrown by the Layout.Size setter when the nullable value, when set, is less than 1. Size fixes an exact rendered width; a non-null value below 1 is invalid (null means auto-size).","triggerScenarios":"Setting Layout.Size to a non-null int that is 0 or negative.","commonSituations":"Assigning 0 to mean 'automatic' (use null instead), or computing a fixed width that underflows to 0 in a narrow terminal.","solutions":["Set Size to null for automatic sizing.","Set Size to a positive integer when a fixed width is required.","Clamp computed sizes with value <= 0 ? null : value."],"exampleFix":"// before\nlayout.Size = computedWidth; // could be 0\n\n// after\nlayout.Size = computedWidth > 0 ? computedWidth : null;","handlingStrategy":"validation","validationCode":"layout.Size = computedWidth > 0 ? computedWidth : null;","typeGuard":"static int? SanitizeSize(int? value) => value.HasValue && value.Value < 1 ? null : value;","tryCatchPattern":null,"preventionTips":["Use null for automatic sizing rather than 0.","Clamp fixed widths derived from terminal measurements."],"tags":["layout","invalid-operation","property-validation","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}