-
Notifications
You must be signed in to change notification settings - Fork 222
Stryker 4.10.0 AddOpenAPI issue: One or more errors occurred. (Internal error due to compile error.) #3397
Description
Describe the bug
I am using the latest 4.10.0 version and I get the error:
[12:09:19 WRN] An unidentified mutation in Microsoft.AspNetCore.OpenApi.SourceGenerators\Microsoft.AspNetCore.OpenApi.SourceGenerators.XmlCommentGenerator\OpenApiXmlCommentSupport.generated.cs resulted in a compile error (at 596:1) with id: CS9137, message: The 'interceptors' feature is not enabled in this namespace. Add '<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces>' to your project. (Source code: global::System.Runtime.CompilerServices.InterceptsLocationAttribute)
[12:09:19 INF] Safe Mode! Stryker will remove all mutations in AddOpenApi and mark them as 'compile error'.
[12:09:19 FTL] Stryker.NET could not compile the project after mutation. This is probably an error for Stryker.NET and not your project. Please report this issue on github with the previous error message.
[12:09:19 ERR] An error occurred during the mutation test run
System.AggregateException: One or more errors occurred. (Internal error due to compile error.)
---> Stryker.Abstractions.Exceptions.CompilationException: Internal error due to compile error.
I removed the AddOpenAPI() call from Program.cs and it seems it is mutating the project now. The problem is similar to #3379 but I do not have the Failed to load analyzer 'Microsoft.CodeAnalysis.Razor.Compiler warning.
Logs
Version: 4.10.0
[12:07:38 INF] Analysis starting.
[12:07:38 INF] Identifying projects to mutate in C:\Users\user\Documents\Projects\SalaProject\SalaProject.sln. This can take a while.
[12:07:43 INF] Could not find a valid analysis for target net10.0 for project 'C:\Users\user\Documents\Projects\SalaProject\SalaProject.GUI.Tests\SalaProject.Tests.csproj'. Selected version is net10.0-windows10.0.19041.0.
[12:07:49 INF] Could not find an assembly reference to a mutable assembly for project C:\Users\user\Documents\Projects\SalaProject\SalaProject.GUI.Tests\SalaProject.Tests.csproj. Will look into project references.
[12:07:49 INF] Could not find an assembly reference to a mutable assembly for project C:\Users\user\Documents\Projects\SalaProject\Workers.Tests\Workers.Tests.csproj. Will look into project references.
[12:07:49 INF] Found project C:\Users\user\Documents\Projects\SalaProject\SalaProject.API\SalaProject.API.csproj to mutate.
[12:07:49 INF] Analysis complete.
[12:07:49 INF] Building solution SalaProject.sln
[12:07:49 INF] Building project SalaProject.sln using dotnet build SalaProject.sln (directory C:\Users\user\Documents\Projects\SalaProject.)
[12:08:08 INF] Number of tests found: 38 for project C:\Users\user\Documents\Projects\SalaProject\SalaProject.API\SalaProject.API.csproj. Initial test run started.
[12:09:19 WRN] An unidentified mutation in Microsoft.AspNetCore.OpenApi.SourceGenerators\Microsoft.AspNetCore.OpenApi.SourceGenerators.XmlCommentGenerator\OpenApiXmlCommentSupport.generated.cs resulted in a compile error (at 596:1) with id: CS9137, message: The 'interceptors' feature is not enabled in this namespace. Add '<InterceptorsNamespaces>$(InterceptorsNamespaces);Microsoft.AspNetCore.OpenApi.Generated</InterceptorsNamespaces>' to your project. (Source code: global::System.Runtime.CompilerServices.InterceptsLocationAttribute)
[12:09:19 INF] Safe Mode! Stryker will remove all mutations in AddOpenApi and mark them as 'compile error'.
[12:09:19 FTL] Stryker.NET could not compile the project after mutation. This is probably an error for Stryker.NET and not your project. Please report this issue on github with the previous error message.
[12:09:19 ERR] An error occurred during the mutation test run
System.AggregateException: One or more errors occurred. (Internal error due to compile error.)
---> Stryker.Abstractions.Exceptions.CompilationException: Internal error due to compile error.
at Stryker.Core.Compiling.CSharpRollbackProcess.Start(CSharpCompilation compiler, ImmutableArray`1 diagnostics, Boolean lastAttempt, Boolean devMode) in /_/src/Stryker.Core/Stryker.Core/Compiling/CSharpRollbackProcess.cs:line 75
at Stryker.Core.Compiling.CsharpCompilingProcess.TryCompilation(Stream ms, Stream symbolStream, CSharpCompilation& compilation, EmitResult previousEmitResult, Boolean lastAttempt, Int32 retryCount) in /_/src/Stryker.Core/Stryker.Core/Compiling/CsharpCompilingProcess.cs:line 185
at Stryker.Core.Compiling.CsharpCompilingProcess.Compile(IEnumerable`1 syntaxTrees, Stream ilStream, Stream symbolStream) in /_/src/Stryker.Core/Stryker.Core/Compiling/CsharpCompilingProcess.cs:line 82
at Stryker.Core.MutationTest.CsharpMutationProcess.CompileMutations(MutationTestInput input, CsharpCompilingProcess compilingProcess) in /_/src/Stryker.Core/Stryker.Core/MutationTest/CsharpMutationProcess.cs:line 72
at Stryker.Core.MutationTest.CsharpMutationProcess.Mutate(MutationTestInput input, IStrykerOptions options) in /_/src/Stryker.Core/Stryker.Core/MutationTest/CsharpMutationProcess.cs:line 62
at Stryker.Core.MutationTest.MutationTestProcess.Mutate() in /_/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs:line 65
at Stryker.Core.Initialisation.ProjectMutator.MutateProject(IStrykerOptions options, MutationTestInput input, IReporter reporters) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectMutator.cs:line 43
at Stryker.Core.Initialisation.ProjectOrchestrator.<>c__DisplayClass8_0.<MutateProjects>b__0(MutationTestInput mutationTestInput) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 76
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(IStrykerOptions options, IReporter reporters, ITestRunner runner) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 74
at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs) in /_/src/Stryker.Core/Stryker.Core/StrykerRunner.cs:line 59
[12:09:19 INF] Time Elapsed 00:01:41.2097493
Unhandled exception. System.AggregateException: One or more errors occurred. (Internal error due to compile error.)
---> Stryker.Abstractions.Exceptions.CompilationException: Internal error due to compile error.
at Stryker.Core.Compiling.CSharpRollbackProcess.Start(CSharpCompilation compiler, ImmutableArray`1 diagnostics, Boolean lastAttempt, Boolean devMode) in /_/src/Stryker.Core/Stryker.Core/Compiling/CSharpRollbackProcess.cs:line 75
at Stryker.Core.Compiling.CsharpCompilingProcess.TryCompilation(Stream ms, Stream symbolStream, CSharpCompilation& compilation, EmitResult previousEmitResult, Boolean lastAttempt, Int32 retryCount) in /_/src/Stryker.Core/Stryker.Core/Compiling/CsharpCompilingProcess.cs:line 185
at Stryker.Core.Compiling.CsharpCompilingProcess.Compile(IEnumerable`1 syntaxTrees, Stream ilStream, Stream symbolStream) in /_/src/Stryker.Core/Stryker.Core/Compiling/CsharpCompilingProcess.cs:line 82
at Stryker.Core.MutationTest.CsharpMutationProcess.CompileMutations(MutationTestInput input, CsharpCompilingProcess compilingProcess) in /_/src/Stryker.Core/Stryker.Core/MutationTest/CsharpMutationProcess.cs:line 72
at Stryker.Core.MutationTest.CsharpMutationProcess.Mutate(MutationTestInput input, IStrykerOptions options) in /_/src/Stryker.Core/Stryker.Core/MutationTest/CsharpMutationProcess.cs:line 62
at Stryker.Core.MutationTest.MutationTestProcess.Mutate() in /_/src/Stryker.Core/Stryker.Core/MutationTest/MutationTestProcess.cs:line 65
at Stryker.Core.Initialisation.ProjectMutator.MutateProject(IStrykerOptions options, MutationTestInput input, IReporter reporters) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectMutator.cs:line 43
at Stryker.Core.Initialisation.ProjectOrchestrator.<>c__DisplayClass8_0.<MutateProjects>b__0(MutationTestInput mutationTestInput) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 76
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2.<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica.Execute()
--- End of inner exception stack trace ---
at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.ForWorker[TLocal,TInt](TInt fromInclusive, TInt toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Action`1 body)
at Stryker.Core.Initialisation.ProjectOrchestrator.MutateProjects(IStrykerOptions options, IReporter reporters, ITestRunner runner) in /_/src/Stryker.Core/Stryker.Core/Initialisation/ProjectOrchestrator.cs:line 74
at Stryker.Core.StrykerRunner.RunMutationTest(IStrykerInputs inputs) in /_/src/Stryker.Core/Stryker.Core/StrykerRunner.cs:line 59
at Stryker.CLI.StrykerCli.RunStryker(IStrykerInputs inputs) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 153
at Stryker.CLI.StrykerCli.<>c__DisplayClass11_0.<Run>b__0() in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 125
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.<>c__DisplayClass143_0.<OnExecute>b__0(CancellationToken _)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at Stryker.CLI.StrykerCli.Run(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/StrykerCLI.cs:line 131
at Stryker.CLI.Program.Main(String[] args) in /_/src/Stryker.CLI/Stryker.CLI/Program.cs:line 26
Expected behavior
The command should not fail, it should compile and mutate the project.
Desktop (please complete the following information):
- OS: Windows 10
- Type of project: ASP.Net
- Framework Version: NET Core 10
- Stryker Version: 4.10.0
Additional context
My test project also uses TestContainers which opens containers like postgresql, etc. However I don't think this be a problem.
I did not try yet the suggested InterceptorsNamespaces fix from the log because I didn't want to modify the main project so the tests run. I will have to look into what this attribute does to the csproj.