BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Codify and standardize the console message for each Analyzer

Open AnthonyMastrean opened this issue 3 years ago • 3 comments

We established Visual Studio Code tasks to run different groups of benchmarks, but we can't easily access the analyzers printed in the console via the Problems panel. It would be helpful to codify and standardize the console message for each analyzer.

For example, these messages cannot be easily matched:

  Example.One: VeryLongRun    -> The minimum observed iteration time is 1.4000 us which is very small. It's recommended to increase it to at least 100.0000 ms using more operations.

But these can!

.\source\Example.cs(10,10): warning BDN0001: The minimum observed iteration time is very small. [.\source\Example.csproj]

We could use the built-in $msCompile problem matcher (see this Regex101 example). Each codified analyzer could be written up in more detail somewhere on the website, like the other SDK analyzers.

AnthonyMastrean avatar Jul 28 '22 18:07 AnthonyMastrean

Hi @AnthonyMastrean

We could definitely standardize all messages, but I am not sure about the source file reference. At the moment when the warning is produced, we typically don't know the path to the source file and especially the source line number.

adamsitnik avatar Jul 29 '22 08:07 adamsitnik

Ooh, looks like some new .NET 7 tech might come in handy?

Allows you to obtain the line number in the source file at which the method is called.

https://learn.microsoft.com/en-us/dotnet/api/system.runtime.compilerservices.callerlinenumberattribute?view=net-7.0

AnthonyMastrean avatar Oct 20 '22 13:10 AnthonyMastrean

@AnthonyMastrean That has been around since .Net Framework 4.5. But it doesn't help this situation, because that's only useful on the callee side, and we're on the caller side. We would have to somehow obtain the source file/line of the called method from the pdb info, if it's even available.

timcassell avatar Oct 20 '22 20:10 timcassell