{"record":{"id":"f5e30572a8510acb","repo":"dotnet/wpf","slug":"matrixkeyframecollection-0","errorCode":null,"errorMessage":"MatrixKeyFrameCollection[{0}]","messagePattern":"MatrixKeyFrameCollection\\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/MatrixKeyFrameCollection.cs","lineNumber":466,"sourceCode":"            }\n        }\n\n        /// <summary>\n        /// Gets or sets the MatrixKeyFrame at a given index.\n        /// </summary>\n        public MatrixKeyFrame 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, \"MatrixKeyFrameCollection[{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/MatrixKeyFrameCollection.cs#L448-L484","documentation":"The MatrixKeyFrameCollection indexer setter throws ArgumentNullException when a null key frame is assigned. The exception's message ( paramName) is the formatted string \"MatrixKeyFrameCollection[index]\", identifying the collection position rather than a parameter name.","triggerScenarios":"Executing collection[index] = null on a MatrixKeyFrameCollection.","commonSituations":"Building key-frame animations from data where individual frames may be null; reflection or designer code assigning frames by index.","solutions":["Guard the value for null before assigning into the collection","Only add non-null MatrixKeyFrame instances (use Add, which also validates)","If a slot must be 'empty', remove the frame instead of assigning null"],"exampleFix":"// before\nkeyFrames[0] = GetFrameMaybeNull();\n// after\nvar frame = GetFrameMaybeNull();\nif (frame == null) throw new InvalidOperationException(\"frame required\");\nkeyFrames[0] = frame;","handlingStrategy":"validation","validationCode":"if (frame == null) throw new ArgumentException($\"MatrixKeyFrameCollection[{index}] requires a non-null frame\");\ncollection[index] = frame;","typeGuard":"bool IsValidFrame(MatrixKeyFrame f) => f != null;","tryCatchPattern":"try { collection[index] = frame; }\ncatch (ArgumentNullException ex) when (ex.ParamName?.StartsWith(\"MatrixKeyFrameCollection[\") == true) { /* supply a valid frame or remove the slot */ }","preventionTips":["Null-check frames before any collection assignment","Prefer Add over indexer assignment for new frames","Filter nulls out of data-driven frame lists"],"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-22T01:17:13.364Z"}