Skip to content

Deduplicate sample binlog argument construction - #11740

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/duplicate-code-fix-binlog-path
Oct 5, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/duplicate-code-fix-binlog-path

Conversation

Copilot AI commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Sample build scripts repeated binlog path, suffix, and argument-prefix construction across several code paths, risking inconsistent naming and behavior.

  • Shared helper

    • Add Get-SampleBinlogArgument to eng/samples-tools.ps1.
    • Centralize .binlog suffixing, path joining, and -bl://bl: formatting.
  • Call-site consolidation

    • Use the helper for UWP restore/build, regular solution builds, and standalone projects.
    • Reuse it from test-samples.ps1 while preserving its -bl:{} fallback.
$buildArgs += Get-SampleBinlogArgument `
    -BinaryLogDirectory $BinaryLogDirectory `
    -LogName $solutionName

Copilot AI balanced review requested due to automatic review settings October 4, 2026 12:10

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 4, 2026 12:17
Copilot AI changed the title [WIP] Refactor to eliminate duplicate binlog-path construction Deduplicate sample binlog argument construction Oct 4, 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 refactoring preserves existing argument behavior and introduces no unresolved issues.

Review effort: Balanced
Findings: None

@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review October 4, 2026 12:56
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) October 4, 2026 12:57
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 4, 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.

Review outcome: No actionable findings — this is a behavior-preserving DRY refactor that correctly consolidates binlog-argument construction.

Change classification

  • Build infrastructure / PowerShell tooling: New Get-SampleBinlogArgument helper in eng/samples-tools.ps1, consumed by all 5 previously-duplicated call sites in eng/build-samples.ps1 (UWP restore, UWP build, regular dotnet build, standalone projects) and eng/test-samples.ps1's Get-BinlogArgument.

Confidence at a glance

🟢 Correctness & design — verified equivalent
  • Why it applies: Refactor must preserve the exact binlog path/prefix produced at every call site.
  • Evidence: Traced all 5 call sites: /bl: prefix is preserved for the two UWP (restore/msbuild) sites via explicit -ArgumentPrefix "/bl:", and -bl: default is preserved for the dotnet build and standalone-project sites. In test-samples.ps1, Get-BinlogArgument strips the .binlog suffix from $logName before calling the helper (which re-appends it), so the composed path is byte-for-byte identical to before; the -bl:{} fallback (used by hot-reload/MSBuild-server style invocation) is untouched. The downstream VisualStudioInvoke mode's $binlogArgument.Substring(4) (stripping the 4-char -bl: prefix) still holds since the default prefix length is unchanged.
  • Gap or disposition: None found; pure mechanical consolidation with no behavioral drift.
🟢 Build, dependencies & scripts (PowerShell Scripting Hygiene) — clean
  • Why it applies: eng/**/*.ps1 changes are always in scope for this dimension.
  • Evidence: No $array += $item loop accumulation, no parameter-name shadowing, no inline gh/external-tool duplication, no batch-loop abort-on-first-failure pattern introduced. Set-StrictMode -Version Latest is already present in both calling scripts (unaffected by this change). The new function mirrors the existing sibling Get-SampleRelativePath's style (no comment-based help), so it's consistent with the file's conventions.
  • Gap or disposition: None.

⚪ Not applicable: Concurrency & lifecycle, Security & protocol, API & compatibility, Performance, Localization, Tests, Analyzers (no production code, public API, async/threading, security boundary, user-facing string, analyzer, or test-coverage-relevant behavior touched — purely mechanical build-script deduplication per the Edge Cases "mechanical changes" exception).

@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 4, 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 4, 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 5, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 9d751e6 into main Oct 5, 2026
28 of 30 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the copilot/duplicate-code-fix-binlog-path branch October 5, 2026 07:27
@github-actions github-actions Bot removed the state/needs-review Awaiting review from the team. label Oct 5, 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.

[duplicate-code] Duplicate Code: Repeated BinaryLogDirectory/binlog-path construction in eng/build-samples.ps1

4 participants