{"record":{"id":"a3bf6c139205144b","repo":"dotnet/BenchmarkDotNet","slug":"sourcetype-name-has-no-public-accessible-method","errorCode":null,"errorMessage":"{sourceType.Name} has no public, accessible method/property called {sourceName}, unable to read values for [ParamsSource]","messagePattern":"(.+?) has no public, accessible method/property called (.+?), unable to read values for \\[ParamsSource\\]","errorType":"exception","errorClass":"InvalidBenchmarkDeclarationException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet/Running/BenchmarkConverter.cs","lineNumber":317,"sourceCode":"                return EnumParam.FromObject(providedValue, type);\n            }\n            return providedValue;\n        }\n\n        private static (MemberInfo source, object[] values) GetValidValuesForParamsSource(Type sourceType, string sourceName)\n        {\n            var paramsSourceMethod = sourceType.GetAllMethods().FirstOrDefault(method => method.Name == sourceName && method.IsPublic);\n\n            if (paramsSourceMethod != default)\n                return (paramsSourceMethod, ToArray(\n                    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))","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet/Running/BenchmarkConverter.cs#L299-L335","documentation":"Thrown by GetValidValuesForParamsSource when the type containing [ParamsSource] does not have a public method or property with the name specified in the attribute. The method searches both GetAllMethods() and GetAllProperties() for a member matching the sourceName with public visibility; if neither is found, it throws InvalidBenchmarkDeclarationException.","triggerScenarios":"Declaring [ParamsSource(nameof(MyValues))] on a field/property but the actual member 'MyValues' is misspelled, is a field (not a method/property), is non-public, or does not exist on the declaring type.","commonSituations":"Renaming the source member but forgetting to update the [ParamsSource] attribute string (or forgetting to use nameof). Declaring the source as a field instead of a property. Making the source method/property private or internal.","solutions":["Use nameof() to reference the source member: [ParamsSource(nameof(MyValues))] instead of a hardcoded string.","Ensure the source member is a public property or public method (not a field).","Verify the member name exactly matches between the attribute and the declaration."],"exampleFix":"// before\npublic IEnumerable<int> Values => new[] { 1, 2, 3 };\n[Params]\n[ParamsSource(\"MyValues\")] // typo: should be \"Values\"\npublic int Number;\n\n// after\npublic IEnumerable<int> Values => new[] { 1, 2, 3 };\n[Params]\n[ParamsSource(nameof(Values))]\npublic int Number;","handlingStrategy":"validation","validationCode":"string sourceName = nameof(MyValues); // compile-time safe\nvar member = typeof(MyBench).GetMember(sourceName, BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static)\n    .FirstOrDefault(m => m is MethodInfo or PropertyInfo);\nif (member is null)\n    throw new InvalidOperationException($\"No public method/property '{sourceName}' found.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always use nameof(MemberName) in [ParamsSource] attributes, not hardcoded strings.","Ensure the source member is a public property or method (not a field).","Run a quick smoke test that resolves the ParamsSource member by name before the full benchmark suite."],"tags":["benchmark-declaration","params-source","reflection","benchmark-converter"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}