{"record":{"id":"ff879669b14d75dd","repo":"JamesNK/Newtonsoft.Json","slug":"memberinfo-0-has-index-parameters","errorCode":null,"errorMessage":"MemberInfo '{0}' has index parameters","messagePattern":"MemberInfo '(.+?)' has index parameters","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs","lineNumber":546,"sourceCode":"        /// <param name=\"target\">The target object.</param>\n        /// <returns>The member's value on the object.</returns>\n        public static object? GetMemberValue(MemberInfo member, object target)\n        {\n            ValidationUtils.ArgumentNotNull(member, nameof(member));\n            ValidationUtils.ArgumentNotNull(target, nameof(target));\n\n            switch (member.MemberType())\n            {\n                case MemberTypes.Field:\n                    return ((FieldInfo)member).GetValue(target);\n                case MemberTypes.Property:\n                    try\n                    {\n                        return ((PropertyInfo)member).GetValue(target, null);\n                    }\n                    catch (TargetParameterCountException e)\n                    {\n                        throw new ArgumentException(\"MemberInfo '{0}' has index parameters\".FormatWith(CultureInfo.InvariantCulture, member.Name), e);\n                    }\n                default:\n                    throw new ArgumentException(\"MemberInfo '{0}' is not of type FieldInfo or PropertyInfo\".FormatWith(CultureInfo.InvariantCulture, member.Name), nameof(member));\n            }\n        }\n\n        /// <summary>\n        /// Sets the member's value on the target object.\n        /// </summary>\n        /// <param name=\"member\">The member.</param>\n        /// <param name=\"target\">The target.</param>\n        /// <param name=\"value\">The value.</param>\n        public static void SetMemberValue(MemberInfo member, object target, object? value)\n        {\n            ValidationUtils.ArgumentNotNull(member, nameof(member));\n            ValidationUtils.ArgumentNotNull(target, nameof(target));\n\n            switch (member.MemberType())","sourceCodeStart":528,"sourceCodeEnd":564,"githubUrl":"https://github.com/JamesNK/Newtonsoft.Json/blob/4f73e74372445108d2c1bda37b36e6f5e43402e0/Src/Newtonsoft.Json/Utilities/ReflectionUtils.cs#L528-L564","documentation":"Thrown by ReflectionUtils.GetMemberValue when PropertyInfo.GetValue throws TargetParameterCountException because the property requires index parameters (an indexer). It wraps the inner TargetParameterCountException. Indexed properties such as C# `this[int]` cannot be read without supplying an index.","triggerScenarios":"Calling GetMemberValue on a PropertyInfo whose GetIndexParameters().Length > 0 (an indexer). Internally can occur when a serializer or utility walks all properties including indexers.","commonSituations":"Custom serializers iterating PropertyInfo collections that include indexers, types with indexers mistaken for ordinary properties, or dictionary-like wrapper types exposing `this[object]`.","solutions":["Skip indexed properties: check propertyInfo.GetIndexParameters().Length == 0 before reading.","If you must read an indexer, call PropertyInfo.GetValue directly with the index arguments.","Annotate indexers with [JsonIgnore] to exclude them from serialization."],"exampleFix":"// before\nvar value = ReflectionUtils.GetMemberValue(indexerProperty, target);\n\n// after\nif (((PropertyInfo)indexerProperty).GetIndexParameters().Length == 0)\n    var value = ReflectionUtils.GetMemberValue(indexerProperty, target);","handlingStrategy":"validation","validationCode":"if (member is PropertyInfo p && p.GetIndexParameters().Length > 0)\n    throw new ArgumentException($\"{p.Name} is an indexer; use GetValue with index args.\");","typeGuard":"static bool IsIndexer(PropertyInfo p) => p.GetIndexParameters().Length > 0;","tryCatchPattern":null,"preventionTips":["Skip indexed properties when walking PropertyInfos (check GetIndexParameters().Length).","Annotate indexers with [JsonIgnore].","Use PropertyInfo.GetValue directly with index arguments when an indexer must be read."],"tags":["reflection","indexed-property","property","indexer"],"analyzedSha":"4f73e74372445108d2c1bda37b36e6f5e43402e0","analyzedAt":"2026-08-07T06:10:08.596Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}