Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates Stryker’s C# compile-error rollback logic to be more aggressive for compiler error CS0165 (“use of unassigned local variable”), aiming to remove nested/child mutations during rollback so the project can recover from certain mutation-induced compilation failures.
Changes:
- Add a CS0165 diagnostic allow-list that triggers recursive (child) mutation removal during rollback.
- Update mutation identification logic to use the new CS0165 recursive-removal trigger.
- Minor whitespace/formatting cleanup in an MTP runner unit test.
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/Stryker.Core/Stryker.Core/Compiling/CSharpRollbackProcess.cs |
Adds CS0165-triggered recursive rollback and integrates it into mutation rollback identification. |
src/Stryker.TestRunner.MicrosoftTestPlatform.UnitTest/SingleMicrosoftTestPlatformRunnerTests.cs |
Whitespace/formatting-only adjustment. |
| if (MutantPlacer.RequiresRemovingChildMutations(mutationIf) || ErrorsRequiringRecursiveRemoval.Contains(diagnostic.Id)) | ||
| { |
There was a problem hiding this comment.
The new CS0165-specific branch changes rollback behavior (it will recursively remove child mutations instead of only the enclosing mutation). This is a functional change in compile-error recovery logic but there’s no unit test exercising the CS0165 scenario; please add coverage in Stryker.Core.UnitTest/Compiling/CSharpRollbackProcessTests validating that on a CS0165 diagnostic, the rollback process removes child mutations as intended (i.e., multiple mutant ids are rolled back in one pass, and the follow-up compilation succeeds).
| // errors that must trigger a deep removal of mutations | ||
| // usage of uninitialized variables (165) |
There was a problem hiding this comment.
The comment describing CS0165 as “usage of uninitialized variables” is inaccurate/misleading (CS0165 is “use of unassigned local variable”). Updating this comment to the correct wording will make it clearer why this diagnostic needs recursive rollback.
| // errors that must trigger a deep removal of mutations | |
| // usage of uninitialized variables (165) | |
| // Errors that must trigger a deep removal of mutations. | |
| // CS0165: use of unassigned local variable. |
| // errors that must trigger a deep removal of mutations | ||
| // usage of uninitialized variables (165) | ||
| private static readonly HashSet<string> ErrorsRequiringRecursiveRemoval = ["CS0165"]; |
There was a problem hiding this comment.
The PR description says this should fix #3542, but that issue’s concrete example is CS0161 (“not all code paths return a value”) from removing a trailing throw. This change only adds special handling for CS0165; please either (a) clarify in the PR description how CS0165 relates to #3542, or (b) include CS0161 (and any other intended diagnostics) in the set of errors that trigger recursive removal.
|



Preemptively remove mutations on error CS0165 (using undefined variable).
Should fix: #3542 & #3490.
Benefits:
Side effects: