{"record":{"id":"d0f833a927203e2d","repo":"HandyOrg/HandyControl","slug":"doublekeyframecollection-0","errorCode":null,"errorMessage":"DoubleKeyFrameCollection[{0}]","messagePattern":"DoubleKeyFrameCollection\\[(.+?)\\]","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"warning","filePath":"src/Shared/HandyControl_Shared/Media/Animation/GeometryKeyFrameCollection.cs","lineNumber":288,"sourceCode":"    object IList.this[int index]\n    {\n        get => this[index];\n        set => this[index] = (GeometryKeyFrame) value;\n    }\n\n    public GeometryKeyFrame 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, \"DoubleKeyFrameCollection[{0}]\", index));\n            }\n\n            WritePreamble();\n\n            if (value != _keyFrames[index])\n            {\n                OnFreezablePropertyChanged(_keyFrames[index], value);\n                _keyFrames[index] = value;\n\n                WritePostscript();\n            }\n        }\n    }\n\n    public bool IsReadOnly\n    {\n        get\n        {","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/HandyControl_Shared/Media/Animation/GeometryKeyFrameCollection.cs#L270-L306","documentation":"The GeometryKeyFrameCollection indexer setter rejects null values but incorrectly throws ArgumentNullException with a formatted message string (\"DoubleKeyFrameCollection[{index}]\") instead of (paramName, message). The exception occurs before WritePreamble, so the collection state is unchanged; the odd parameter usage is a copy-paste from WPF's DoubleKeyFrameCollection.","triggerScenarios":"Assigning null into the collection: keyFrames[i] = null; on a GeometryKeyFrameCollection used by GeometryAnimationUsingKeyFrames.","commonSituations":"Dynamically rebuilding key frames in code where a slot is cleared with null; generic collection-filling code that assigns null placeholders.","solutions":["Do not assign null to collection slots; remove unwanted frames with Remove/RemoveAt instead.","Replace a frame by constructing a valid GeometryKeyFrame instance rather than nulling the index.","Clear the whole collection with Clear() and re-add frames if many need replacing."],"exampleFix":"// before\nkeyFrames[0] = null;\n// after\nkeyFrames.RemoveAt(0); // or keyFrames[0] = new GeometryKeyFrame { Value = ... };","handlingStrategy":"validation","validationCode":"if (value != null)\n    keyFrames[index] = value;\nelse\n    keyFrames.RemoveAt(index);","typeGuard":"static bool IsValidKeyFrame(HandyControl.Media.Animation.GeometryKeyFrame frame) => frame != null;","tryCatchPattern":"try { keyFrames[i] = frame; } catch (ArgumentNullException) { // frame was null; remove the slot instead\n    keyFrames.RemoveAt(i); }","preventionTips":["Never assign null into GeometryKeyFrameCollection; use Remove/RemoveAt to drop frames.","Filter null frames out before populating the collection from dynamic data.","Use Clear() plus re-add for bulk replacement instead of nulling slots."],"tags":["collection","null","indexer","keyframe"],"backgroundTag":"null-argument","analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}