{"record":{"id":"fc7dd88c118ea715","repo":"dotnet/BenchmarkDotNet","slug":"benchmark-benchmark-name-has-invalid-type-of-arg","errorCode":null,"errorMessage":"Benchmark {benchmark.Name} has invalid type of arguments provided by [ArgumentsSource({valuesInfo.source.Name})]. It should be IEnumerable<object[]> or IEnumerable<object>.","messagePattern":"Benchmark (.+?) has invalid type of arguments provided by \\[ArgumentsSource\\((.+?)\\)\\]\\. It should be IEnumerable<object\\[\\]> or IEnumerable<object>\\.","errorType":"validation","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Parameters/SmartParamBuilder.cs","lineNumber":57,"sourceCode":"                        [Create(parameterDefinitions, array[0], valuesInfo.source, sourceIndex, argumentIndex: 0, summaryStyle)]);\n                }\n\n                if (parameterDefinitions.Length > 1)\n                {\n                    if (parameterDefinitions.Length != array.Length)\n                        throw new InvalidOperationException($\"Benchmark {benchmark.Name} has invalid number of arguments provided by [ArgumentsSource({valuesInfo.source.Name})]! {array.Length} instead of {parameterDefinitions.Length}.\");\n\n                    return new ParameterInstances(\n                        array.Select((value, argumentIndex) => Create(parameterDefinitions, value, valuesInfo.source, sourceIndex, argumentIndex, summaryStyle)).ToArray());\n                }\n            }\n\n            if (parameterDefinitions.Length == 1)\n            {\n                return new ParameterInstances([Create(parameterDefinitions, unwrappedValue, valuesInfo.source, sourceIndex, argumentIndex: 0, summaryStyle)]);\n            }\n\n            throw new NotSupportedException($\"Benchmark {benchmark.Name} has invalid type of arguments provided by [ArgumentsSource({valuesInfo.source.Name})]. It should be IEnumerable<object[]> or IEnumerable<object>.\");\n        }\n\n        private static ParameterInstance Create(ParameterDefinition[] parameterDefinitions, object value, MemberInfo source, int sourceIndex, int argumentIndex, SummaryStyle summaryStyle)\n        {\n            if (SourceCodeHelper.IsCompilationTimeConstant(value))\n                return new ParameterInstance(parameterDefinitions[argumentIndex], value, summaryStyle);\n\n            return new ParameterInstance(parameterDefinitions[argumentIndex], new SmartArgument(parameterDefinitions, value, source, sourceIndex, argumentIndex), summaryStyle);\n        }\n    }\n\n    internal class SmartArgument : IParam\n    {\n        private readonly ParameterDefinition[] parameterDefinitions;\n        private readonly MemberInfo source;\n        private readonly int sourceIndex;\n        private readonly int argumentIndex;\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Parameters/SmartParamBuilder.cs#L39-L75","documentation":"Thrown by SmartParamBuilder.CreateForArguments as a fallback NotSupportedException when the value yielded by [ArgumentsSource] is neither an object[] (for multi-parameter benchmarks) nor a single object (for single-parameter benchmarks) that the builder can process. This is the terminal else-branch after all recognized shapes (array for multi-param, single object for one-param) have been checked.","triggerScenarios":"A benchmark method has more than one parameter but [ArgumentsSource] yields individual scalar values (not wrapped in object[]), or yields a type that is neither IEnumerable<object[]> nor IEnumerable<object>. For example, yielding ints from a source for a two-parameter method.","commonSituations":"Misunderstanding the ArgumentsSource contract: for multi-parameter benchmarks the source must yield object[] (one array per test case), not individual values. Also from returning non-enumerable types or nested structures.","solutions":["For multi-parameter benchmarks, change the source to return IEnumerable<object[]> where each object[] has one element per parameter.","For single-parameter benchmarks, ensure the source returns IEnumerable<object> or IEnumerable<T>.","Verify the return type of the source member matches the benchmark parameter count."],"exampleFix":"// before (multi-param benchmark)\npublic IEnumerable<int> Data() => new[] { 1, 2, 3 };\n[Benchmark]\n[ArgumentsSource(nameof(Data))]\npublic void Run(int a, int b) { }\n\n// after\npublic IEnumerable<object[]> Data() => new[]\n{\n    new object[] { 1, 2 },\n    new object[] { 3, 4 },\n};","handlingStrategy":"validation","validationCode":"// For multi-parameter benchmarks, ensure source returns IEnumerable<object[]>\nvar sourceType = typeof(MyBench).GetMethod(nameof(MyBench.Data))!.ReturnType;\nif (paramCount > 1 && !typeof(IEnumerable<object[]>).IsAssignableFrom(sourceType))\n    throw new InvalidOperationException(\"Multi-param benchmarks need IEnumerable<object[]> source.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use IEnumerable<object[]> as the return type signature for multi-parameter ArgumentsSource members to get compile-time safety.","Add a unit test that materializes the source and verifies the type of each element.","Review the ArgumentsSource documentation contract: multi-param => object[], single-param => object or T."],"tags":["benchmark-declaration","arguments-source","not-supported","type-mismatch"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}