Skip to content

test(serialization): cover multidimensional array copying - #10880

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-issue-10859-serialization-coverage
Aug 28, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-issue-10859-serialization-coverage

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 27, 2026

Copy link
Copy Markdown
Member

Problem

MultiDimensionalArrayCopier<T>.DeepCopy had no coverage despite complexity 22 and a reported CRAP score of 506. Its lower-bound handling also assumed zero-based arrays, and shallow-copyable arrays were not recorded in the copy context.

Solution

Add focused multidimensional array tests covering ranks 1, 2, and 3+, shallow and reference elements, repeated aliases, cycles, empty dimensions, extreme CLR bounds, round-trip independence, supported-type boundaries, and the non-zero-lower-bound serialization failure contract.

Preserve lower bounds during deep copy, record shallow array copies so aliases remain stable, use offset-based loops which remain correct at int.MinValue/int.MaxValue, and reject non-zero lower bounds during serialization explicitly because the wire format records lengths only.

The targeted coverage run raises MultiDimensionalArrayCopier<T> and DeepCopy from 0% line / 0% branch coverage to 100% line / 100% branch coverage, reducing the method CRAP score from 506 to 22.

This is a mergeable first slice of #10859. The repository-wide build currently encounters the independent main-branch failure tracked by #10856; #10878 contains that fix.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings August 27, 2026 23:29

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

Review tier: Lite
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity test/​Orleans.Serialization.UnitTests/​MultiDimensionalArrayTests.csArray.CreateInstance(typeof(MyValue), [1, 0], [int.MaxValue, int.MinValue]) is not portable…
What changed in this PR

Adds targeted unit tests and runtime fixes to improve correctness and coverage for multi-dimensional array cloning/serialization within Orleans’ serialization subsystem, addressing previously uncovered and complex MultiDimensionalArrayCopier<T>.DeepCopy behavior.

Changes:

  • Added comprehensive unit tests for multi-dimensional array deep copying (aliasing, cycles, bounds, empty dimensions) and serialization failure behavior for non-zero lower bounds.
  • Updated MultiDimensionalArrayCopier<T>.DeepCopy to preserve array lower bounds and to record shallow-copyable array clones in the copy context to maintain alias stability.
  • Updated MultiDimensionalArrayCodec<T> to explicitly reject serialization of multi-dimensional arrays with non-zero lower bounds.
File Description
test/​Orleans.Serialization.UnitTests/​MultiDimensionalArrayTests.cs Adds focused tests covering deep copy and serialization contracts for multi-dimensional arrays.
src/​Orleans.Serialization/​Codecs/​MultiDimensionalArrayCodec.cs Preserves lower bounds during deep copy, records shallow clones in copy context, and rejects non-zero-lower-bound array serialization.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread test/Orleans.Serialization.UnitTests/MultiDimensionalArrayTests.cs
Copilot AI review requested due to automatic review settings August 28, 2026 00:55
@ReubenBond
ReubenBond force-pushed the rb-issue-10859-serialization-coverage branch from fbee35a to 228bb3d Compare August 28, 2026 00:55

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

Review tier: Lite
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity src/​Orleans.Serialization/​Codecs/​MultiDimensionalArrayCodec.cs — EnsureZeroLowerBounds is currently executed before reference handling, so it will run even when the…
Pre-existing issues (1)
Severity Finding
Medium severity test/​Orleans.Serialization.UnitTests/​MultiDimensionalArrayTests.csArray.CreateInstance(typeof(MyValue), [1, 0], [int.MaxValue, int.MinValue]) is not portable… View comment

Comment thread src/Orleans.Serialization/Codecs/MultiDimensionalArrayCodec.cs Outdated
@github-actions

Copy link
Copy Markdown
Contributor

Code coverage

78.50% line coverage - 99,402 / 126,627 lines

Coverage details

Copilot AI review requested due to automatic review settings August 28, 2026 04:07

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

Review tier: Lite
Findings: None

Issues resolved since last review (2)
Severity Finding
Low severity src/​Orleans.Serialization/​Codecs/​MultiDimensionalArrayCodec.cs — EnsureZeroLowerBounds is currently executed before reference handling, so it will run even when the… View resolved comment
Medium severity test/​Orleans.Serialization.UnitTests/​MultiDimensionalArrayTests.csArray.CreateInstance(typeof(MyValue), [1, 0], [int.MaxValue, int.MinValue]) is not portable… View resolved comment

@ReubenBond
ReubenBond merged commit 0204f19 into dotnet:main Aug 28, 2026
72 of 75 checks passed
@ReubenBond
ReubenBond deleted the rb-issue-10859-serialization-coverage branch August 28, 2026 06:54
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.

2 participants