Skip to content

feat(utilities.text.json): STJ overloads for keystone JsonExtensions + migrate 5 callers (#83) - #166

Merged
ChrisonSimtian merged 1 commit into
mainfrom
feature/83-jsonextensions-stj-keystone
May 24, 2026
Merged

feat(utilities.text.json): STJ overloads for keystone JsonExtensions + migrate 5 callers (#83)#166
ChrisonSimtian merged 1 commit into
mainfrom
feature/83-jsonextensions-stj-keystone

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Summary

Adds System.Text.Json parallel overloads to the JsonExtensions keystone and migrates all 5 internal callers to the STJ surface. Non-breaking on 10.3.x — Newtonsoft surface stays, just [Obsolete] for v11 removal.

JsonExtensions.cs surface

New (STJ):

  • DefaultSerializerOptions (System.Text.Json equivalent of DefaultSerializerSettings)
  • ToJson<T>(JsonSerializerOptions), GetJson<T>(JsonSerializerOptions)
  • GetJsonObject(string) → JsonObject, ReadJsonObject(AbsolutePath) → JsonObject
  • WriteJson<T>(AbsolutePath, T, JsonSerializerOptions)
  • ReadJson<T>(AbsolutePath, JsonSerializerOptions)
  • UpdateJson<T>(AbsolutePath, Action<T>, JsonSerializerOptions)
  • UpdateJsonObject(AbsolutePath, Action<JsonObject>)

[Obsolete] for v11 removal (Newtonsoft):

  • ToJson<T>(JsonSerializerSettings?, Formatting)
  • GetJson<T>(JsonSerializerSettings?), GetJson(JsonSerializerSettings?) → JObject
  • WriteJson<T>(JsonSerializerSettings?), ReadJson<T>(JsonSerializerSettings?), ReadJson(JsonSerializerSettings?) → JObject
  • UpdateJson<T>(Action<T>, JsonSerializerSettings?), UpdateJson(Action<JObject>, JsonSerializerSettings?)

STJ overloads require an explicit JsonSerializerOptions argument (no default) to avoid overload-resolution ambiguity with the Newtonsoft no-args path. Callers wanting framework defaults pass JsonExtensions.DefaultSerializerOptions.

Migrated callers (5)

File Pattern
Tools/OctoVersion/OctoVersionTasks.cs Drops the AllWritableContractResolver workaround (STJ binds records via ctor natively)
Attributes/HandleSingleFileExecutionAttribute.cs global.json sdk.version lookup uses JsonObject + GetValue<string>
GlobalTool/Program.Secrets.cs Secret param read/write via JsonObject + Where on the IEnumerable<KeyValuePair<string, JsonNode>> it implements
GlobalTool/Program.Setup.cs Parameters-file write
GlobalTool/Program.Update.cs global.json sdk.version write

Drops using Newtonsoft.Json.Linq; from all 5; they're now pure STJ.

Out of scope (still needs Newtonsoft)

  • JObject.GetChildren.cs / JObject.GetPropertyValue.cs — still used by the 3 pragma-suppressed call sites from feat(net): STJ overloads for HTTP JSON helpers, [Obsolete] Newtonsoft surface (#83 follow-up) #165 (MastodonTasks, SlackTasks, GitHubActions.Client). Their migration is a separate v11 cutover.
  • AllWritableContractResolver, Base64JsonConverter — unused after the OctoVersionTasks migration but kept until the v11 cleanup (external consumers may still reference them).
  • Fallout.Tooling, Fallout.Tooling.Generator, Fallout.Build (NJsonSchema swap), the bulk of Fallout.Common runtime + ~60 Tools/*/*.Generated.cs files.

Added System.Text.Json PackageReference to Fallout.Utilities.Text.Json.csproj (STJ isn't in netstandard2.0 BCL). Newtonsoft.Json reference stays for the still-internal Newtonsoft-typed surfaces.

Verification

  • dotnet build src/Fallout.Utilities.Text.Json/Fallout.Utilities.Text.Json.csproj — 0 errors
  • dotnet build src/Fallout.Common/Fallout.Common.csproj — 0 errors (callers migrated cleanly)
  • dotnet build src/Fallout.GlobalTool/Fallout.GlobalTool.csproj — 0 errors
  • dotnet build fallout.slnx — 0 errors across the whole solution
  • dotnet test tests/Fallout.SourceGenerators.Tests/Fallout.SourceGenerators.Tests.csproj — 6/6 pass

Test plan

  • CI green
  • nuke :secrets and nuke :update CLI surfaces still work as expected against a real Fallout-using repo
  • External consumer using the JsonSerializerSettings overloads sees [Obsolete] warnings pointing to the v11 cutover

🤖 Generated with Claude Code

…+ migrate 5 callers (#83)

Adds System.Text.Json parallel overloads to the JsonExtensions keystone and
migrates all 5 internal callers to the STJ surface.

JsonExtensions.cs surface:
- NEW: DefaultSerializerOptions (System.Text.Json equivalent of DefaultSerializerSettings)
- NEW: ToJson<T>(JsonSerializerOptions), GetJson<T>(JsonSerializerOptions)
- NEW: GetJsonObject(string) → JsonObject; ReadJsonObject(AbsolutePath) → JsonObject
- NEW: WriteJson<T>(AbsolutePath, T, JsonSerializerOptions),
       ReadJson<T>(AbsolutePath, JsonSerializerOptions),
       UpdateJson<T>(AbsolutePath, Action<T>, JsonSerializerOptions)
- NEW: UpdateJsonObject(AbsolutePath, Action<JsonObject>)
- [Obsolete] on all 7 Newtonsoft-typed methods (ToJson, GetJson×2, WriteJson,
  ReadJson×2, UpdateJson×2) — scheduled for v11 removal

STJ overloads require an explicit JsonSerializerOptions argument (no default)
to avoid C# overload-resolution ambiguity with the Newtonsoft no-args path.
Callers wanting framework defaults pass JsonExtensions.DefaultSerializerOptions.

Migrated callers (5):
- src/Fallout.Common/Tools/OctoVersion/OctoVersionTasks.cs — drops the
  AllWritableContractResolver workaround (STJ binds records via ctor)
- src/Fallout.Common/Attributes/HandleSingleFileExecutionAttribute.cs —
  global.json sdk.version lookup uses JsonObject + GetValue<string>
- src/Fallout.GlobalTool/Program.Secrets.cs — secret param read/write via
  JsonObject + Where on the IEnumerable<KeyValuePair<string, JsonNode>>
- src/Fallout.GlobalTool/Program.Setup.cs — parameters file write
- src/Fallout.GlobalTool/Program.Update.cs — global.json sdk.version write

Out of scope for this PR (still needs Newtonsoft):
- JObject.GetChildren.cs / JObject.GetPropertyValue.cs — used by the 3
  pragma-suppressed call sites from #165 (Mastodon, Slack, GitHubActions.Client);
  their migration is a separate v11 cutover
- AllWritableContractResolver, Base64JsonConverter — unused after the
  OctoVersionTasks migration but kept until the v11 cleanup
- Fallout.Tooling, Fallout.Tooling.Generator, Fallout.Build NJsonSchema swap,
  Fallout.Common runtime/Generated.cs files

Added System.Text.Json PackageReference to Fallout.Utilities.Text.Json.csproj.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ChrisonSimtian
ChrisonSimtian merged commit b6c40bc into main May 24, 2026
1 check passed
@ChrisonSimtian
ChrisonSimtian deleted the feature/83-jsonextensions-stj-keystone branch May 24, 2026 10:16
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