{"record":{"id":"edb57cb82cb718e0","repo":"dotnet/BenchmarkDotNet","slug":"memberinfo-name-of-type-type-name-does-not-imp","errorCode":null,"errorMessage":"{memberInfo.Name} of type {type.Name} does not implement IEnumerable, unable to read values for [ParamsSource]","messagePattern":"(.+?) of type (.+?) does not implement IEnumerable, unable to read values for \\[ParamsSource\\]","errorType":"exception","errorClass":"InvalidBenchmarkDeclarationException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Running/BenchmarkConverter.cs","lineNumber":328,"sourceCode":"                    paramsSourceMethod.Invoke(paramsSourceMethod.IsStatic ? null : Activator.CreateInstance(sourceType), null)!,\n                    paramsSourceMethod,\n                    sourceType));\n\n            var paramsSourceProperty = sourceType.GetAllProperties().FirstOrDefault(property => property.Name == sourceName && property.GetMethod?.IsPublic == true);\n\n            if (paramsSourceProperty == null)\n                throw new InvalidBenchmarkDeclarationException($\"{sourceType.Name} has no public, accessible method/property called {sourceName}, unable to read values for [ParamsSource]\");\n\n            return (paramsSourceProperty, ToArray(\n                paramsSourceProperty.GetValue(paramsSourceProperty.GetMethod!.IsStatic ? null : Activator.CreateInstance(sourceType)!)!,\n                paramsSourceProperty,\n                sourceType));\n        }\n\n        private static object[] ToArray(object sourceValue, MemberInfo memberInfo, Type type)\n        {\n            if (!(sourceValue is IEnumerable collection))\n                throw new InvalidBenchmarkDeclarationException($\"{memberInfo.Name} of type {type.Name} does not implement IEnumerable, unable to read values for [ParamsSource]\");\n\n            return collection.Cast<object>().ToArray();\n        }\n\n        private static object?[] GetAllValidValues(Type parameterType)\n        {\n            if (parameterType == typeof(bool))\n                return [false, true];\n\n            if (parameterType.GetTypeInfo().IsEnum)\n            {\n                if (parameterType.GetTypeInfo().IsDefined(typeof(FlagsAttribute)))\n                    return [Activator.CreateInstance(parameterType)!];\n\n                return Enum.GetValues(parameterType).Cast<object>().ToArray();\n            }\n\n            var nullableUnderlyingType = Nullable.GetUnderlyingType(parameterType);","sourceCodeStart":310,"sourceCodeEnd":346,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Running/BenchmarkConverter.cs#L310-L346","documentation":"Thrown by ToArray when the member referenced by [ParamsSource] returns a value that does not implement IEnumerable. BenchmarkDotNet requires the source to produce a collection of values to enumerate for parameter generation; a non-enumerable return type (e.g., a single int, a custom object) cannot be iterated.","triggerScenarios":"Declaring [ParamsSource(nameof(Source))] where Source is a public property/method returning a non-IEnumerable type, e.g. public int Source => 42 or public MyCustomObject Source => new MyCustomObject().","commonSituations":"Misunderstanding that ParamsSource must return a collection. Accidentally returning a single value. Declaring a property that returns a custom type without implementing IEnumerable.","solutions":["Change the source member to return IEnumerable<T> or IEnumerable<object>, e.g. a list or array.","Wrap a single value in a collection if only one value is needed: new[] { 42 }.","Ensure the return type implements IEnumerable (arrays, List<T>, HashSet<T>, etc.)."],"exampleFix":"// before\npublic int Source => 42;\n[Params]\n[ParamsSource(nameof(Source))]\npublic int Number;\n\n// after\npublic IEnumerable<int> Source => new[] { 42 };\n[Params]\n[ParamsSource(nameof(Source))]\npublic int Number;","handlingStrategy":"validation","validationCode":"var member = typeof(MyBench).GetProperty(nameof(MyBench.Source))?.PropertyType\n    ?? typeof(MyBench).GetMethod(nameof(MyBench.Source))?.ReturnType;\nif (member is null || !typeof(IEnumerable).IsAssignableFrom(member))\n    throw new InvalidOperationException(\"ParamsSource member must return an IEnumerable.\");","typeGuard":"static bool IsEnumerableSource(Type? sourceReturnType) =>\n    sourceReturnType is not null && typeof(IEnumerable).IsAssignableFrom(sourceReturnType);","tryCatchPattern":null,"preventionTips":["Type the ParamsSource member's return type as IEnumerable<T> or T[] for compile-time safety.","Never return a single scalar value from a ParamsSource; always wrap in a collection.","Add a unit test that materializes the source to catch type issues early."],"tags":["benchmark-declaration","params-source","type-mismatch","benchmark-converter"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}