{"record":{"id":"356ea698322e8383","repo":"AvaloniaUI/Avalonia","slug":"glyphrun","errorCode":null,"errorMessage":"glyphRun","messagePattern":"glyphRun","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/ImmediateDrawingContext.cs","lineNumber":190,"sourceCode":"                return;\n            }\n\n            var originX = center.X - radiusX;\n            var originY = center.Y - radiusY;\n            var width = radiusX * 2;\n            var height = radiusY * 2;\n\n            PlatformImpl.DrawEllipse(brush, pen, new Rect(originX, originY, width, height));\n        }\n\n        /// <summary>\n        /// Draws a glyph run.\n        /// </summary>\n        /// <param name=\"foreground\">The foreground brush.</param>\n        /// <param name=\"glyphRun\">The glyph run.</param>\n        public void DrawGlyphRun(IImmutableBrush foreground, IImmutableGlyphRunReference glyphRun)\n        {\n            _ = glyphRun ?? throw new ArgumentNullException(nameof(glyphRun));\n            if (glyphRun.GlyphRun != null)\n                PlatformImpl.DrawGlyphRun(foreground, glyphRun.GlyphRun.Item);\n        }\n\n        /// <summary>\n        /// Draws a filled rectangle.\n        /// </summary>\n        /// <param name=\"brush\">The brush.</param>\n        /// <param name=\"rect\">The rectangle bounds.</param>\n        /// <param name=\"cornerRadius\">The corner radius.</param>\n        public void FillRectangle(IImmutableBrush brush, Rect rect, float cornerRadius = 0.0f)\n        {\n            DrawRectangle(brush, null, rect, cornerRadius, cornerRadius);\n        }\n\n        public readonly record struct PushedState : IDisposable\n        {\n            private readonly int _level;","sourceCodeStart":172,"sourceCodeEnd":208,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/ImmediateDrawingContext.cs#L172-L208","documentation":"DrawGlyphRun throws ArgumentNullException(nameof(glyphRun)) when the IImmutableGlyphRunReference is null. The context dereferences glyphRun.GlyphRun, so a null reference is rejected up front.","triggerScenarios":"Calling context.DrawGlyphRun(foreground, null) — e.g. a text rendering path that produced no glyph run or passed a reference before it was built.","commonSituations":"Custom text controls drawing before the glyph run is computed; formatted text with no characters yielding null; partial initialization of a GlyphRunReference.","solutions":["Null-check the glyph run before drawing.","Skip the draw call when the text run is empty.","Ensure GlyphRun objects are built before being wrapped as references."],"exampleFix":"// before\ncontext.DrawGlyphRun(foreground, glyphRunRef); // may be null\n\n// after\nif (glyphRunRef is not null)\n    context.DrawGlyphRun(foreground, glyphRunRef);","handlingStrategy":"validation","validationCode":"if (glyphRun is null) return;\ncontext.DrawGlyphRun(foreground, glyphRun);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check glyph runs before drawing.","Skip drawing for empty text runs.","Build GlyphRun instances before wrapping them as references."],"tags":["rendering","drawingcontext","text","argumentnull"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}