Skip to content

Deduplicate ApplyEngine map-cloning helpers - #11758

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/code-simplifierdedup-cloning-helpers
Oct 6, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/code-simplifierdedup-cloning-helpers

Conversation

Copilot AI commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

ApplyEngine repeated candidate lookup and byte-map cloning expressions. This change extracts private helpers while preserving ordinal key comparison and byte-array deep copies.

  • Candidate maps: Replace three repeated lookups with ToCandidateMap.
  • Byte snapshots: Replace two repeated clones with CloneBytesMap.
private static Dictionary<string, Candidate> ToCandidateMap(IEnumerable<Candidate> candidates) =>
    candidates.ToDictionary(static candidate => candidate.CandidateId, StringComparer.Ordinal);

Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 14:12
Copilot AI changed the title [WIP] Simplify candidate-map and byte-map cloning helpers in ApplyEngine Deduplicate ApplyEngine map-cloning helpers Oct 5, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused refactor preserves the original comparer, projections, deep-copy behavior, control flow, and required file encoding.

Review effort: Balanced
Findings: None

@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review October 6, 2026 06:14
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) October 6, 2026 06:14
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 6, 2026

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, same static lambda (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.

@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 6, 2026
@github-actions github-actions Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 6, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added state/needs-review Awaiting review from the team. and removed state/needs-review Awaiting review from the team. labels Oct 6, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit e0f6f6a into main Oct 6, 2026
30 checks passed
@github-actions github-actions Bot added state/approved Proposal approved; ready for implementation. and removed state/needs-review Awaiting review from the team. labels Oct 6, 2026
@Evangelink
Amaury Levé (Evangelink) deleted the copilot/code-simplifierdedup-cloning-helpers branch October 6, 2026 08:28
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Oct 6, 2026
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.

[code-simplifier] Dedup candidate-map and byte-map cloning helpers in ApplyEngine

4 participants