{"record":{"id":"e90902aa67c18f5b","repo":"dotnet/BenchmarkDotNet","slug":"benchmark-benchmark-name-has-invalid-number-of-d","errorCode":null,"errorMessage":"Benchmark {benchmark.Name} has invalid number of defined arguments provided with [Arguments]! {argumentsAttribute.Values.Length} instead of {parameterDefinitions.Length}.","messagePattern":"Benchmark (.+?) has invalid number of defined arguments provided with \\[Arguments\\]! (.+?) instead of (.+?)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Running/BenchmarkConverter.cs","lineNumber":233,"sourceCode":"        private static IEnumerable<ParameterInstances> GetArgumentsDefinitions(MethodInfo benchmark, Type benchmarkType, SummaryStyle summaryStyle)\n        {\n            var argumentsAttributes = benchmark.GetCustomAttributes<PriorityAttribute>();\n            int priority = argumentsAttributes.Select(attribute => attribute.Priority).Sum();\n\n            var parameterDefinitions = benchmark.GetParameters()\n                .Select(parameter => new ParameterDefinition(parameter.Name!, false, [], true, parameter.ParameterType, priority))\n                .ToArray();\n\n            if (parameterDefinitions.IsEmpty())\n            {\n                yield return new ParameterInstances([]);\n                yield break;\n            }\n\n            foreach (var argumentsAttribute in benchmark.GetCustomAttributes<ArgumentsAttribute>())\n            {\n                if (parameterDefinitions.Length != argumentsAttribute.Values.Length)\n                    throw new InvalidOperationException($\"Benchmark {benchmark.Name} has invalid number of defined arguments provided with [Arguments]! {argumentsAttribute.Values.Length} instead of {parameterDefinitions.Length}.\");\n\n                yield return new ParameterInstances(\n                    argumentsAttribute\n                        .Values\n                        .Select((value, index) =>\n                            {\n                                var definition = parameterDefinitions[index];\n                                var type = definition.ParameterType;\n                                return new ParameterInstance(definition, Map(value, type), summaryStyle);\n                            })\n                        .ToArray());\n            }\n\n            if (!benchmark.HasAttribute<ArgumentsSourceAttribute>())\n                yield break;\n\n            var argumentsSourceAttribute = benchmark.GetCustomAttribute<ArgumentsSourceAttribute>()!;\n            var targetType = argumentsSourceAttribute.Type ?? benchmarkType;","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Running/BenchmarkConverter.cs#L215-L251","documentation":"Thrown during benchmark case generation when a [Arguments] attribute on a benchmark method provides a number of values that does not match the method's parameter count. The check `parameterDefinitions.Length != argumentsAttribute.Values.Length` ensures every [Arguments] row has exactly one value per declared parameter.","triggerScenarios":"Declaring [Benchmark] void Run(int a, string b) with [Arguments(1)] or [Arguments(1, \"x\", 2.0)] — any count other than exactly 2 values triggers the exception during conversion.","commonSituations":"Adding or removing a parameter from a benchmark method but forgetting to update the [Arguments] attributes. Using multiple [Arguments] rows where some have the wrong count. Miscounting positional arguments in the attribute.","solutions":["Count the benchmark method parameters and ensure each [Arguments(...)] provides exactly that many values in positional order.","Use [ArgumentsSource] instead for large or dynamic parameter sets.","After changing a method signature, audit all [Arguments] attributes on that method."],"exampleFix":"// before\n[Benchmark]\n[Arguments(1)]\npublic void Run(int a, int b) { }\n\n// after\n[Benchmark]\n[Arguments(1, 2)]\npublic void Run(int a, int b) { }","handlingStrategy":"validation","validationCode":"int paramCount = benchmarkMethod.GetParameters().Length;\nforeach (var attr in benchmarkMethod.GetCustomAttributes<ArgumentsAttribute>())\n    if (attr.Values.Length != paramCount)\n        throw new InvalidOperationException($\"[Arguments] has {attr.Values.Length} values, expected {paramCount}.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write a unit test that verifies every [Arguments] row count matches the method parameter count.","When changing a benchmark method signature, audit all [Arguments] attributes on that method.","Consider [ArgumentsSource] for dynamic or large parameter sets to reduce manual counting errors."],"tags":["benchmark-declaration","arguments","parameter-mismatch","invalid-operation"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}