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

ArgumentNullException when trying to roll back #643

Closed jnyrup closed 5 years ago

jnyrup commented 5 years ago

Describe the bug When Stryker tries to rollback a mutation, but cannot find the AssemblyOriginatorKeyFile for the project, Stryker throws an ArgumentNullException.

I cloned and ran Stryker in Debug mode:

In

RollbackProcess.Start(CSharpCompilation compiler, ImmutableArray<Diagnostic> diagnostics, bool devMode)`
foreach (var diagnostic in diagnostics.Where(x => x.Severity == DiagnosticSeverity.Error))
{
...
}

when the error throws, diagnostic has the following values:

diagnostic = error CS7027: Error signing output with public key from file 'C:\Users\jonas\source\repos\GenericTests\GenericTests\sgKey.snk' -- Could not find file 'C:\Users\jonas\source\repos\GenericTests\GenericTests\sgKey.snk'.
diagnostic.Location = NoLocation
diagnostic.Location.SourceTree = null

Logs From running dotnet stryker

An error occurred during the mutation test run
System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   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 44
   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 107
   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 75
   at Stryker.Core.MutationTest.MutationTestProcess.Mutate(StrykerOptions options) in d:\a\1\s\src\Stryker.Core\Stryker.Core\MutationTest\MutationTestProcess.cs:line 92
   at Stryker.Core.StrykerRunner.RunMutationTest(StrykerOptions options) in d:\a\1\s\src\Stryker.Core\Stryker.Core\StrykerRunner.cs:line 79

log-20190731.txt

Expected behavior Instead of throwing an ArgumentNullException Stryker should stop gracefully. Optionally support projects that uses signing.

Desktop:

Additional context

rouke-broersma commented 5 years ago

We do support projects that use signing. Error handling could be better yes.

jnyrup commented 5 years ago

I forgot to add the example project, where Stryker fails to handle signing using

<AssemblyOriginatorKeyFile>sgKey.snk</AssemblyOriginatorKeyFile>
<SignAssembly>True</SignAssembly>

GenericTests.zip