{"record":{"id":"c67d0b45fea1875d","repo":"AvaloniaUI/Avalonia","slug":"source","errorCode":null,"errorMessage":"source","messagePattern":"source","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Media/ImmediateDrawingContext.cs","lineNumber":77,"sourceCode":"        public Matrix CurrentTransform\n        {\n            get { return _currentTransform; }\n            private set\n            {\n                _currentTransform = value;\n                var transform = _currentTransform * _currentContainerTransform;\n                PlatformImpl.Transform = transform;\n            }\n        }\n\n        /// <summary>\n        /// Draws an bitmap.\n        /// </summary>\n        /// <param name=\"source\">The bitmap.</param>\n        /// <param name=\"rect\">The rect in the output to draw to.</param>\n        public void DrawBitmap(Bitmap source, Rect rect)\n        {\n            _ = source ?? throw new ArgumentNullException(nameof(source));\n            DrawBitmap(source, new Rect(source.Size), rect);\n        }\n\n        /// <summary>\n        /// Draws an image.\n        /// </summary>\n        /// <param name=\"source\">The bitmap.</param>\n        /// <param name=\"sourceRect\">The rect in the image to draw.</param>\n        /// <param name=\"destRect\">The rect in the output to draw to.</param>\n        public void DrawBitmap(Bitmap source, Rect sourceRect, Rect destRect)\n        {\n            _ = source ?? throw new ArgumentNullException(nameof(source));\n            PlatformImpl.DrawBitmap(source.PlatformImpl.Item, 1, sourceRect, destRect);\n        }\n\n        /// <summary>\n        /// Draws a line.\n        /// </summary>","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Media/ImmediateDrawingContext.cs#L59-L95","documentation":"DrawBitmap(Bitmap source, Rect rect) throws ArgumentNullException(nameof(source)) when source is null. The drawing context requires a concrete Bitmap to blit.","triggerScenarios":"Calling drawingContext.DrawBitmap(null, rect) — e.g. when a bound image source is null or a field has not been initialized before render.","commonSituations":"Rendering in an OnRender override before the image is loaded; a null ImageBrush/source bound at runtime; a race where the source is cleared during a draw.","solutions":["Null-check the bitmap before calling DrawBitmap.","Ensure the image source is loaded/assigned before the render pass.","Provide a fallback placeholder bitmap."],"exampleFix":"// before\ncontext.DrawBitmap(_image, rect); // _image may be null\n\n// after\nif (_image is not null)\n    context.DrawBitmap(_image, rect);","handlingStrategy":"validation","validationCode":"if (source is null) return;\ncontext.DrawBitmap(source, rect);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check bitmaps before drawing.","Initialize image sources before the render pass.","Provide a placeholder bitmap for missing assets."],"tags":["rendering","drawingcontext","argumentnull","bitmaps"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}