{"record":{"id":"3dcefe69a932d486","repo":"dotnet/wpf","slug":"colorkeyframecollection-0","errorCode":null,"errorMessage":"ColorKeyFrameCollection[{0}]","messagePattern":"ColorKeyFrameCollection\\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/ColorKeyFrameCollection.cs","lineNumber":466,"sourceCode":"            }\n        }\n\n        /// <summary>\n        /// Gets or sets the ColorKeyFrame at a given index.\n        /// </summary>\n        public ColorKeyFrame this[int index]\n        {\n            get\n            {\n                ReadPreamble();\n\n                return _keyFrames[index];\n            }\n            set\n            {\n                if (value == null)\n                {\n                    throw new ArgumentNullException(String.Format(CultureInfo.InvariantCulture, \"ColorKeyFrameCollection[{0}]\", index));\n                }\n\n                WritePreamble();\n\n                if (value != _keyFrames[index])\n                {\n                    OnFreezablePropertyChanged(_keyFrames[index], value);\n                    _keyFrames[index] = value;\n\n                    Debug.Assert(_keyFrames[index] != null);\n\n                    WritePostscript();\n                }\n            }\n        }\n\n        #endregion\n    }","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/ColorKeyFrameCollection.cs#L448-L484","documentation":"ColorKeyFrameCollection's public indexer setter throws ArgumentNullException when assigning null at a given index. The parameter name is built as \"ColorKeyFrameCollection[{index}]\" so the message points at the offending slot. The collection requires every element to be a non-null ColorKeyFrame.","triggerScenarios":"Executing keyFrames[i] = null on a ColorKeyFrameCollection, or API/XAML paths that end up assigning a null key frame into an existing slot.","commonSituations":"Data-binding a null item into the collection; clearing logic that assigns null instead of removing; deserialization producing null entries.","solutions":["Assign a valid ColorKeyFrame instance instead of null","Use RemoveAt(index) to delete a slot rather than setting null","Validate the key frame for null before the assignment","Fix binding/source data so it never yields null key frames"],"exampleFix":"// before\nkeyFrameCollection[0] = null; // ArgumentNullException\n// after\nif (newFrame != null) keyFrameCollection[0] = newFrame; else keyFrameCollection.RemoveAt(0);","handlingStrategy":"type-guard","validationCode":"if (frame == null) keyFrames.RemoveAt(index); else keyFrames[index] = frame;","typeGuard":"static bool IsValidSlotAssignment(ColorKeyFrame frame) => frame != null;","tryCatchPattern":"try { keyFrames[i] = frame; }\ncatch (ArgumentNullException ex) when (ex.ParamName == $\"ColorKeyFrameCollection[{i}]\") { /* remove slot or supply default frame */ }","preventionTips":["Null-check key frames before indexer assignment","Use RemoveAt instead of assigning null","Validate data-bound collections for null items"],"tags":["wpf","animation","keyframes","null-argument"],"backgroundTag":"null-argument","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-21T21:30:21.729Z"}