stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.76k stars 175 forks source link

Buildalyzer warn and CS0518 system.attribute error #2685

Closed tnoiretisa closed 11 months ago

tnoiretisa commented 11 months ago

Describe the bug When i run dotnet stryker on my project we go warn during the build

[10:57:11 WRN] Buildalyzer could not find sourcefiles. This should not happen. Will fallback to filesystem scan. Please report an issue at github.

And error

[10:58:25 ERR] Failed to build the mutated assembly due to unrecoverable error: error CS0518: Le type prédéfini 'System.Attribute' n'est pas défini ou importé

Logs [10:56:49 INF] Identifying project to mutate. [10:57:11 WRN] Buildalyzer could not find sourcefiles. This should not happen. Will fallback to filesystem scan. Please report an issue at github. [10:57:12 INF] Found project myproject.csproj to mutate. [10:57:12 INF] Building test project myproject.Tests.csproj (1/1) [10:58:21 INF] Total number of tests found: 157. [10:58:21 INF] Initial testrun started. [10:58:25 ERR] Failed to build the mutated assembly due to unrecoverable error: error CS0518: Le type prédéfini 'System.Attribute' n'est pas défini ou importé

Expected behavior No warning and build sucess

Desktop (please complete the following information):

Additional context To find the bug, i have used a standalone Buildalyzer to analyse my solutions (very big solution, >100 projects, multiple SNL on root directory etc...). On stryker config, if solution isn't provide i have this message Stryker could not build your project as no solution file was presented. Please pass the solution path to stryker.

Afte my fix, build logs add two additional information on skipping files

[14:16:09 DBG] Skipping auto-generated code file: myproject\obj\Debug\.NETFramework,Version=v4.8.AssemblyAttributes.cs [14:16:09 DBG] Skipping auto-generated code file: myproject\obj\Debug\myproject.AssemblyInfo.cs

I made this PR to fix this https://github.com/stryker-mutator/stryker-net/pull/2683

rouke-broersma commented 11 months ago

I'm not 100% sure but it appears we have a major regression in framework support where we are no longer always using the solution file, which is required for framework. Your fix appears to be the correct fix, we will look into this, thank you.

dupdob commented 11 months ago

integration test works properly for full framework, so it may be subtler than it looks

rouke-broersma commented 11 months ago

integration test works properly for full framework, so it may be subtler than it looks

Yep, that has me stumped.