{"record":{"id":"d42d2d590206efeb","repo":"dotnet/wpf","slug":"collectionisfixedsize-thousandthofemrealpoints","errorCode":null,"errorMessage":"CollectionIsFixedSize","messagePattern":"CollectionIsFixedSize","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/ThousandthOfEmRealPoints.cs","lineNumber":164,"sourceCode":"        }\n\n        public IEnumerator<Point> GetEnumerator()\n        {\n            for (int i = 0; i < Count; i++)\n            {\n                yield return this[i];\n            }\n        }        \n\n\tSystem.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()\n        {\n            return ((IEnumerable<Point>)this).GetEnumerator();\n        }\n\n        public void Add(Point value)\n        {\n            // not supported, same as Point[] \n            throw new NotSupportedException(SR.CollectionIsFixedSize);                           \n        }\n\n        public void Insert(int index, Point item)\n        {\n            // not supported, same as Point[] \n            throw new NotSupportedException(SR.CollectionIsFixedSize);                           \n        }\n\n        public bool Remove(Point item)\n        {\n            // not supported, same as Point[]             \n            throw new NotSupportedException(SR.CollectionIsFixedSize);                           \n        }\n\n        public void RemoveAt(int index)\n        {\n            // not supported, same as Point[]             \n            throw new NotSupportedException(SR.CollectionIsFixedSize);                           ","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationCore/MS/internal/TextFormatting/ThousandthOfEmRealPoints.cs#L146-L182","documentation":"ThousandthOfEmRealPoints models an immutable, fixed-size point collection (like Point[]), so Add is explicitly unsupported and always throws NotSupportedException with SR.CollectionIsFixedSize. The collection is populated internally during text formatting, never by callers.","triggerScenarios":"Calling Add(Point) on a ThousandthOfEmRealPoints instance, typically through the ICollection<Point> or IList<Point> interface in generic code.","commonSituations":"Generic algorithms that call ICollection<T>.Add when building collections, or LINQ-style bulk-fill code that assumes any ICollection is mutable.","solutions":["Do not mutate the collection; treat it as read-only and read values via CopyTo, indexer, or enumeration.","Copy the points into your own List<Point> and modify that instead.","If you need a different point set, construct a new collection/arrangement rather than appending."],"exampleFix":"// before\ncollection.Add(new Point(x, y));\n// after\nvar mutable = new List<Point>(collection);\nmutable.Add(new Point(x, y));","handlingStrategy":"fallback","validationCode":"if (collection.IsReadOnly) throw new InvalidOperationException(\"Collection is read-only; copy to a mutable list first.\");","typeGuard":"// .NET\ncollection is ICollection<Point> c && !c.IsReadOnly","tryCatchPattern":"try { collection.Add(p); }\ncatch (NotSupportedException) { var list = new List<Point>(collection); list.Add(p); useList(list); }","preventionTips":["Treat ThousandthOfEmRealPoints as immutable output of text formatting.","Check ICollection<T>.IsReadOnly before mutating through the interface.","Copy into List<Point> whenever modification is needed."],"tags":["not-supported-exception","fixed-size-collection","read-only","wpf"],"backgroundTag":"unsupported-operation","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"}