Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declare standard predefined symbols when building mutated assemblies #1828

Closed
dupdob opened this issue Dec 7, 2021 · 9 comments · Fixed by #1836
Closed

Declare standard predefined symbols when building mutated assemblies #1828

dupdob opened this issue Dec 7, 2021 · 9 comments · Fixed by #1836
Assignees
Labels
🐛 Bug Something isn't working 🚀 Feature request New feature or request

Comments

@dupdob
Copy link
Member

dupdob commented Dec 7, 2021

Is your feature request related to a problem? Please describe.
See issue #1824

Describe the solution you'd like
Stryker needs to declare predefined symbols when building the mutated assembly.

Describe alternatives you've considered
Those symbols can be explicitly declared in the (VS/VC) project settings, but this defeats the purpose of predefined symbols.

Additional context
It appears Roslyn does not add them automatically. So the code may have to declare them according the target framework version. Any official method would obviously be preferable.

@dupdob dupdob added the 🚀 Feature request New feature or request label Dec 7, 2021
@psfinaki
Copy link
Contributor

psfinaki commented Dec 7, 2021

So I still don't completely understand it. Why symbols like NET6_0 are understood whereas symbols like NET6_0_OR_GREATER are not? This basically says that all these _OR_GREATER symbols were added with .NET5.

@dupdob
Copy link
Member Author

dupdob commented Dec 7, 2021

We need to test this, but are you certain that some symbols are automatically defined ? my understanding is that those are defined by MsBuild targets and Stryker does not use those (until we find a way to cleanly inject mutated source code during MsBuild builds).

@psfinaki
Copy link
Contributor

psfinaki commented Dec 7, 2021

Yes, actually Stryker currently works ideally for platform monikers other than OR_GREATER, and target-framework option in the config also performs correctly with that.

Look: Repro.zip

For this class:
image

This is what Stryker does:
image

100% behavior that we need.

@psfinaki
Copy link
Contributor

psfinaki commented Dec 7, 2021

image

It looks like internally something somewhere doesn't use the .NET5+ SDK.

@rouke-broersma
Copy link
Member

@psfinaki the build system is msbuild. We don't use msbuild so we don't have those symbols by default is what my guess would be. Why we do have some of the symbols I do not know.

@dupdob
Copy link
Member Author

dupdob commented Dec 7, 2021

update on this:
Stryker uses Buildalyzer to capture the settings of the project. I guess that is how Stryker captures the predefined symbols, so maybe the problem lies within Buildalyzer. We need either to repro this or see if this is a known issue on Buildalyzer

@richardwerkman
Copy link
Member

I was able to reproduce this issue and could not see a workaround. So I created an issue with buildalyzer.

@psfinaki
Copy link
Contributor

Thanks for that, @richardwerkman

@richardwerkman
Copy link
Member

I was able to fix the desired solution in Builalyzer so I created a PR. When it's merged and released we can fix this in Stryker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Something isn't working 🚀 Feature request New feature or request
Projects
None yet
4 participants