Repository navigation
Split XxHashShared into focused partial files - #11800
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.
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 newpartial classfiles —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,Statestruct) — with constants, theDefaultSecrettables, and the#if DEBUG && NETstatic-constructor self-check retained in the original file. TheXxHashSharedclass itself becomespartial; 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 NETbranch 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 NETguards it actually needs (e.g.XxHashShared.Simd.cskeeps theSystem.Runtime.Intrinsics.{Arm,Wasm,X86}usings gated by#if NET;XxHashShared.Primitives.cskeepsSystem.Buffers.Binaryunconditionally sinceReadUInt32LE/WriteUInt64LEuseBinaryPrimitiveson all TFMs). Confirmed via the repo'sDirectory.Build.propsimplicit<Using Include="System.Diagnostics" />/System.Runtime.CompilerServices/System.Runtime.InteropServicesentries thatDebug,MethodImplOptions,MemoryMarshal, andUnsaferesolve without per-file usings — consistent with how the original monolithic file relied on the same implicit usings. - Build/project wiring:
Microsoft.Testing.Extensions.TrxReport.csprojhas no explicit<Compile Include>for theHashing/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.csattribution 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 trimmedXxHashShared.csretain 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:
XxHashSharedisinternal; noPublicAPI.Unshipped.txtentries 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.cskeeps all#if NET/Vector128/Vector256/Avx2/AdvSimd/Sse2/PackedSimdguards intact exactly as in the original;XxHashShared.Core.cskeeps its own#if NETbranches forMath.BigMulvs. 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).
XxHashShared.cshad grown to 956 lines, making the hashing implementation harder to navigate. Split its unchanged implementation into focused partial-class files.XxHashShared.cs.