From 54cb2b583d401ea4cb04a3e6c0fde3c87b8bb8c2 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Wed, 28 Jun 2023 23:28:54 +0200 Subject: [PATCH] RecyclableCollectionsBenchmarks.GetTestMethod will now throw exception if the method couldn't be found in a given class. --- .../Benchmarks/RecyclableCollections.Benchmarks.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs b/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs index a02e64b..7f05752 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs @@ -69,7 +69,8 @@ namespace Recyclable.Collections.Benchmarks public override RecyclableCollectionsBenchmarkSource DataType { get => base.DataType; set => base.DataType = value; } protected override Action? GetTestMethod(RecyclableCollectionsBenchmarkSource benchmarkType) - => (Action?) GetType().GetMethod($"{benchmarkType}_{TestCase}", BindingFlags.Instance | BindingFlags.Public)?.CreateDelegate(typeof(Action), this) - ?? (Action?)GetType().GetMethod($"{benchmarkType}_AddRangeWhenSourceIs{benchmarkType}", BindingFlags.Instance | BindingFlags.Public)?.CreateDelegate(typeof(Action), this); + => (Action?) GetType().GetMethod($"{benchmarkType}_{TestCase}", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)?.CreateDelegate(typeof(Action), this) + ?? (Action?)GetType().GetMethod($"{benchmarkType}_AddRangeWhenSourceIs{benchmarkType}", BindingFlags.Instance | BindingFlags.Public)?.CreateDelegate(typeof(Action), this) + ?? throw new InvalidOperationException($"Method {benchmarkType}_{TestCase} not found in class {GetType().FullName}"); } }