BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

[bug] auto-generated boilerplate Build Error if local solution Source Generator is present

Open Stepami opened this issue 4 weeks ago • 0 comments

Describe the bug

Unable to run benchmark as it fails to build.

BenchmarkDotNet has failed to build the auto-generated boilerplate code.

Error suggests that there is something wrong with referenced source generator.

error CS8032: An instance of analyzer HydraScript.Infrastructure.LexerRegexGenerator.PatternGenerator cannot be created from 

However, the main project builds and runs fine.

To Reproduce Steps to reproduce the behavior:

  1. Clone bug/benchmark-build branch of hydrascript repo: https://github.com/Stepami/hydrascript/tree/bug/benchmark-build
  2. In root project folder run: dotnet run -c Release --project .\benchmarks\HydraScript.Benchmarks\HydraScript.Benchmarks.csproj
  3. See error

Expected behavior Successful benchmark run.

Screenshots/logs

// Validating benchmarks:
// ***** BenchmarkRunner: Start   *****
// ***** Found 2 benchmark(s) in total *****                                                                                                           
// ***** Building 2 exe(s) in Parallel: Start   *****                                                                                                  
// ***** Done, took 00:00:06 (6.38 sec)   *****                                                                                                        
// ***** Failed to build in Parallel, switching to sequential build   *****                                                                            
// ***** Done, took 00:00:10 (10.29 sec)   *****                                                                                                       
// Found 2 benchmarks:                                                                                                                                 
//   InvokeBenchmark.Invoke: .NET 10.0(Runtime=.NET 10.0)                                                                                              
//   InvokeBenchmark.Invoke: NativeAOT 10.0(Runtime=NativeAOT 10.0)                                                                                    
                                                                                                                                                       
Setup power plan (GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c FriendlyName: Высокая производительность)
// Build Error: Standard output:                                                                                                                       
                                                                                                                                                       
 Standard error:                                                                                                                                       
   HydraScript.Domain.Constants -> C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Domain.Constants.dll                                                                                    
  HydraScript.Infrastructure.LexerRegexGenerator -> C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Infrastructure.LexerRegexGenerator.dll                                                 
  HydraScript.Domain.BackEnd -> C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Domain.BackEnd.dll                                                                                         
  HydraScript.Domain.FrontEnd -> C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Domain.FrontEnd.dll                                                                                       
  HydraScript.Application.CodeGeneration -> C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Application.CodeGeneration.dll                                                                 
  HydraScript.Domain.IR -> C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Domain.IR.dll                                                                                                   
  HydraScript.Application.StaticAnalysis -> C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Application.StaticAnalysis.dll                                                                 
CSC : error CS8032: An instance of analyzer HydraScript.Infrastructure.LexerRegexGenerator.PatternGenerator cannot be created from C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Infrastructure.LexerRegexGenerator.dll : System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. [C:\Users\Stepan\RiderProjects\hydrascript\src\Infrastructure\HydraScript.Infrastructure\HydraScript.Infrastructure.csproj]                                           
C:\Program Files\dotnet\sdk\10.0.100\Microsoft.Common.CurrentVersion.targets(2137,5): error MSB4181: The "MSBuild" task returned false but did not log an error. [C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\HydraScript.Benchmarks.csproj]                                  
Build FAILED.                                                                                                                                          
CSC : error CS8032: An instance of analyzer HydraScript.Infrastructure.LexerRegexGenerator.PatternGenerator cannot be created from C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1\bin\Release\net10.0\HydraScript.Infrastructure.LexerRegexGenerator.dll : System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. [C:\Users\Stepan\RiderProjects\hydrascript\src\Infrastructure\HydraScript.Infrastructure\HydraScript.Infrastructure.csproj]                                           
C:\Program Files\dotnet\sdk\10.0.100\Microsoft.Common.CurrentVersion.targets(2137,5): error MSB4181: The "MSBuild" task returned false but did not log an error. [C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\HydraScript.Benchmarks.csproj]                                  
    0 Warning(s)                                                                                                                                       
    2 Error(s)                                                                                                                                         
Time Elapsed 00:00:02.94                                                                                                                               
                                                                                                                                                       
// BenchmarkDotNet has failed to build the auto-generated boilerplate code.
// It can be found in C:\Users\Stepan\RiderProjects\hydrascript\benchmarks\HydraScript.Benchmarks\bin\Release\net10.0\HydraScript.Benchmarks-.NET 10.0-1                                                                                                                                                      
// Please follow the troubleshooting guide: https://benchmarkdotnet.org/articles/guides/troubleshooting.html                                           
                                                                                                                                                       
// ** Remained 0 (0,0 %) benchmark(s) to run. Estimated finish 2025-12-02 14:41 (0h 0m from now) **
Successfully reverted power plan (GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c FriendlyName: Высокая производительность)                                 
// ***** BenchmarkRunner: Finish  *****                                                                                                                
                                                                                                                                                       
// * Export *
  BenchmarkDotNet.Artifacts\results\HydraScript.Benchmarks.InvokeBenchmark-report.csv                                                                  
  BenchmarkDotNet.Artifacts\results\HydraScript.Benchmarks.InvokeBenchmark-report-github.md                                                            
  BenchmarkDotNet.Artifacts\results\HydraScript.Benchmarks.InvokeBenchmark-report.html                                                                 
                                                                                                                                                       
// * Detailed results *
InvokeBenchmark.Invoke: .NET 10.0(Runtime=.NET 10.0)                                                                                                   
Runtime = ; GC =                                                                                                                                       
There are not any results runs                                                                                                                         
                                                                                                                                                       
// * Summary *
                                                                                                                                                       
BenchmarkDotNet v0.15.6, Windows 10 (10.0.19045.6456/22H2/2022Update)
12th Gen Intel Core i7-12650H 2.30GHz, 1 CPU, 16 logical and 10 physical cores                                                                         
.NET SDK 10.0.100                                                                                                                                      
  [Host] : .NET 10.0.0 (10.0.0, 10.0.25.52411), X64 RyuJIT x86-64-v3                                                                                   
                                                                                                                                                       
Job=.NET 10.0  Runtime=.NET 10.0  

| Method | Mean | Error |
|------- |-----:|------:|
| Invoke |   NA |    NA |                                                                                                                              

Benchmarks with issues:
  InvokeBenchmark.Invoke: .NET 10.0(Runtime=.NET 10.0)                                                                                                 
                                                                                                                                                       
// * Legends *
  Mean  : Arithmetic mean of all measurements                                                                                                          
  Error : Half of 99.9% confidence interval                                                                                                            
  1 ns  : 1 Nanosecond (0.000000001 sec)                                                                                                               
                                                                                                                                                       
// * Diagnostic Output - MemoryDiagnoser *
                                                                                                                                                       

// ***** BenchmarkRunner: End *****
Run time: 00:00:00 (0.09 sec), executed benchmarks: 0                                                                                                  
                                                                                                                                                       
Global total time: 00:00:17 (17.38 sec), executed benchmarks: 0
// * Artifacts cleanup *                                                                                                                               
Artifacts cleanup is finished

Desktop (please complete the following information):

  • OS: Windows 10
  • Platform: x64
  • BenchmarkDotNet Version: 0.15.6
  • .NET SDK Version: 10.0.100

Stepami avatar Dec 02 '25 11:12 Stepami