Description
I am trying to use the code below using BenchmarkDotNet. Whenever I use a #if block in my benchmarks, I get errors like the one below.
#if !NETFRAMEWORK
[Benchmark(Description = "LOOPING: for() & Span")]
[BenchmarkCategory(Categories.New, Categories.GenericCollections, Categories.Span)]
public void TestFor04()
{
var collection = new System.Span<PersonFixed>(personFixedCollection.ToArray());
for (int count = 0; count < collection.Length; count++)
{
ProcessPerson(collection[count]);
}
}
#endif
Standard error:
Time Elapsed 00:00:06.01
2 Error(s)
0 Warning(s)
c3bcb847-7512-47e8-b975-1bd66eb19257.notcs(4005,17): error CS0103: The name 'TestFor04' does not exist in the current context [C:\src\Books\RockYourCode\CodePerformance\src\OutputBin\netcoreapp3.0\c3bcb847-7512-47e8-b975-1bd66eb19257\BenchmarkDotNet.Autogenerated.csproj]
c3bcb847-7512-47e8-b975-1bd66eb19257.notcs(3431,32): error CS0103: The name 'TestFor04' does not exist in the current context [C:\src\Books\RockYourCode\CodePerformance\src\OutputBin\netcoreapp3.0\c3bcb847-7512-47e8-b975-1bd66eb19257\BenchmarkDotNet.Autogenerated.csproj]
Build FAILED.
c3bcb847-7512-47e8-b975-1bd66eb19257.notcs(4005,17): error CS0103: The name 'TestFor04' does not exist in the current context [C:\src\Books\RockYourCode\CodePerformance\src\OutputBin\netcoreapp3.0\c3bcb847-7512-47e8-b975-1bd66eb19257\BenchmarkDotNet.Autogenerated.csproj]
c3bcb847-7512-47e8-b975-1bd66eb19257.notcs(3431,32): error CS0103: The name 'TestFor04' does not exist in the current context [C:\src\Books\RockYourCode\CodePerformance\src\OutputBin\netcoreapp3.0\c3bcb847-7512-47e8-b975-1bd66eb19257\BenchmarkDotNet.Autogenerated.csproj]