Fix CloneWithUpdatedSource mutating this instead of the clone#9581
Merged
Conversation
Fixes #9573 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes an object-model cloning bug in the MSTest adapter platform services layer where TestMethod.CloneWithUpdatedSource mutated the original TestMethod instance instead of the returned clone, causing the clone to retain stale source/MethodInfo while introducing side effects on the shared original.
Changes:
- Update
CloneWithUpdatedSourceto assignAssemblyNameon the cloned instance. - Update
CloneWithUpdatedSourceto clearMethodInfoon the cloned instance (not onthis).
Show a summary per file
| File | Description |
|---|---|
| src/Adapter/MSTestAdapter.PlatformServices/ObjectModel/TestMethod.cs | Corrects CloneWithUpdatedSource to mutate the clone rather than the original instance. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Low
0101
approved these changes
Jul 3, 2026
github-actions Bot
added a commit
that referenced
this pull request
Jul 4, 2026
- Add --report-azdo-groups/--report-azdo-annotations toggles (#9542) to Platform changelog - Add re-print errored assemblies in end-of-run recap (#9545) to Platform changelog - Add server-initiated session cancellation (#9549) to Platform changelog - Add fix for CloneWithUpdatedSource mutating this (#9581) to MSTest changelog Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Evangelink
added a commit
that referenced
this pull request
Jul 5, 2026
This was referenced Jul 7, 2026
Evangelink
added a commit
that referenced
this pull request
Jul 8, 2026
- #9670 stays in MSTest 4.3.0 since it's being backported to rel/4.3 (only #9581 remains under 4.4.0). - Add new 2.3.0 stable HtmlReport and experimental (1.0.0-alpha.26357.13) extension packages (CtrfReport, GitHubActionsReport, JUnitReport, Logging, PackagedApp, VideoRecorder) to the MTP 2.3.0 artifacts. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.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.
Fixes #9573
TestMethod.CloneWithUpdatedSource(string source)(and by extensionUnitTestElement.CloneWithUpdatedSource) assigned the new source and clearedMethodInfoonthisrather than on the returned clone. As a result, the "updated-source" clone kept the old source/MethodInfo, while the shared original element was mutated as a side effect.Change
UnitTestElement.CloneWithUpdatedSourcedelegates to this method, so it is fixed transitively.Build passes with 0 warnings/errors.