{"record":{"id":"5a5a50d0b2f52f9e","repo":"dotnet/wpf","slug":"rectkeyframecollection-0","errorCode":null,"errorMessage":"RectKeyFrameCollection[{0}]","messagePattern":"RectKeyFrameCollection\\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/RectKeyFrameCollection.cs","lineNumber":466,"sourceCode":"            }\n        }\n\n        /// <summary>\n        /// Gets or sets the RectKeyFrame at a given index.\n        /// </summary>\n        public RectKeyFrame 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, \"RectKeyFrameCollection[{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/RectKeyFrameCollection.cs#L448-L484","documentation":"RectKeyFrameCollection's this[int] setter throws ArgumentNullException whose (misused) message parameter is the formatted string \"RectKeyFrameCollection[{index}]\" when a null RectKeyFrame is assigned at the given index. The collection forbids null key frames; the formatted string is used as the paramName, identifying the failing index.","triggerScenarios":"Executing collection[index] = null on a RectKeyFrameCollection, e.g. myCollection[0] = null;","commonSituations":"Programmatic collection manipulation where a key frame variable is null (failed lookup/creation) before assignment; generic collection-filling code that doesn't check for null elements.","solutions":["Check for null before assigning: only set collection[index] when the key frame is non-null","Create a valid RectKeyFrame instance instead of assigning null","Use Add() and validate elements before insertion"],"exampleFix":"// before\nkeyFrames[0] = GetKeyFrame(); // may return null\n// after\nvar kf = GetKeyFrame();\nif (kf != null) keyFrames[0] = kf;","handlingStrategy":"type-guard","validationCode":"if (kf == null) throw new InvalidOperationException(\"Cannot assign null key frame at index \" + index); keyFrames[index] = kf;","typeGuard":"bool IsValidKeyFrame(RectKeyFrame kf) => kf != null;","tryCatchPattern":"try { keyFrames[index] = kf; } catch (ArgumentNullException ex) { /* kf was null at ex.ParamName index */ }","preventionTips":["Null-check key frames before indexed assignment","Ensure factory methods never return null key frames","Prefer Add() with validation over direct index sets"],"tags":["wpf","animation","null-argument","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"}