test(serialization): cover multidimensional array copying - #10880
Merged
ReubenBond merged 2 commits intoAug 28, 2026
Merged
Conversation
11 tasks
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
test/Orleans.Serialization.UnitTests/MultiDimensionalArrayTests.cs — Array.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>.DeepCopyto 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.
ReubenBond
force-pushed
the
rb-issue-10859-serialization-coverage
branch
from
August 28, 2026 00:55
fbee35a to
228bb3d
Compare
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: 1
New issues introduced by this change (1)
| Severity | Finding |
|---|---|
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 |
|---|---|
test/Orleans.Serialization.UnitTests/MultiDimensionalArrayTests.cs — Array.CreateInstance(typeof(MyValue), [1, 0], [int.MaxValue, int.MinValue]) is not portable… View comment |
Contributor
Code coverage78.50% line coverage - 99,402 / 126,627 lines Coverage details
|
Contributor
There was a problem hiding this comment.
Copilot review overview
Review tier: Lite
Findings: None
Issues resolved since last review (2)
| Severity | Finding |
|---|---|
src/Orleans.Serialization/Codecs/MultiDimensionalArrayCodec.cs — EnsureZeroLowerBounds is currently executed before reference handling, so it will run even when the… View resolved comment |
|
test/Orleans.Serialization.UnitTests/MultiDimensionalArrayTests.cs — Array.CreateInstance(typeof(MyValue), [1, 0], [int.MaxValue, int.MinValue]) is not portable… View resolved comment |
This was referenced Aug 29, 2026
This was referenced Sep 7, 2026
This was referenced Sep 14, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Problem
MultiDimensionalArrayCopier<T>.DeepCopyhad 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>andDeepCopyfrom 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