Skip to content

feat: support multi-dimensional array indexing and iteration - #649

Merged
rexm merged 2 commits into
masterfrom
fix/issue-483
Aug 5, 2026
Merged

feat: support multi-dimensional array indexing and iteration#649
rexm merged 2 commits into
masterfrom
fix/issue-483

Conversation

@rexm

@rexm rexm commented Aug 5, 2026

Copy link
Copy Markdown
Member

Summary

  • C# true multi-dimensional arrays (rank > 1, e.g. int[,]) previously threw when indexed via path expressions (Array's non-generic IList indexer rejects rank > 1) or iterated with {{#each}} (cast to T[] failed for non-SZArrays).
  • Adds a lazy MultidimensionalArraySlice view that lets a rank-N array be walked one dimension at a time: {{grid.[0].[1]}} indexes dimension by dimension, and {{#each}} iterates the outer-most dimension, yielding row/slab slices for the remaining dimensions (matches how users conceptually think of a 2D array as rows).
  • Jagged arrays and existing IList/IEnumerable behavior are unaffected — rank-1 arrays keep using the existing code path.

Test plan

  • Added tests in IteratorTests.cs/BasicIntegrationTests.cs: jagged-array regression, 2D #each (including @index), 3D nested #each, 2D/3D path indexing
  • Full test suite passes (1857/1857)
  • README.md updated with a new "Multi-dimensional Arrays" section and examples

Fixes #483

🤖 Generated with Claude Code

)

C# true multi-dimensional arrays (rank > 1, e.g. int[,]) previously threw
when indexed via path expressions (Array's non-generic IList indexer
rejects rank > 1) or iterated with {{#each}} (cast to T[] failed for
non-SZArrays).

Adds a lazy MultidimensionalArraySlice view that lets a rank-N array be
walked one dimension at a time - {{grid.[0].[1]}} indexes dimension by
dimension, and {{#each}} iterates the outer-most dimension, yielding
row/slab slices for the remaining dimensions. Jagged arrays and
IList/IEnumerable behavior are unaffected since rank-1 arrays keep using
the existing code path.
@rexm
rexm enabled auto-merge August 5, 2026 04:14
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

@rexm
rexm merged commit cd6a95e into master Aug 5, 2026
7 checks passed
@rexm
rexm deleted the fix/issue-483 branch August 5, 2026 04:39
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.

[Feature] Multi-dimensional Arrays support

1 participant