{"record":{"id":"dbd39b753e9ee547","repo":"tui-cs/Terminal.Gui","slug":"value","errorCode":null,"errorMessage":"value","messagePattern":"value","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Views/LinearRange/LinearRangeViewBase.cs","lineNumber":368,"sourceCode":"    protected virtual bool OnLegendsOrientationChanging (ValueChangingEventArgs<Orientation> args) => false;\n\n    /// <summary>Called after <see cref=\"LegendsOrientation\"/> has changed.</summary>\n    protected virtual void OnLegendsOrientationChanged (ValueChangedEventArgs<Orientation> args) { }\n\n    /// <summary>LinearRange styles. <see cref=\"LinearRangeStyle\"></see></summary>\n    public LinearRangeStyle Style { get; set; } = new ();\n\n    /// <summary>\n    ///     Set the linear range options. When the new options no longer contain the previously selected\n    ///     value(s), the selection is dropped (event semantics depend on the concrete subclass).\n    /// </summary>\n    public List<LinearRangeOption<TOption>> Options\n    {\n        get => _options ?? [];\n        set\n        {\n            // _options should never be null\n            _options = value ?? throw new ArgumentNullException (nameof (value));\n\n            // Drop any selected indices that are no longer valid\n            _setOptions.RemoveAll (i => i < 0 || i >= _options.Count);\n\n            if (_options.Count == 0)\n            {\n                return;\n            }\n\n            SetContentSize ();\n        }\n    }\n\n    /// <summary>\n    ///     Internal accessor for whether a range is allowed to collapse to a single option (only meaningful\n    ///     when <see cref=\"RenderMode\"/> is <see cref=\"LinearRangeRenderMode.Span\"/>). Exposed publicly only\n    ///     by <see cref=\"LinearRange{T}\"/>.\n    /// </summary>","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Views/LinearRange/LinearRangeViewBase.cs#L350-L386","documentation":"Thrown by the LinearRangeViewBase.Options setter (message is just the param name 'value' via nameof) when assigning null to the Options list. Although the getter returns an empty list as a fallback, the setter explicitly refuses null to keep the internal _options non-null invariant. The selected indices are then pruned against the new options.","triggerScenarios":"Assigning rangeView.Options = null; or passing a variable that is null (e.g. a list built conditionally that stayed null, or a deserialised collection whose source was absent).","commonSituations":"MVVM/binding where the model collection is initially null; JSON deserialisation with missing-options defaulting to null; refactor that replaced a field initialiser with a nullable property.","solutions":["Assign an empty list instead of null: rangeView.Options = options ?? [];","Ensure the source collection is initialised to a non-null list in its owner before binding.","Initialise the bound property with a default: public List<LinearRangeOption<T>> Options { get; set; } = [];"],"exampleFix":"// before\nrange.Options = maybeOptions; // null when nothing selected\n\n// after\nrange.Options = maybeOptions ?? [];\n// or at the source:\npublic List<LinearRangeOption<T>> Options { get; set; } = [];","handlingStrategy":"validation","validationCode":"range.Options = maybeOptions ?? [];","typeGuard":"static bool HasValidOptions<T>(List<LinearRangeOption<T>>? o) => o is not null;","tryCatchPattern":null,"preventionTips":["Always assign [] instead of null.","Initialise bound collection properties to [] at declaration.","Coerce deserialised null collections to empty before binding."],"tags":["linearrange","nullable","validation","precondition"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}