{"record":{"id":"ffc76867120b4de4","repo":"dotnet/wpf","slug":"notimplementedexception-indexerpropertyinfo","errorCode":null,"errorMessage":"NotImplementedException","messagePattern":"NotImplementedException","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/IndexerPropertyInfo.cs","lineNumber":77,"sourceCode":"        public override MethodInfo GetSetMethod(bool nonPublic)\n        {\n            return null;\n        }\n\n        public override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, System.Globalization.CultureInfo culture)\n        {\n            // This is the only interesting line.  GetValue returns the base object itself.\n            return obj;\n        }\n\n        public override Type PropertyType\n        {\n            get { return typeof(Object); }\n        }\n\n        public override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, System.Globalization.CultureInfo culture)\n        {\n            throw new NotImplementedException();\n        }\n\n        public override Type DeclaringType\n        {\n            get { throw new NotImplementedException(); }\n        }\n\n        public override object[] GetCustomAttributes(Type attributeType, bool inherit)\n        {\n            throw new NotImplementedException();\n        }\n\n        public override object[] GetCustomAttributes(bool inherit)\n        {\n            throw new NotImplementedException();\n        }\n\n        public override bool IsDefined(Type attributeType, bool inherit)","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/IndexerPropertyInfo.cs#L59-L95","documentation":"IndexerPropertyInfo is an internal PropertyInfo wrapper used by WPF data binding to represent an indexer; SetValue is deliberately unsupported and always throws NotImplementedException. Values are written through binding-internal paths (DynamicIndexerAccessor), not through reflection SetValue.","triggerScenarios":"Any code calling SetValue on the IndexerPropertyInfo instance obtained via TypeDescriptor/reflection from ItemProperties — e.g. generic reflection-based serialization, property-grid code, or test code trying to assign to an indexer via this PropertyInfo.","commonSituations":"Using a reflection utility or ORM-ish code that enumerates ItemProperties of a bound item and attempts to write every property including the indexer.","solutions":["Do not use this PropertyInfo for writes; set indexer values directly on the object: obj[key] = value.","Filter out indexer properties before bulk-writing: skip PropertyInfo objects that are IndexerPropertyInfo or have IndexParameters.Length > 0.","If generic reflection is needed, detect the type via the internal MS.Internal.Data.IndexerPropertyInfo type name and handle indexers specially."],"exampleFix":"// before\nprop.SetValue(item, newValue, null); // NotImplementedException for indexer\n\n// after\nif (prop.GetIndexParameters().Length == 0) prop.SetValue(item, newValue, null);","handlingStrategy":"validation","validationCode":"bool isWritable = prop != null && prop.GetIndexParameters().Length == 0;","typeGuard":"static bool IsRealProperty(System.Reflection.PropertyInfo p) => p.GetIndexParameters().Length == 0;","tryCatchPattern":"try { prop.SetValue(item, value, null); }\ncatch (NotImplementedException) { /* indexer write unsupported; set via obj[key] = value */ }","preventionTips":["Check GetIndexParameters().Length before using a PropertyInfo for read/write.","Skip WPF's synthetic indexer (IndexerPropertyInfo) in generic reflection loops.","Write indexer values directly through the object's this[] operator instead of reflection."],"tags":["wpf","reflection","propertyinfo","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"}