{"record":{"id":"71d3b259f927c61e","repo":"dotnet/wpf","slug":"charkeyframecollection-0","errorCode":null,"errorMessage":"CharKeyFrameCollection[{0}]","messagePattern":"CharKeyFrameCollection\\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/System/Windows/Media/Animation/Generated/CharKeyFrameCollection.cs","lineNumber":466,"sourceCode":"            }\n        }\n\n        /// <summary>\n        /// Gets or sets the CharKeyFrame at a given index.\n        /// </summary>\n        public CharKeyFrame 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, \"CharKeyFrameCollection[{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/CharKeyFrameCollection.cs#L448-L484","documentation":"The indexer setter of CharKeyFrameCollection throws ArgumentNullException (message \"CharKeyFrameCollection[{0}]\") when null is assigned into the collection at an index. Every slot must hold a concrete CharKeyFrame instance.","triggerScenarios":"charKeyFrameCollection[i] = null; or any generated/binding code path inserting a null CharKeyFrame into the collection.","commonSituations":"Unresolved key-frame resources in XAML, or dynamically computed key frames that can evaluate to null.","solutions":["Assign a valid CharKeyFrame (e.g. new DiscreteCharKeyFrame('a', KeyTime.FromTimeSpan(TimeSpan.FromSeconds(1)))) instead of null","Null-check before inserting and skip or substitute a default key frame","Verify XAML resource keys resolve to CharKeyFrame instances"],"exampleFix":"// before\nframes[0] = GetCharKeyFrame(); // may return null\n// after\nvar kf = GetCharKeyFrame();\nframes[0] = kf ?? new DiscreteCharKeyFrame('\\0', KeyTime.FromTimeSpan(TimeSpan.Zero));","handlingStrategy":"validation","validationCode":"if (frame == null) throw new ArgumentException(\"Key frame cannot be null\", nameof(frame));\ncharKeyFrameCollection[index] = frame;","typeGuard":"static bool IsValidKeyFrame(CharKeyFrame f) => f != null;","tryCatchPattern":"try { collection[index] = frame; }\ncatch (ArgumentNullException ex) { /* message names the index; supply a valid CharKeyFrame */ }","preventionTips":["Never assign null into key-frame collections; use typed Add methods","Null-check key frames from factories/resources before insertion","Use collection initializers to catch nulls at authoring time"],"tags":["wpf","animation","argument-null","keyframe-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"}