The following code causes unhandled InvalidOperationException.
[CoreJob]
[RPlotExporter, RankColumn]
[MemoryDiagnoser]
public class BenchClass
{
[Benchmark(Baseline = true)]
public void GetValueIsBaseLine(string param)
{
}
}
As far as I understand the excepted behavior is to print an error message from the InvalidOperationException in a proper way.
Here is a full StackTrace:
Unhandled Exception: System.InvalidOperationException: Benchmark method 'GetValueIsBaseLine' has incorrect signature.
Method shouldn't have any arguments.
at BenchmarkDotNet.Running.BenchmarkConverter.AssertMethodHasCorrectSignature(String methodType, MethodInfo methodInfo)
at BenchmarkDotNet.Running.BenchmarkConverter.CreateDescriptor(Type type, MethodInfo globalSetupMethod, MethodInfo methodInfo, MethodInfo globalCleanupMethod, MethodInfo iterationSetupMethod, MethodInfo iterationCleanupMethod, BenchmarkAttribute attr, MethodInfo[] targetMethods)
at BenchmarkDotNet.Running.BenchmarkConverter.<>c__DisplayClass4_0.<GetTargets>b__1(MethodInfo methodInfo)
at System.Linq.Enumerable.WhereSelectArrayIterator`2.ToArray()
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at BenchmarkDotNet.Running.BenchmarkConverter.MethodsToBenchmarksWithFullConfig(Type containingType, MethodInfo[] benchmarkMethods, ImmutableConfig immutableConfig)
at BenchmarkDotNet.Running.BenchmarkRunner.RunWithDirtyAssemblyResolveHelper(Type type, IConfig config)
at BenchmarkDotNet.Running.BenchmarkRunner.Run[T](IConfig config)
at <namespace>.Program.Main(String[] args)
I think you need to add [Arguments(...)] attribute to this method. There is more information: https://benchmarkdotnet.org/articles/samples/IntroArguments.html
I think you need to add
[Arguments(...)]attribute to this method. There is more information: https://benchmarkdotnet.org/articles/samples/IntroArguments.html
Hi @wojtpl2
Thanks for mentioning the [Arguments(...)] attribute (_I wasn't aware of it_)!
Still I've reported this issue mostly because absence of [Arguments(...)] attribute results in _unhandled exception_ rather than in _application error message_.
If throwing (_and not handling_) the exception is actually the expected behavior then feel free to close this issue as irrelevant.
@OlegKarasik thanks for the report. I will handle this exception and transform it into a nice error message.
Most helpful comment
@OlegKarasik thanks for the report. I will handle this exception and transform it into a nice error message.