{"record":{"id":"fb6dc428194e57c6","repo":"dotnet/wpf","slug":"objectkeyframecollection-0","errorCode":null,"errorMessage":"ObjectKeyFrameCollection[{0}]","messagePattern":"ObjectKeyFrameCollection\\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/ObjectKeyFrameCollection.cs","lineNumber":466,"sourceCode":"            }\n        }\n\n        /// <summary>\n        /// Gets or sets the ObjectKeyFrame at a given index.\n        /// </summary>\n        public ObjectKeyFrame 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, \"ObjectKeyFrameCollection[{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/ObjectKeyFrameCollection.cs#L448-L484","documentation":"The ObjectKeyFrameCollection indexer setter throws ArgumentNullException when a null key frame is assigned. The paramName is the formatted string \"ObjectKeyFrameCollection[index]\" identifying the collection position.","triggerScenarios":"Executing collection[index] = null on an ObjectKeyFrameCollection.","commonSituations":"Data-driven animation setups where frames may be null; replacing frames by index in code.","solutions":["Null-check before assigning into the collection","Add only non-null ObjectKeyFrame instances","Remove the frame (RemoveAt) rather than assigning null"],"exampleFix":"// before\nframes[1] = null; // to clear\n// after\nframes.RemoveAt(1);","handlingStrategy":"validation","validationCode":"if (frame == null) throw new ArgumentException($\"ObjectKeyFrameCollection[{index}] requires a non-null frame\");\ncollection[index] = frame;","typeGuard":"bool IsValidFrame(ObjectKeyFrame f) => f != null;","tryCatchPattern":"try { collection[index] = frame; }\ncatch (ArgumentNullException ex) when (ex.ParamName?.StartsWith(\"ObjectKeyFrameCollection[\") == true) { /* assign a valid frame or remove the slot */ }","preventionTips":["Null-check frames before index assignment","Remove frames with RemoveAt instead of assigning null","Sanitize frame lists loaded from external data"],"tags":["wpf","animation","null","collection"],"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"}