Repository navigation
Deduplicate ApplyEngine map-cloning helpers - #11758
Conversation
There was a problem hiding this comment.
Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
There was a problem hiding this comment.
Note
🤖 Automated review by GitHub Copilot. Generated by the Expert Code Review workflow. To request a follow-up action, reply by tagging @copilot directly.
Scope: Internal tooling refactor in .github/workflows/unskip-closed-tests-tool/ApplyEngine.cs (not part of the public MSTest/MTP API surface — reviewed proportionally as a low-risk, self-contained change).
Correctness & design — CLEAN
Both extracted helpers are verified equivalent to the inline code they replace:
ToCandidateMap(IEnumerable<Candidate> candidates)→candidates.ToDictionary(static candidate => candidate.CandidateId, StringComparer.Ordinal)— identical logic to all three original call sites (requestedCandidates,candidates,finalCandidates), same key selector, same comparer, samestaticlambda (no closure/capture risk).CloneBytesMap(Dictionary<string, byte[]> source)→source.ToDictionary(static pair => pair.Key, static pair => pair.Value.ToArray(), StringComparer.Ordinal)— identical to both original call sites (expectedBytes,rebuiltBytes), correctly deep-copies the byte arrays via.ToArray()rather than aliasing them, preserving the original defensive-copy semantics.
No behavioral change, no new allocation patterns, no edge-case divergence (empty collections, duplicate keys, etc. behave exactly as before since the underlying ToDictionary calls and comparer are unchanged). Naming is clear and consistent with the file's existing style. No concurrency, security, API-surface, or localization concerns apply to this change.
Verdict: Clean, low-risk deduplication refactor. No inline comments or blocking issues.
ApplyEnginerepeated candidate lookup and byte-map cloning expressions. This change extracts private helpers while preserving ordinal key comparison and byte-array deep copies.ToCandidateMap.CloneBytesMap.