{"record":{"id":"cc2bf375579dcd81","repo":"dotnet/wpf","slug":"notimplementedexception-liveshapinglist","errorCode":null,"errorMessage":"NotImplementedException","messagePattern":"NotImplementedException","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/LiveShapingList.cs","lineNumber":617,"sourceCode":"        public int GetCopies()\n        {\n            return _root.GetCopies();\n        }\n\n        public double GetAverageCopy()\n        {\n            return _root.GetAverageCopy();\n        }\n\n        int _comparisons;\n\n#endif // LiveShapingInstrumentation\n\n        #region ICollection Members\n\n        public void CopyTo(Array array, int index)\n        {\n            throw new NotImplementedException();\n        }\n\n        public int Count\n        {\n            get { return _root.Count; }\n        }\n\n        public bool IsSynchronized\n        {\n            get { return false; }\n        }\n\n        public object SyncRoot\n        {\n            get { return null; }\n        }\n\n        #endregion","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/LiveShapingList.cs#L599-L635","documentation":"LiveShapingList's explicit ICollection.CopyTo implementation is intentionally unimplemented and always throws NotImplementedException. LiveShapingList is an internal WPF structure backing live-shaping CollectionViews, and array-copy via the ICollection interface is not a supported path.","triggerScenarios":"Calling CopyTo (directly or via ICollection/System.Collections casts, LINQ's CopyTo-based helpers, or ArrayList/Array.Copy patterns) on a LiveShapingList instance obtained through internal CollectionView plumbing.","commonSituations":"Code that reflects into WPF's CollectionView internals (e.g. to dump view contents) and treats the inner live-shaping list as a plain ICollection; custom sorting/paging utilities that enumerate via ICollection.CopyTo.","solutions":["Enumerate the list with IEnumerable (foreach) instead of CopyTo.","Copy the view contents from the public surface instead: use the CollectionView's Items or OfType<object>().ToArray().","If a copy is truly required, build it manually: var arr = list.Cast<object>().ToArray()."],"exampleFix":"// before\n((ICollection)liveShapingList).CopyTo(target, 0); // NotImplementedException\n\n// after\nvar items = liveShapingList.Cast<object>().ToArray();","handlingStrategy":"fallback","validationCode":"// prefer enumeration; ICollection.CopyTo on LiveShapingList is unimplemented\nvar items = list is System.Collections.IEnumerable e ? e.Cast<object>().ToArray() : new object[0];","typeGuard":"static bool SupportsCopyTo(System.Collections.ICollection c) => !(c.GetType().Name == \"LiveShapingList\");","tryCatchPattern":"try { ((System.Collections.ICollection)list).CopyTo(arr, 0); }\ncatch (NotImplementedException) { var items = list.Cast<object>().ToArray(); }","preventionTips":["Enumerate internal WPF collections with IEnumerable, never ICollection.CopyTo.","Copy view contents via the public CollectionView surface.","Avoid reaching into CollectionView internals for data extraction."],"tags":["wpf","collectionview","icollection","notimplemented"],"backgroundTag":"method-not-implemented","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"}