@@ -16,14 +16,15 @@ namespace BenchmarkDotNet.Running
1616{
1717 public static partial class BenchmarkConverter
1818 {
19+ private const BindingFlags AllMethodsFlags = BindingFlags . Static | BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ;
20+
1921 public static BenchmarkRunInfo TypeToBenchmarks ( Type type , IConfig config = null )
2022 {
2123 if ( type . IsGenericTypeDefinition )
2224 throw new ArgumentException ( $ "{ type . Name } is generic type definition, use BenchmarkSwitcher for it") ; // for "open generic types" should be used BenchmarkSwitcher
2325
2426 // We should check all methods including private to notify users about private methods with the [Benchmark] attribute
25- var bindingFlags = BindingFlags . Static | BindingFlags . Instance | BindingFlags . Public | BindingFlags . NonPublic ;
26- var benchmarkMethods = GetOrderedBenchmarkMethods ( type . GetMethods ( bindingFlags ) ) ;
27+ var benchmarkMethods = GetOrderedBenchmarkMethods ( type . GetMethods ( AllMethodsFlags ) ) ;
2728
2829 return MethodsToBenchmarksWithFullConfig ( type , benchmarkMethods , config ) ;
2930 }
@@ -42,13 +43,13 @@ private static MethodInfo[] GetOrderedBenchmarkMethods(MethodInfo[] methods)
4243
4344 private static BenchmarkRunInfo MethodsToBenchmarksWithFullConfig ( Type type , MethodInfo [ ] benchmarkMethods , IConfig config )
4445 {
45- var allPublicMethods = type . GetMethods ( ) ; // benchmarkMethods can be filtered, without Setups, look #564
46+ var allMethods = type . GetMethods ( AllMethodsFlags ) ; // benchmarkMethods can be filtered, without Setups, look #564
4647 var configPerType = GetFullTypeConfig ( type , config ) ;
4748
48- var globalSetupMethods = GetAttributedMethods < GlobalSetupAttribute > ( allPublicMethods , "GlobalSetup" ) ;
49- var globalCleanupMethods = GetAttributedMethods < GlobalCleanupAttribute > ( allPublicMethods , "GlobalCleanup" ) ;
50- var iterationSetupMethods = GetAttributedMethods < IterationSetupAttribute > ( allPublicMethods , "IterationSetup" ) ;
51- var iterationCleanupMethods = GetAttributedMethods < IterationCleanupAttribute > ( allPublicMethods , "IterationCleanup" ) ;
49+ var globalSetupMethods = GetAttributedMethods < GlobalSetupAttribute > ( allMethods , "GlobalSetup" ) ;
50+ var globalCleanupMethods = GetAttributedMethods < GlobalCleanupAttribute > ( allMethods , "GlobalCleanup" ) ;
51+ var iterationSetupMethods = GetAttributedMethods < IterationSetupAttribute > ( allMethods , "IterationSetup" ) ;
52+ var iterationCleanupMethods = GetAttributedMethods < IterationCleanupAttribute > ( allMethods , "IterationCleanup" ) ;
5253
5354 var targets = GetTargets ( benchmarkMethods , type , globalSetupMethods , globalCleanupMethods , iterationSetupMethods , iterationCleanupMethods ) . ToArray ( ) ;
5455
@@ -135,8 +136,8 @@ private static Tuple<MethodInfo, TargetedAttribute>[] GetAttributedMethods<T>(Me
135136 return methods . SelectMany ( m => m . GetCustomAttributes < T > ( )
136137 . Select ( attr =>
137138 {
138- AssertMethodHasCorrectSignature ( methodName , m ) ;
139139 AssertMethodIsAccessible ( methodName , m ) ;
140+ AssertMethodHasCorrectSignature ( methodName , m ) ;
140141 AssertMethodIsNotGeneric ( methodName , m ) ;
141142
142143 return new Tuple < MethodInfo , TargetedAttribute > ( m , attr ) ;
0 commit comments