fix(object-creation-mutator): skip empty initializer for required members#3603
Open
slang25 wants to merge 3 commits into
Open
fix(object-creation-mutator): skip empty initializer for required members#3603slang25 wants to merge 3 commits into
slang25 wants to merge 3 commits into
Conversation
…quired members
ObjectCreationMutator always emits an empty-initializer variant
(e.g. `new Notification {}`), which fails to compile with CS9035 when
the target type has C# 11 required properties or fields.
Use the semantic model to walk the resolved type and its base types; if
any member has IsRequired == true, skip the empty-initializer mutation.
Fixes stryker-mutator#3598
4 tasks
… skip Skipping object-initializer mutations on types with required members removes 4 mutants from the integration target projects. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Member
|
As said in the related issue, I am afraid I don't think this filtering logic adds enough value to warrant a merge. Instead of non mutating them, why not using your detection logic to initialize said required members to default value? I simply wonder if those would be sensible mutations. What do you think? |
…lt! instead of skipping When the target type has required members, an empty initializer fails to compile with CS9035. Previously the mutator skipped these creations entirely; now it emits a mutation that keeps every required member assigned to `default!`, producing a compileable mutation that still exercises behaviour. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ObjectCreationMutatoralways emits an empty-initializer variant (e.g.new Notification {}), which fails to compile with CS9035 when the target type has C# 11requiredproperties/fields.IsRequired == true, skip the empty-initializer mutation.Fixes #3598. Split out from #3594.
Test plan
ObjectCreationMutatorTestscases still pass