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

Failed to mutate Nullable generic type #716

Closed lg2de closed 4 years ago

lg2de commented 4 years ago

Describe the bug After #557 has been fixed I tried again with my project using .NET Core 3 preview.

I found new issue on a nullable type. According to the error message the type should have a type constraint.

But, all usages of TResult in the mentioned file have a specific constraint:

where TResult : class, TActionReturnBase

As you can see, TResult is constrainted to class AND TActionReturnBase. TActionReturnBase itself is the generic parameter of the class, which does NOT have a constraint.

Actual behavior

   _____ _              _               _   _ ______ _______
  / ____| |            | |             | \ | |  ____|__   __|
 | (___ | |_ _ __ _   _| | _____ _ __  |  \| | |__     | |
  \___ \| __| '__| | | | |/ / _ \ '__| | . ` |  __|    | |
  ____) | |_| |  | |_| |   <  __/ |    | |\  | |____   | |
 |_____/ \__|_|   \__, |_|\_\___|_| (_)|_| \_|______|  |_|
                   __/ |
                  |___/

Version: 0.13.0 (beta)

[13:42:40 INF] The project [...]\AIS.TC.Common\AIS.TC.Common.csproj will be mutated
[13:42:42 INF] Started initial build using dotnet build
[13:42:50 INF] Initial build successful
[13:43:06 INF] Using testrunner VsTest
[13:43:06 INF] Total number of tests found: 576
[13:43:06 INF] Initial testrun started
[13:43:11 INF] Using 12870 ms as testrun timeout
[13:43:18 WRN] Stryker.NET encountered an compile error in [...]\AIS.TC.Common\DependencyInjection\TypeResolver.cs with message: Ein Nullable-Typparameter muss als Werttyp oder als Nicht-Nullable-Verweistyp bekannt sein. Sie sollten eine class-, struct- oder eine Typeinschränkung hinzufügen. (Source code: TResult?)
[13:43:18 WRN] Safe Mode! Stryker will try to continue by rolling back all mutations in method. This should not happen, please report this as an issue on github with the previous error message.
[13:43:18 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.
[13:43:18 ERR] An error occurred during the mutation test run
System.ApplicationException: Internal error due to compile error.
   at Stryker.Core.Compiling.RollbackProcess.RemoveMutantIfStatements(SyntaxTree originalTree, ICollection`1 diagnosticInfo, Boolean devMode) in d:\a\1\s\src\Stryker.Core\Stryker.Core\Compiling\RollbackProcess.cs:line 190
   at Stryker.Core.Compiling.RollbackProcess.Start(CSharpCompilation compiler, ImmutableArray`1 diagnostics, Boolean devMode) in d:\a\1\s\src\Stryker.Core\Stryker.Core\Compiling\RollbackProcess.cs:line 60
   at Stryker.Core.Compiling.CompilingProcess.TryCompilation(MemoryStream ms, CSharpCompilation compilation, EmitResult previousEmitResult, Boolean devMode, Int32 retryCount) in d:\a\1\s\src\Stryker.Core\Stryker.Core\Compiling\CompilingProcess.cs:line 115
   at Stryker.Core.Compiling.CompilingProcess.Compile(IEnumerable`1 syntaxTrees, MemoryStream ms, Boolean devMode) in d:\a\1\s\src\Stryker.Core\Stryker.Core\Compiling\CompilingProcess.cs:line 83
   at Stryker.Core.MutationTest.MutationTestProcess.Mutate() in d:\a\1\s\src\Stryker.Core\Stryker.Core\MutationTest\MutationTestProcess.cs:line 113
   at Stryker.Core.StrykerRunner.RunMutationTest(StrykerOptions options, IEnumerable`1 initialLogMessages) in d:\a\1\s\src\Stryker.Core\Stryker.Core\StrykerRunner.cs:line 86
[13:43:18 INF] Time Elapsed 00:00:40.9025722

Desktop (please complete the following information):

richardwerkman commented 4 years ago

Thanks for letting us know about this issue. Could you provide an actual reproduction scenario? Like the piece of code that makes stryker crash?

lg2de commented 4 years ago

StrykerTest.zip