dotnet / BenchmarkDotNet

Powerful .NET library for benchmarking
https://benchmarkdotnet.org
MIT License
10.47k stars 962 forks source link

CS0119 thrown when benchmark named _.System() #2543

Open mflibby opened 6 months ago

mflibby commented 6 months ago

This is a problem that I have resolved, but I want to make this info available in case others run into a similar problem. Consider the following extract from the benchmarking I have written:

type InsertBenchmark() =
    [<ParamsSource(nameof(InsertBenchmark.DataValues))>]
    member public _.Data 
        ...
    ...
    [<Benchmark(Baseline = true)>]
    member _.System() = 
        ...

(see Form>Performance for a full example)

About a month ago, this benchmark ran fine. I ran it again this week without any substantive changes and it threw CS0119 (the library I'm benchmarking is undergoing a major revision change, so the code in the respective benchmarks changed, but the "System" benchmark did not change at all, as it tests the tools available in the System libraries).

Error Details:

 error CS0119: 'InsertBenchmark.System()' is a method, which is not valid in the given context

Changing from System to anything else eliminated the error, so I don't think this warrants a change/addition to the library, but if there is a way to catch benchmarks that are named System and warn the user (or whatever else if there is a different root cause I am not seeing here).

Potentially related issues/PRs: #832, #754