Skip to content

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

Closed

Description

@github-actions

Code Simplification - 2026-10-05

This PR simplifies code from ApplyEngine.cs (introduced in merged PR #11733, "Split ApplyEngine into focused partial modules") to reduce duplication while preserving all functionality.

Files Simplified

  • .github/workflows/unskip-closed-tests-tool/ApplyEngine.cs - Extracted two small, named helper methods to remove repeated LINQ expressions that appeared 3–4 times each.

Improvements Made

  1. Reduced Duplication

    • The expression candidates.ToDictionary(static candidate => candidate.CandidateId, StringComparer.Ordinal) was repeated 3 times for building a candidate-ID lookup map from requestedManifest.Candidates, freshResolved.Candidates, and finalEligibility.Candidates. Extracted into ToCandidateMap(IEnumerable<Candidate>).
    • The byte-dictionary deep-clone expression (source.ToDictionary(pair => pair.Key, pair => pair.Value.ToArray(), StringComparer.Ordinal)) was repeated twice for originalBytes snapshots. Extracted into CloneBytesMap(Dictionary<string, byte[]>).
  2. Enhanced Clarity

    • Named helper methods make the intent of each dictionary construction self-documenting at each call site.
  3. No Behavior Change

    • Both helpers are pure, allocation-equivalent wrappers around the original inline LINQ expressions (same comparer, same projection, same deep-copy semantics).

Testing

  • ✅ dotnet build UnskipClosedTests.Tool.csproj succeeds with 0 warnings/errors.
  • ✅ dotnet run --project Tests/UnskipClosedTests.Tool.Tests.csproj — all 5 existing tests pass, unchanged.
  • ✅ No functional changes - behavior, ordering, and comparer semantics are identical.
  • ✅ UTF-8 BOM preserved in the edited file.

Review Focus

Please verify:

  • The two new private helpers (ToCandidateMap, CloneBytesMap) match prior inline semantics exactly (comparer StringComparer.Ordinal, static lambdas where applicable).
  • No unintended side effects on ApplyEngine.ApplyAsync control flow.

Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the change modifies protected files. A human must create the pull request manually.

Protected files

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the artifact from the workflow run
gh run download '37317221010' -n agent -D '/tmp/agent-37317221010'

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-37317221010/aw-code-simplifier-unskip-tool-dedup.bundle'
temp_ref='refs/bundles/create-pr-code-simplifier-unskip-tool-dedup-4e79fcd046a56932-300d1cb5'
target_ref='refs/heads/code-simplifier/unskip-tool-dedup-4e79fcd046a56932'
bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 ~ /^refs\/heads\// { print $2 }')
if [ -z "$bundle_source_ref" ]; then
  bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 == "HEAD" { print $2 }')
fi
if [ "$(printf '%s\n' "$bundle_source_ref" | sed '/^$/d' | wc -l | tr -d ' ')" != "1" ]; then
  echo "Expected exactly one bundle source ref, found: $bundle_source_ref" >&2
  exit 1
fi
git fetch "$bundle_path" "${bundle_source_ref}:${temp_ref}"
git update-ref "$target_ref" "$temp_ref"
git checkout 'code-simplifier/unskip-tool-dedup-4e79fcd046a56932'
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d "$temp_ref"

# Push the branch and create the pull request
git push origin code-simplifier/unskip-tool-dedup-4e79fcd046a56932
gh pr create --title '[code-simplifier] Dedup candidate-map and byte-map cloning helpers in ApplyEngine' --base main --head code-simplifier/unskip-tool-dedup-4e79fcd046a56932 --repo microsoft/testfx

Warning

Firewall blocked 8 domains

The following domains were blocked by the firewall during workflow execution:

  • 96bvsblobprodcus338.vsblob.vsassets.io
  • dc.services.visualstudio.com
  • github.com
  • kgfvsblobprodcus314.vsblob.vsassets.io
  • l49vsblobprodcus358.vsblob.vsassets.io
  • m6xvsblobprodcus342.vsblob.vsassets.io
  • pkgs.dev.azure.com
  • yluvsblobprodcus367.vsblob.vsassets.io

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "96bvsblobprodcus338.vsblob.vsassets.io"
    - "dc.services.visualstudio.com"
    - "github.com"
    - "kgfvsblobprodcus314.vsblob.vsassets.io"
    - "l49vsblobprodcus358.vsblob.vsassets.io"
    - "m6xvsblobprodcus342.vsblob.vsassets.io"
    - "pkgs.dev.azure.com"
    - "yluvsblobprodcus367.vsblob.vsassets.io"

See Network Configuration for more information.

🤖 Automated content by GitHub Copilot. Generated by the Code Simplifier workflow. · copilot · auto · 131.8 AIC · ⌖ 13.5 AIC · ⊞ 14.5K · [◷]( · ◷)

Add this agentic workflow to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/code-simplifier.md@main
  • expires on Oct 6, 2026, 1:42 PM UTC

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions