{"record":{"id":"ac2f8878079d98fb","repo":"BCUninstaller/Bulk-Crap-Uninstaller","slug":"value-cannot-be-null-or-empty","errorCode":null,"errorMessage":"Value cannot be null or empty","messagePattern":"Value cannot be null or empty","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"source/UninstallTools/Lists/Filter.cs","lineNumber":27,"sourceCode":"using Klocman.Extensions;\r\nusing Klocman.Tools;\r\nusing UninstallTools.Properties;\r\n\r\nnamespace UninstallTools.Lists\r\n{\r\n    public class Filter : ITestEntry\r\n    {\r\n        public Filter()\r\n        {\r\n        }\r\n\r\n        public Filter(string name, string filterText)\r\n        {\r\n            if (!string.IsNullOrEmpty(name))\r\n                Name = name;\r\n\r\n            if (string.IsNullOrEmpty(filterText))\r\n                throw new ArgumentException(Localisation.UninstallListItem_ValueEmpty, nameof(filterText));\r\n\r\n            if (filterText.ContainsAny(StringTools.NewLineChars, StringComparison.Ordinal))\r\n                throw new ArgumentException(Localisation.UninstallListItem_NewLineInValue, nameof(filterText));\r\n\r\n            ComparisonEntries.Add(new FilterCondition { FilterText = filterText });\r\n        }\r\n\r\n        public Filter(string name, bool exclude, params FilterCondition[] conditions)\r\n        {\r\n            if (!string.IsNullOrEmpty(name))\r\n                Name = name;\r\n            Exclude = exclude;\r\n            ComparisonEntries.AddRange(conditions);\r\n        }\r\n\r\n        public string Name { get; set; } = Localisation.UninstallListEditor_NewFilter;\r\n\r\n        /// <summary>\r","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/BCUninstaller/Bulk-Crap-Uninstaller/blob/608321de98e92297377b1eb69029af55c25504a1/source/UninstallTools/Lists/Filter.cs#L9-L45","documentation":"The Filter(string name, string filterText) constructor validates filterText with string.IsNullOrEmpty and throws ArgumentException (param 'filterText') if it is null or empty. A Filter is a single match rule inside an UninstallList; an empty filter text would match nothing or everything ambiguously, so the constructor rejects it upfront.","triggerScenarios":"Constructing a Filter via 'new Filter(name, filterText)' where filterText is null, string.Empty, or whitespace-only that the caller did not pre-trim. Common when deserialising user-edited XML where a <Filter> element has no text, or when wiring up a filter textbox without validating input.","commonSituations":"A user saves an uninstall list with a blank filter row; loading it and reconstructing Filter objects throws. Also programmatic creation from a config field that defaults to empty.","solutions":["Validate and trim filterText before constructing the Filter; show a validation error to the user if blank.","When loading from XML, skip Filter elements whose text is null/empty rather than passing them to the constructor.","Unit-test the filter-input path with null, empty, and whitespace-only inputs."],"exampleFix":"// before\nvar filter = new Filter(name, filterText);\n\n// after\nif (string.IsNullOrWhiteSpace(filterText))\n    throw new InvalidOperationException(\"Filter text required for filter '\" + name + \"'.\");\nvar filter = new Filter(name, filterText.Trim());","handlingStrategy":"validation","validationCode":"string text = filterText ?? string.Empty;\ntext = text.Trim();\nif (string.IsNullOrEmpty(text))\n    throw new InvalidOperationException(\"Filter text is required.\");\nvar filter = new Filter(name, text);","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Validate and trim filter text at the UI boundary before constructing Filter.","Skip blank <Filter> elements when loading an UninstallList XML.","Unit-test the filter-input path with null, empty, and whitespace inputs."],"tags":["validation","argument-exception","filters","uninstall-list","constructor"],"backgroundTag":null,"analyzedSha":"608321de98e92297377b1eb69029af55c25504a1","analyzedAt":"2026-08-13T12:17:35.389Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}