{"record":{"id":"f2880f8ff25ccc15","repo":"stride3d/stride","slug":"value-cannot-be-null-parameter-points","errorCode":null,"errorMessage":"Value cannot be null. (Parameter 'points')","messagePattern":"Value cannot be null\\. \\(Parameter 'points'\\)","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/Drawing/CanvasRenderer.cs","lineNumber":109,"sourceCode":"            point.Offset(-size.Width / 2, -size.Height / 2);\n            var rect = new Rect(point, size);\n\n            var ellipse = Create<Ellipse>(isHitTestVisible, rect.Left, rect.Top);\n\n            ellipse.Fill = GetBrush(fillColor);\n            SetStroke(ellipse, strokeColor, thickness, lineJoin, dashArray, dashOffset, false);\n\n            ellipse.Height = rect.Height;\n            ellipse.Width = rect.Width;\n            Canvas.SetLeft(ellipse, rect.Left);\n            Canvas.SetTop(ellipse, rect.Top);\n        }\n\n        /// <inheritdoc/>\n        public void DrawEllipses(IList<Point> points, double radiusX, double radiusY, Color fillColor, Color strokeColor,\n            double thickness, PenLineJoin lineJoin, ICollection<double> dashArray, double dashOffset, bool isHitTestVisible)\n        {\n            if (points == null) throw new ArgumentNullException(nameof(points));\n            if (points.Count == 0)\n                return;\n\n            var fillBrush = GetBrush(fillColor);\n            var strokeBrush = GetBrush(strokeColor);\n            var pen = new Pen(strokeBrush, thickness)\n            {\n                LineJoin = lineJoin,\n                DashStyle = new DashStyle(dashArray, dashOffset),\n            };\n\n            var visual = new DrawingVisual();\n            var context = visual.RenderOpen();\n            foreach (var point in points)\n            {\n                context.DrawEllipse(fillBrush, pen, point, radiusX, radiusY);\n            }\n            context.Close();","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/Drawing/CanvasRenderer.cs#L91-L127","documentation":"CanvasRenderer.DrawEllipses requires a non-null IList<Point> and throws ArgumentNullException(nameof(points)) when null. A null point list has no meaningful ellipse set to draw, so the method fails fast before allocating brushes or geometries. An empty list is explicitly allowed and returns silently.","triggerScenarios":"Calling DrawEllipses with a null points collection — e.g. a data-bound Points property not yet populated, a LINQ query returning null by convention, or passing an uninitialized field instead of an empty collection.","commonSituations":"Drawing layers whose point data loads asynchronously (first render pass has null data); view models exposing nullable point collections; serialization layers that skip empty arrays so deserialized objects have null collections.","solutions":["Initialize point collections to an empty List<Point> instead of leaving them null (empty lists are handled gracefully).","Null-check points at the call site and skip the draw call when null.","Coalesce at the boundary: points ?? Array.Empty<Point>() or points ?? new List<Point>().","If data is asynchronous, render only after the collection is materialized."],"exampleFix":"// before\nrenderer.DrawEllipses(model.Points, ...); // model.Points is null\n// after\nvar pts = model.Points ?? new List<Point>();\nrenderer.DrawEllipses(pts, ...);","handlingStrategy":"validation","validationCode":"var safePoints = points ?? new List<Point>();\nif (safePoints.Count == 0) return; // renderer also no-ops on empty","typeGuard":"static bool HasDrawablePoints(IList<Point> pts) => pts is { Count: > 0 };","tryCatchPattern":"try { renderer.DrawEllipses(points, rx, ry, fill, stroke, thickness, join, dash, offset, hitTest); }\ncatch (ArgumentNullException ex) when (ex.ParamName == \"points\") { log.Warn(\"DrawEllipses skipped: null points\"); }","preventionTips":["Default collection properties to empty lists, never null.","Coalesce null data at the view-model boundary.","For async data, draw only after materialization.","Treat 'no data' as an empty collection in APIs you control."],"tags":["wpf","argument-null","drawing"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}