Add validation warning for sealed
classes containing benchmarks #2516
Closed
Description
It is easy to create benchmarks, for example as shown in README.md:
// attributes here
public class Md5VsSha256
{
// setups and benchmarks here
}
However, if I choose to seal my class, as in:
public sealed class Md5VsSha256
then if I use BenchmarkSwitcher.FromAssemblies(...).Run(...)
to run my benchmarks, then the class is no longer discovered.
Is there any technical reason for this behavior?
It seems that if you go to src/BenchmarkDotNet/Extensions/ReflectionExtensions.cs line 159 and remove the .IsSealed
criterion, then this should work?
In the project I am working in, we prefer to make all types sealed
unless they are specifically designed to be base classes, and this practice improves performance in general, so it is a shame if classes containing benchmarks cannot also be sealed
.