stryker-net: Compilation fails when using compile-time logging

Describe the bug When using the .NET’s compile-time logging feature, Stryker fails with the following exception:

[13:52:24 WRN] Stryker.NET encountered a compile error in C:\Users\MyUser\Documents\Development\GitHub\ScreenshotCreator\src\ScreenshotCreator.Logic\Log.cs (at 49:31) with mess
age: Partial method 'Log.InvalidDimensions(ILogger, int, int, int, int)' must have an implementation part because it has accessibility modifiers. (Source code: [LoggerMessage(EventId = 6,
                      EventName = Prefix + nameof(InvalidDimensions),
                      Level = LogLevel.Warning,
                      Message =
                          "The image's dimensions are invalid. Width: {currentWidth} (expected {expectedWidth}); Height: {currentHeight} (expected {expectedHeight})")]        
    public static partial void InvalidDimensions(this ILogger logger, int currentWidth, int expectedWidth, int currentHeight, int expectedHeight);)
[13:52:24 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:52:24 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:52:24 INF] Time Elapsed 00:07:46.2735169
Unhandled exception.

Internal error due to compile error.

To reproduce the issue, you can use this feature branch: https://github.com/mu88/ScreenshotCreator/tree/feature/mutation-testing

Logs log-20230812.txt

Expected behavior Stryker support compile-time logging rather than failing.

Desktop (please complete the following information):

  • OS: Windows 11 21H2 (OS build 22000.2176)
  • Type of project: .NET (previously called “Core”)
  • Framework Version: 7.0.306
  • Stryker Version: 3.10.0

Additional context I tried to exclude the relevant files (see here), but it still fails.

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

Thanks for this. I tried, but alas, I am working via a VM on a Mac, and I cannot use Docker within this VM.

And just FYI: when running dotnet stryker on a GitHub Action, it fails with exactly the same error, so it should be (somehow) reproducable

Thanks. I am not sure we will able to provide a fix for this without someone on the team being able to reproduce the problem. But I still have some positive news for you:

  1. Not a workaround per se, but you should be able to run Stryker in single project mode by running it against test projects (see documentation)
  2. I will improve logging details for this so that the next release can help pinpoint the cause