You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CloneWithUpdatedSource mutates this instead of the returned clone #9573
TestMethod.CloneWithUpdatedSource(string source) (and by extension UnitTestElement.CloneWithUpdatedSource) in src/Adapter/MSTestAdapter.PlatformServices/ObjectModel assigns the new source (and clears MethodInfo) on this rather than on the returned clone:
internalTestMethodCloneWithUpdatedSource(stringsource){varclone=(TestMethod)MemberwiseClone();AssemblyName=source;// mutates `this`, not `clone`MethodInfo=null;// mutates `this`, not `clone`returnclone;// clone still carries the OLD source/MethodInfo}
So the returned "updated-source" clone actually keeps the old source, while the original (shared) element is mutated as a side effect. This is a latent bug that today's call order happens to tolerate (the shared element is re-read on subsequent calls), and the filter path is unaffected because the discovered test id is filename-based (source-path-independent).
Context
Phase 4 of the platform-agnostic effort (making MSTestAdapter.PlatformServices VSTest-object-model-free) needs correct element-based source resolution for the deployment path (see #6713 — the executed assembly must load from the deployment directory). Rather than change the shared primitive inside a strict no-behavior-change refactor, Phase 4 introduces a new, correct source-update method for the neutral engine path and leaves the existing buggy CloneWithUpdatedSource untouched for the ToTestCase/filter bridge callers, with a code comment referencing this issue.
Follow-up
Unify the two clone methods: fix CloneWithUpdatedSource to assign on the clone (and drop MethodInfo on the clone), migrate the remaining bridge callers, and remove the now-redundant method — verifying the deployment + cross-process suites stay green.
Activity
Track clone bug instead of fixing it; add correct CloneWithSource
Relocate the UnitTestElement<->TestCase conversion to the adapter (Ph…