stryker-net: Stryker disable comment not working for global statements
Describe the bug
I have a .NET 8 Web API whose “Program.cs” contains the code below.
The variable SWAGGER_MODULE is set when the project compiles with the “DEBUG” configuration, and not set when it compiles with the “RELEASE” configuration. Eitherway, note how the // Stryker disable all is outside of the #if. Still, the code gets mutated. (This is also the case if I move the // Stryker disable all inside the #if.)
Why does // Strykler disable all not work?
Logs
Stryker takes several hours on this very big project. I can run it over night and deliver the logs if really required.
Expected behavior
I expect that the code between // Stryker disable all and // Stryker restore all is not mutated.
Desktop (please complete the following information):
- OS: Windows 11
- Type of project: .NET 8 Web API
- Framework Version: .NET 8 Web API
- Stryker Version: 4.3.0
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 24 (13 by maintainers)
Thanks for your help. I am now able to reproduce the issue. This is a problem with top level statements. It turns out we have no test for these (unit or otherwise). For some reason,
// Stryker disable allapplies only to the next statement.I am looking into how to fix this. I suppose you consider this problem as a minor until we provide a fix, but if you want to have a workaround, you can either use the legacy construct for the main method. If you can’t or it does not suit you, you can use
// Stryker disable once allend enclose this bit of code in curly braces for the same result.Ultimately, you can also use multiple
// Stryker disable once.Sorry for the inconvenience and thank you for bearing with me with this.