Skip to content

feat: Expand multidimensional array and dictionary previews in CapturedVariables#1921

Merged
hatayama merged 1 commit into
feature/round7-pause-point-improvementsfrom
fix/pause-point-nullable-enum-array-preview
Jul 21, 2026
Merged

feat: Expand multidimensional array and dictionary previews in CapturedVariables#1921
hatayama merged 1 commit into
feature/round7-pause-point-improvementsfrom
fix/pause-point-nullable-enum-array-preview

Conversation

@hatayama

@hatayama hatayama commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • CapturedVariables previews for multidimensional arrays and dictionaries no longer degrade to a bare type-name string when nested a couple of field-access hops deep inside a captured variable.
  • Enum values inside array/dictionary previews now render by name instead of their underlying integer.

User Impact

Before this fix, inspecting a captured variable like a Tetris board's _cells field (PieceType?[,]) showed only an opaque type-name string such as "System.Nullable\1[...PieceType][,]"-- no shape, no cell values. NestedDictionary<string, int> fields hit the same problem. Separately, even where a preview did expand, enum elements showed up as raw integers ([0,null,1]`) instead of readable names.

After this fix:

  • Board._cells (and any array/dictionary of primitives, enums, or strings) previews as a real Shape/Elements (or key/value) structure at any nesting depth reachable from a captured variable.
  • Enum elements render by name (["Alpha",null,"Beta"]), consistent with how a plain enum-typed local already renders.
  • Collections whose elements are themselves non-primitive objects still fall back to a type name once the preview depth limit is reached -- this fix does not remove the depth limit, only exempts primitive/enum/string leaves from consuming it.

Changes

  • SourcePausePointCollectionPreviewSerializer.cs:
    • Registered StringEnumConverter on the shared primitive JsonSerializer so enum values serialize by name.
    • Added IsJsonPrimitiveElementType/IsPrimitiveKeyValueDictionaryType to detect arrays/dictionaries whose elements (or keys and values) are all primitives, enums, or strings, and exempt those from the remainingDepth <= 0 fallback gate.

Verification

  • dist/darwin-arm64/uloop compile --project-path .: 0 errors, 0 warnings
  • dist/darwin-arm64/uloop run-tests --filter-type regex --filter-value "SourcePausePointVariableFormatterTests" --test-mode EditMode: 42/42 passed (6 new tests covering 1D/2D nullable-enum arrays, primitive-value dictionaries, and the two-hop nesting boundary for both, plus a boundary case confirming non-primitive collections still respect the depth limit)
  • dist/darwin-arm64/uloop run-tests --filter-type regex --filter-value "SourcePausePoint" --test-mode EditMode: 124/124 passed, no regressions

Review in cubic

…pause-point CapturedVariables

The collection preview serializer had two independent bugs affecting
CapturedVariables output:

1. Enum values inside arrays/dictionaries serialized as their underlying
   integer (e.g. [0,null,1]) instead of their name, diverging from the
   scalar-capture path which already renders enums by name. Fixed by
   registering StringEnumConverter on the shared primitive JsonSerializer.

2. A T?[,] or Dictionary<K,V> reached two field-access hops deep (e.g.
   Board._cells) exhausted the remaining preview depth budget before
   BuildToken ever inspected the collection itself, degrading it to a bare
   type-name ToString fallback -- reproducing the reported Tetris board
   symptom exactly. Fixed by exempting arrays/dictionaries whose
   elements/keys/values are all primitives, enums, or strings from the
   depth gate, since those leaf values already resolve independent of
   depth. Collections of non-primitive objects still degrade at the depth
   limit as before.
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The preview serializer now renders enum names and preserves JSON expansion for primitive arrays and dictionaries at depth limits. New formatter tests cover nullable enum arrays, nested field access, primitive dictionary serialization, and custom-object fallback behavior.

Changes

Pause point preview serialization

Layer / File(s) Summary
Primitive preview serialization and depth handling
Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointCollectionPreviewSerializer.cs
Enum values use names in JSON previews, while primitive arrays and dictionaries continue expanding at the depth limit; non-primitive collections still fall back to type names.
Nested nullable collection regression coverage
Assets/Tests/Editor/SourcePausePointCapture/SourcePausePointVariableFormatterTests.cs
Tests and fixtures cover nullable enum array shapes, null elements, nested field access, primitive dictionaries, and custom-object dictionary fallback.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: expanding CapturedVariables previews for multidimensional arrays and dictionaries.
Description check ✅ Passed The description is clearly related to the changeset and explains the preview fixes, behavior changes, and verification results.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pause-point-nullable-enum-array-preview

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointCollectionPreviewSerializer.cs (1)

126-129: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consider supporting generic collections (like List<T>) for primitive JSON expansion at depth limits.

Currently, this depth-limit exception explicitly targets Array and IDictionary. This perfectly fulfills the PR's objective, but it means that a primitive list (e.g., List<int>) nested at the depth limit will still fall through isPrimitiveElementArray and degrade to a type-name string fallback.

If you want to allow all generic collections of primitives to remain JSON-expandable at depth limits, consider expanding this check to inspect IEnumerable<T> or ICollection<T> to cover common types like List<T> and HashSet<T>.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointCollectionPreviewSerializer.cs`
around lines 126 - 129, Extend the depth-limit primitive collection detection
around isPrimitiveElementArray to recognize generic IEnumerable<T> or
ICollection<T> implementations, including List<T> and HashSet<T>, while
preserving the existing array and dictionary checks. Ensure the element type is
validated with IsJsonPrimitiveElementType so only collections of JSON primitives
remain expandable.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In
`@Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointCollectionPreviewSerializer.cs`:
- Around line 126-129: Extend the depth-limit primitive collection detection
around isPrimitiveElementArray to recognize generic IEnumerable<T> or
ICollection<T> implementations, including List<T> and HashSet<T>, while
preserving the existing array and dictionary checks. Ensure the element type is
validated with IsJsonPrimitiveElementType so only collections of JSON primitives
remain expandable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b2ecd05e-44c3-4cd4-bde6-de560cacb210

📥 Commits

Reviewing files that changed from the base of the PR and between 8e19067 and d28952d.

📒 Files selected for processing (2)
  • Assets/Tests/Editor/SourcePausePointCapture/SourcePausePointVariableFormatterTests.cs
  • Packages/src/Editor/FirstPartyTools/PausePoint/SourcePausePointCollectionPreviewSerializer.cs

@hatayama
hatayama merged commit 3303491 into feature/round7-pause-point-improvements Jul 21, 2026
2 checks passed
@hatayama
hatayama deleted the fix/pause-point-nullable-enum-array-preview branch July 21, 2026 13:12
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.

1 participant