stryker-mutator / stryker-net

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

Problems with loading Analyzer/Generator assemblies in .NET 7 #2317

Closed psfinaki closed 1 year ago

psfinaki commented 1 year ago

Describe the bug Stryker emits some warnings on the topic when running under .NET 7. They don't seem to be very helpful though, as otherwise the mutation testing works seemingly fine.

image

Logs I will attach the repro but since this might be some kind of an environmental issue, here is also the log: log-20221114.txt

Expected behavior Normal execution.

Desktop (please complete the following information):

Additional context This is not the case for .NET 6. Repro: Repro.zip

pinkfloydx33 commented 1 year ago

I have had the same issue. You don't even necessarily need to be referencing .NET7, just the 7.0.0 versions of those packages which supposedly support .NET6. It tries to load/find all of the analyzers that are included by default in the SDK, even if you aren't using them. (I'm not sure, but it may also happen when referencing the 6.0.x versions but building with the 7.0 SDK)

They seem to be looking for ref assemblies, but I recall recently reading something about ref assemblies not being produced anymore (or at least, in the way they used to be) for inbox packages. Could this be related? Found it: here though perhaps I misunderstand the conversation.

tdashworth commented 1 year ago

Same problem here with a .NET 7 Blazor WASM application.

Repo: https://github.com/tdashworth/name-badge-automater

tdashworth commented 1 year ago

I have tried rolling back to .NET6 (with version 6 of Nuget packages) but still getting this:

[08:57:49 WRN] Stryker.NET encountered an compile error in ...NameBadgeAutomator\src\NameBadgeAutomater\Program.cs (at 7:27) with message: The type or namespace name 
'App' could not be found (are you missing a using directive or an assembly reference?) (Source code: App)
[08:57:49 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.
centreboard commented 1 year ago

Updating to .NET 7 I'm getting errors like:

[09:03:53 WRN] Analyzer/Generator assembly C:\hostedtoolcache\windows\dotnet\packs\Microsoft.AspNetCore.App.Ref\7.0.0\analyzers/dotnet/roslyn4.4/cs/Microsoft.Extensions.Logging.Generators.dll could not be loaded. Generated source code may be missing.

which then fails to compile due to the generator not running. Might #2318 help?

rouke-broersma commented 1 year ago

@centreboard I suspect so

psfinaki commented 1 year ago

Yeeeep it seems to help, at least it fixes the repro posted in this issue, I tried running Stryker from this branch.

rouke-broersma commented 1 year ago

This is probably improved/fixed in 3.2.0