Skip to content

More aggressive rollback for error CS0165#3548

Open
dupdob wants to merge 1 commit intomasterfrom
improve_rolback
Open

More aggressive rollback for error CS0165#3548
dupdob wants to merge 1 commit intomasterfrom
improve_rolback

Conversation

@dupdob
Copy link
Copy Markdown
Member

@dupdob dupdob commented Apr 14, 2026

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

Benefits:

  • Unblock projects that hit the 50 retries limit
  • Reduce build time, hence slightly reduce overall Stryker run time

Side effects:

  • slightly change the results as it will impact which mutations are rolled back

Copilot AI review requested due to automatic review settings April 14, 2026 15:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +334 to 335
if (MutantPlacer.RequiresRemovingChildMutations(mutationIf) || ErrorsRequiringRecursiveRemoval.Contains(diagnostic.Id))
{
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot generated this review using guidance from repository custom instructions.
Comment on lines +316 to +317
// errors that must trigger a deep removal of mutations
// usage of uninitialized variables (165)
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
Comment on lines +316 to +318
// errors that must trigger a deep removal of mutations
// usage of uninitialized variables (165)
private static readonly HashSet<string> ErrorsRequiringRecursiveRemoval = ["CS0165"];
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improving removal attempts of mutations when compile fails.

2 participants