{"record":{"id":"4793a1d5a16a3e13","repo":"dotnet/BenchmarkDotNet","slug":"methodtype-method-methodinfo-name-has-incorrec","errorCode":null,"errorMessage":"{methodType} method {methodInfo.Name} has incorrect signature.\\nMethod shouldn't have any arguments.","messagePattern":"(.+?) method (.+?) has incorrect signature\\.\\\\nMethod shouldn't have any arguments\\.","errorType":"exception","errorClass":"InvalidBenchmarkDeclarationException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Running/BenchmarkConverter.cs","lineNumber":264,"sourceCode":"\n            if (!benchmark.HasAttribute<ArgumentsSourceAttribute>())\n                yield break;\n\n            var argumentsSourceAttribute = benchmark.GetCustomAttribute<ArgumentsSourceAttribute>()!;\n            var targetType = argumentsSourceAttribute.Type ?? benchmarkType;\n\n            var valuesInfo = GetValidValuesForParamsSource(targetType, argumentsSourceAttribute.Name);\n            for (int sourceIndex = 0; sourceIndex < valuesInfo.values.Length; sourceIndex++)\n                yield return SmartParamBuilder.CreateForArguments(benchmark, parameterDefinitions, valuesInfo, sourceIndex, summaryStyle);\n        }\n\n        private static ImmutableArray<BenchmarkCase> GetFilteredBenchmarks(IEnumerable<BenchmarkCase> benchmarks, IEnumerable<IFilter> filters)\n            => benchmarks.Where(benchmark => filters.All(filter => filter.Predicate(benchmark))).ToImmutableArray();\n\n        private static void AssertMethodHasCorrectSignature(string methodType, MethodInfo methodInfo)\n        {\n            if (methodInfo.GetParameters().Any() && !methodInfo.HasAttribute<ArgumentsAttribute>() && !methodInfo.HasAttribute<ArgumentsSourceAttribute>())\n                throw new InvalidBenchmarkDeclarationException($\"{methodType} method {methodInfo.Name} has incorrect signature.\\nMethod shouldn't have any arguments.\");\n        }\n\n        private static void AssertMethodIsAccessible(string methodType, MethodInfo methodInfo)\n        {\n            if (!methodInfo.IsPublic)\n                throw new InvalidBenchmarkDeclarationException($\"{methodType} method {methodInfo.Name} has incorrect access modifiers.\\nMethod must be public.\");\n            /* Moved the code that verifies if DeclaringType of a given MethodInfo (a method) is publicly accessible to CompilationValidator */\n        }\n\n        private static void AssertMethodIsNotGeneric(string methodType, MethodInfo methodInfo)\n        {\n            if (methodInfo.IsGenericMethod)\n                throw new InvalidBenchmarkDeclarationException($\"{methodType} method {methodInfo.Name} is generic.\\nGeneric {methodType} methods are not supported.\");\n        }\n\n        private static object?[] GetValidValues(object?[] values, Type parameterType)\n            => values.Select(value => Map(value, parameterType)).ToArray();\n","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Running/BenchmarkConverter.cs#L246-L282","documentation":"Thrown by AssertMethodHasCorrectSignature when a benchmark method (or a related lifecycle method like GlobalSetup/GlobalCleanup) declares parameters but does not have [Arguments] or [ArgumentsSource] attributes. BenchmarkDotNet requires parameterless signatures unless argument-providing attributes are present. The check is: GetParameters().Any() && !HasAttribute<ArgumentsAttribute>() && !HasAttribute<ArgumentsSourceAttribute>().","triggerScenarios":"Declaring [Benchmark] public void Run(int x) without adding [Arguments] or [ArgumentsSource]. Also applies to [GlobalSetup], [GlobalCleanup], [IterationSetup], etc. methods that erroneously take parameters.","commonSituations":"Writing a benchmark method that accidentally takes a parameter (e.g., refactored from a test). Declaring a GlobalSetup method with parameters (which is not supported). Forgetting to add [ArgumentsSource] when parameterizing.","solutions":["Remove parameters from the method signature if argument injection is not intended.","Add [Arguments(...)] or [ArgumentsSource(nameof(Source))] to the method if parameters are intentional.","For [GlobalSetup]/[GlobalCleanup], ensure they are parameterless."],"exampleFix":"// before\n[Benchmark]\npublic void Run(int size) { /* ... */ }\n\n// after\n[Benchmark]\n[Arguments(100)]\npublic void Run(int size) { /* ... */ }","handlingStrategy":"validation","validationCode":"var method = typeof(MyBench).GetMethod(nameof(MyBench.Run))!;\nif (method.GetParameters().Any() &&\n    !method.IsDefined(typeof(ArgumentsAttribute), false) &&\n    !method.IsDefined(typeof(ArgumentsSourceAttribute), false))\n    throw new InvalidOperationException(\"Method has parameters but no [Arguments]/[ArgumentsSource].\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure [Benchmark] methods are parameterless unless using [Arguments] or [ArgumentsSource].","Keep [GlobalSetup], [GlobalCleanup], [IterationSetup], [IterationCleanup] parameterless.","Run a quick validation pass over benchmark types before executing the suite."],"tags":["benchmark-declaration","method-signature","benchmark-converter"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}