{"record":{"id":"4c43679a878ef7b2","repo":"HandyOrg/HandyControl","slug":"argumentoutofrangeexception","errorCode":null,"errorMessage":"ArgumentOutOfRangeException","messagePattern":"ArgumentOutOfRangeException","errorType":"exception","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs","lineNumber":114,"sourceCode":"                        Brush = new SolidColorBrush(backColor),\n                        Geometry = new RectangleGeometry(new Rect(0, 0, 8, 8))\n                    },\n                    new GeometryDrawing\n                    {\n                        Brush = new SolidColorBrush(foreColor),\n                        Geometry = foreGeometryGroup\n                    }\n                }\n            }\n        };\n        RenderOptions.SetCachingHint(drawingBrush, CachingHint.Cache);\n\n        return drawingBrush;\n    }\n\n    private byte[] GetHatchData(HatchStyle hatchStyle) =>\n        hatchStyle < HatchStyle.Horizontal || hatchStyle > HatchStyle.SolidDiamond\n            ? throw new ArgumentOutOfRangeException(nameof(hatchStyle))\n            : HatchBrushes[(int) hatchStyle];\n}\n","sourceCodeStart":96,"sourceCodeEnd":117,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs#L96-L117","documentation":"Validation guard in GetHatchData: the HatchStyle value passed in (or computed upstream and fed into the hatch-pattern lookup) falls outside the supported hatch-style range, so the array indexer throws when selecting the pattern data. The real fault lies in the caller supplying an undefined/out-of-range style — the sentinel exception marks an invalid enum input rather than a rendering failure.","triggerScenarios":"Thrown at src/Shared/HandyControl_Shared/Tools/Generator/HatchBrushGenerator.cs:114 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate hatchStyle with Enum.IsDefined(typeof(HatchStyle), value) (plus range check for non-flags values) before calling GetHatchData, falling back to a default style like Solid","Clamp the style: 'hatchStyle = (HatchStyle)Math.Clamp((int)hatchStyle, (int)HatchStyle.Min, (int)HatchStyle.Max);' before indexing the pattern array","Return null (or a default pattern) from GetHatchData for unsupported styles and let the caller render a plain brush instead of crashing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}