Skip to content

Split XxHashShared into focused partial files - #11800

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/file-diet-refactor-xxhashshared
Oct 8, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
copilot/file-diet-refactor-xxhashshared

Conversation

Copilot AI commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

XxHashShared.cs had grown to 956 lines, making the hashing implementation harder to navigate. Split its unchanged implementation into focused partial-class files.

  • State: State lifecycle and buffer layout.
  • Core: Scalar digest and mixing operations.
  • SIMD: Vectorized accumulation and scrambling.
  • Primitives: Low-level read, write, and bit-mixing helpers.
  • Shared constants: Retained in XxHashShared.cs.

Copilot AI balanced review requested due to automatic review settings October 7, 2026 19:15

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 7, 2026 19:30
Copilot AI changed the title [WIP] Refactor XxHashShared.cs into focused modules Split XxHashShared into focused partial files Oct 7, 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.

🟢 Approval recommended

The mechanical split preserves implementation, API surface, linked-source inclusion, and file-size requirements.

0 open findings

🧠 Review effort: Balanced

@Evangelink
Amaury Levé (Evangelink) marked this pull request as ready for review October 8, 2026 07:08
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) October 8, 2026 07:09
@github-actions github-actions Bot added the state/needs-review Awaiting review from the team. label Oct 8, 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 verified, purely mechanical file split with no logic changes.

Change classification

  • Internal refactor: src/Platform/Microsoft.Testing.Extensions.TrxReport/Hashing/XxHashShared.cs (956 lines) split into 4 new partial class files — XxHashShared.Core.cs (scalar digest/mixing), XxHashShared.Primitives.cs (read/write/bit-mixing helpers), XxHashShared.Simd.cs (vectorized accumulate/scramble), XxHashShared.State.cs (state lifecycle, buffer layout, State struct) — with constants, the DefaultSecret tables, and the #if DEBUG && NET static-constructor self-check retained in the original file. The XxHashShared class itself becomes partial; no other type changes.

Verification performed

  • Algorithmic correctness / no behavior change: Extracted every added (+) line from the diff for the 4 new files and the trimmed main file, then compared against the pre-PR 956-line file line-by-line (ignoring only file-header/namespace/using/brace noise). Every method body, Debug.Assert, constant reference, and #if NET branch in the original file reappears verbatim in exactly one of the 5 post-split files — zero lines were dropped, and zero new logic lines were introduced beyond the file-split comment headers. All 29 public/private/internal members (Rrmxmx, HashInternalLoop, ConsumeStripes, DigestLong, Accumulate*, ScrambleAccumulator*, Initialize, Reset, Append, CopyAccumulators, ReadUInt64LE, etc.) are present with identical signatures and bodies in both the before and after trees.
  • Cross-TFM correctness: Each new file re-declares only the using/#if NET guards it actually needs (e.g. XxHashShared.Simd.cs keeps the System.Runtime.Intrinsics.{Arm,Wasm,X86} usings gated by #if NET; XxHashShared.Primitives.cs keeps System.Buffers.Binary unconditionally since ReadUInt32LE/WriteUInt64LE use BinaryPrimitives on all TFMs). Confirmed via the repo's Directory.Build.props implicit <Using Include="System.Diagnostics" /> / System.Runtime.CompilerServices / System.Runtime.InteropServices entries that Debug, MethodImplOptions, MemoryMarshal, and Unsafe resolve without per-file usings — consistent with how the original monolithic file relied on the same implicit usings.
  • Build/project wiring: Microsoft.Testing.Extensions.TrxReport.csproj has no explicit <Compile Include> for the Hashing/ folder, so it relies on the SDK's default glob — the 4 new sibling files are automatically picked up with no project-file edit required (verified no project file was touched in the diff and none was needed).
  • License/attribution correctness: Every new file carries the Microsoft copyright/MIT header plus the // Adapted from https://github.com/dotnet/runtime/blob/<pinned-sha>/.../XxHashShared.cs attribution comment pointing at the same pinned upstream commit as the pre-split file, with an added one-line note on which slice of the upstream file each partial covers. This isn't a new vendor/fork — it's reorganizing an already-vendored-and-adapted file that predates this PR; attribution is preserved unchanged.
  • Formatting (BOM / .editorconfig): Confirmed all 4 new files and the trimmed XxHashShared.cs retain the required UTF-8 BOM (EF BB BF) matching sibling files (XxHash128.cs, BitOperations.cs) in the same folder, and each file ends with a single trailing newline (SA1518) with no trailing whitespace (SA1028) on inspected lines.
  • Public API: XxHashShared is internal; no PublicAPI.Unshipped.txt entries were needed or added, correctly.

Confidence at a glance

🟢 Correctness & design — verified no-op split
  • Why it applies: Large structural change to a hot-path hashing implementation warrants verifying no logic drift.
  • Evidence: Line-by-line reconciliation (see above) shows 100% body preservation across the 5 resulting files with zero added/removed logic lines.
  • Gap or disposition: None — purely mechanical, as the PR description claims.
🟢 Cross-TFM compatibility — guards correctly redistributed
  • Why it applies: Code targets net462/netstandard2.0/net8.0/net9.0; moving #if NET-gated SIMD code to a new file risks losing a guard.
  • Evidence: XxHashShared.Simd.cs keeps all #if NET / Vector128/Vector256/Avx2/AdvSimd/Sse2/PackedSimd guards intact exactly as in the original; XxHashShared.Core.cs keeps its own #if NET branches for Math.BigMul vs. manual 64x64→128 multiply.
  • Gap or disposition: None found.
🟢 Performance — no allocation or inlining changes
  • Why it applies: This is a hashing hot path used by TRX reporting; splitting into partial-class files must not affect JIT inlining/codegen decisions.
  • Evidence: All [MethodImpl(MethodImplOptions.AggressiveInlining/NoInlining)] attributes are preserved unchanged on the moved methods; partial classes compile to a single type so there is no runtime indirection introduced by the split.
  • Gap or disposition: None — partial-class splitting is purely a compile-time/source-organization construct with zero runtime effect.

⚪ Not applicable: Threading & concurrency, Security & IPC protocol, Public API & binary compatibility, Resource/IDisposable management, Defensive coding, Localization, Tests (no test files changed, no behavior changed), Analyzer quality, Build infrastructure & dependencies (no dependency/version changes), Scope & PR discipline (single, well-scoped refactor), PowerShell scripting hygiene, MSBuild authoring (no .props/.targets touched).

@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 8, 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 8, 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 8, 2026
@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 8, 2026
@Evangelink
Amaury Levé (Evangelink) merged commit 14c5199 into main Oct 8, 2026
31 of 32 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the copilot/file-diet-refactor-xxhashshared branch October 8, 2026 08:26
@github-actions github-actions Bot removed the state/approved Proposal approved; ready for implementation. label Oct 8, 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.

[file-diet] Refactor XxHashShared.cs (956 lines) into focused modules

4 participants