feat(utilities.text.json): STJ overloads for keystone JsonExtensions + migrate 5 callers (#83) - #166
Merged
Conversation
…+ 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>
3 tasks
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.
Summary
Adds System.Text.Json parallel overloads to the
JsonExtensionskeystone 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 ofDefaultSerializerSettings)ToJson<T>(JsonSerializerOptions),GetJson<T>(JsonSerializerOptions)GetJsonObject(string) → JsonObject,ReadJsonObject(AbsolutePath) → JsonObjectWriteJson<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?) → JObjectWriteJson<T>(JsonSerializerSettings?),ReadJson<T>(JsonSerializerSettings?),ReadJson(JsonSerializerSettings?) → JObjectUpdateJson<T>(Action<T>, JsonSerializerSettings?),UpdateJson(Action<JObject>, JsonSerializerSettings?)STJ overloads require an explicit
JsonSerializerOptionsargument (no default) to avoid overload-resolution ambiguity with the Newtonsoft no-args path. Callers wanting framework defaults passJsonExtensions.DefaultSerializerOptions.Migrated callers (5)
Tools/OctoVersion/OctoVersionTasks.csAllWritableContractResolverworkaround (STJ binds records via ctor natively)Attributes/HandleSingleFileExecutionAttribute.csglobal.json sdk.versionlookup usesJsonObject + GetValue<string>GlobalTool/Program.Secrets.csJsonObject+Whereon theIEnumerable<KeyValuePair<string, JsonNode>>it implementsGlobalTool/Program.Setup.csGlobalTool/Program.Update.csglobal.json sdk.versionwriteDrops
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 theOctoVersionTasksmigration but kept until the v11 cleanup (external consumers may still reference them).Fallout.Tooling,Fallout.Tooling.Generator,Fallout.Build(NJsonSchema swap), the bulk ofFallout.Commonruntime + ~60Tools/*/*.Generated.csfiles.Added
System.Text.JsonPackageReference toFallout.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 errorsdotnet build src/Fallout.Common/Fallout.Common.csproj— 0 errors (callers migrated cleanly)dotnet build src/Fallout.GlobalTool/Fallout.GlobalTool.csproj— 0 errorsdotnet build fallout.slnx— 0 errors across the whole solutiondotnet test tests/Fallout.SourceGenerators.Tests/Fallout.SourceGenerators.Tests.csproj— 6/6 passTest plan
nuke :secretsandnuke :updateCLI surfaces still work as expected against a real Fallout-using repoJsonSerializerSettingsoverloads sees[Obsolete]warnings pointing to the v11 cutover🤖 Generated with Claude Code