Skip to content

feat(audience): Json.Serialize pretty-print overload + Samples.SampleApp IVT (SDK-231)#705

Merged
ImmutableJeffrey merged 2 commits intomainfrom
feat/audience-diagnostic-surface
Apr 24, 2026
Merged

feat(audience): Json.Serialize pretty-print overload + Samples.SampleApp IVT (SDK-231)#705
ImmutableJeffrey merged 2 commits intomainfrom
feat/audience-diagnostic-surface

Conversation

@ImmutableJeffrey
Copy link
Copy Markdown
Collaborator

@ImmutableJeffrey ImmutableJeffrey commented Apr 24, 2026

Summary

  • Json.Serialize(dict, indent) pretty-print overload — indent ≤ 0 routes to the compact Serialize, so every wire-payload caller is unaffected.
  • InternalsVisibleTo("Immutable.Audience.Samples.SampleApp") so the in-repo sample reaches Json.Serialize / JsonReader.DeserializeObject without widening the public API.
  • Audience.Tests.csproj excludes Editor/**/*.cs from the headless dotnet build — no-op today, prereq for the sample-app PR whose editor-only tests reference Unity types.

Closes SDK-231. Prereq for SDK-230 (Unity Audience SampleApp) landing next.

Test plan

  • dotnet test src/Packages/Audience/Tests/Audience.Tests.csproj passes.
  • Unity Test Runner (2022 LTS+): existing JsonTests fixture still passes; pretty-print round-trips through Deserialize identically.

🤖 Generated with Claude Code


Note

Medium Risk
Touches core JSON serialization used for event storage/network payloads; while the default compact path is intended to be unchanged, regressions could affect message formatting/round-tripping. Build changes also alter which tests compile in headless CI, potentially hiding Unity-only failures outside the Unity runner.

Overview
Adds a new Json.Serialize(dict, indent) overload to optionally pretty-print JSON with indentation, while keeping the existing Serialize(dict) as the compact default for wire/disk payloads.

Refactors the JSON writer to thread indent/depth through object/array/value writing and insert newlines/spaces only when pretty-printing. Also grants InternalsVisibleTo for Immutable.Audience.Samples.SampleApp and excludes Editor/**/*.cs from the headless Audience.Tests build to avoid Unity-only compile dependencies.

Reviewed by Cursor Bugbot for commit 73d3e46. Bugbot is set up for automated code reviews on this repo. Configure here.

ImmutableJeffrey and others added 2 commits April 24, 2026 11:50
Second overload indenting nested containers by `indent` spaces per
level. Round-trips through Deserialize identically; indent ≤ 0
routes to the existing compact Serialize, so every wire-payload
caller is unaffected.

Internal scaffolding:
- WriteObject / WriteArray / WriteValue thread indent + depth so the
  overload can emit newlines and leading spaces at the correct
  nesting level.
- AppendNewline helper centralises the "\n + (indent * depth) spaces"
  pattern.
- pretty-path writes ":" with a trailing space; empty containers stay
  on a single line ({} / []), matching the compact form for collapsed
  nodes.

No behaviour change on the compact overload for any existing caller;
the indent threading is inert when indent == 0 (pretty=false).

Motivated by the sample-app landing next — its Init tab renders the
effective AudienceConfig as an echo view, and the Events/Identity
tabs show constructed property dicts, all via Json.Serialize(…, 2).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…tor from headless build

IVT lets the in-repo SampleApp reach Json.Serialize and
JsonReader.DeserializeObject — helpers the public API does not expose.

csproj Remove="Editor/**/*.cs" is a no-op today; prereq for the
sample-app PR, whose editor tests reference Unity-only types that
fail the headless dotnet build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ImmutableJeffrey ImmutableJeffrey force-pushed the feat/audience-diagnostic-surface branch from 85c7b38 to 73d3e46 Compare April 24, 2026 01:51
@ImmutableJeffrey ImmutableJeffrey marked this pull request as ready for review April 24, 2026 02:05
@ImmutableJeffrey ImmutableJeffrey requested review from a team as code owners April 24, 2026 02:05
@ImmutableJeffrey ImmutableJeffrey merged commit e1faba2 into main Apr 24, 2026
20 checks passed
@ImmutableJeffrey ImmutableJeffrey deleted the feat/audience-diagnostic-surface branch April 24, 2026 02:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants