From 954b0861687b75e96aa57518a9d6cd6e346e9164 Mon Sep 17 00:00:00 2001 From: Chrison Simtian Date: Mon, 25 May 2026 11:40:54 +1200 Subject: [PATCH] =?UTF-8?q?feat(utilities.text.json)!:=20remove=20Newtonso?= =?UTF-8?q?ft=20surface=20=E2=80=94=20STJ-3=20of=20#83=20(#116)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BREAKING: Fallout.Utilities.Text.Json's [Obsolete]-marked Newtonsoft.Json surface (added in 10.3.x as parallel-deprecation overloads) is gone for v11. Deleted: - JObjectExtensions (GetChildren/GetPropertyValue/GetPropertyStringValue/ GetPropertyValueOrNull on Newtonsoft JObject) - AllWritableContractResolver - Base64JsonConverter - DefaultSerializerSettings + every JsonSerializerSettings overload of ToJson / GetJson / ReadJson / WriteJson / UpdateJson - JObject-returning GetJson / ReadJson / UpdateJson(Action) Kept: Object.ToJObject + Newtonsoft.Json PackageReference — last caller is Fallout.Tooling's JObject-typed InternalOptions, removed when STJ-4 (#117) lands. In-repo callers migrated: - GitHubActions.cs: PullRequestNumber/Action use direct Newtonsoft .Value() now. GitHubEvent stays JObject (separate API-break PR). - ProcessExtensions.StdToJson: direct JsonConvert.DeserializeObject — Fallout.Tooling is Newtonsoft-bound until #117. - OptionsTest + SettingsTest: same pattern (Options.JsonSerializerSettings is Newtonsoft; STJ equivalent moves with #117). Unblocks STJ-4 (#117), STJ-5 (#118), and the utility-lib-coupled tail of STJ-2 (#115). Full closure of #116 (delete Object.ToJObject + drop the Newtonsoft.Json PackageReference) is folded into #117. Co-Authored-By: Claude Opus 4.7 (1M context) --- CHANGELOG.md | 11 +- .../CI/GitHubActions/GitHubActions.cs | 7 +- src/Fallout.Tooling/ProcessExtensions.cs | 6 +- .../AllWritableContractResolver.cs | 26 --- .../Base64JsonConverter.cs | 32 ---- .../JObject.GetChildren.cs | 29 ---- .../JObject.GetPropertyValue.cs | 45 ----- .../JsonExtensions.cs | 163 ++---------------- tests/Fallout.Common.Tests/SettingsTest.cs | 10 +- tests/Fallout.Tooling.Tests/OptionsTest.cs | 6 +- 10 files changed, 38 insertions(+), 297 deletions(-) delete mode 100644 src/Fallout.Utilities.Text.Json/AllWritableContractResolver.cs delete mode 100644 src/Fallout.Utilities.Text.Json/Base64JsonConverter.cs delete mode 100644 src/Fallout.Utilities.Text.Json/JObject.GetChildren.cs delete mode 100644 src/Fallout.Utilities.Text.Json/JObject.GetPropertyValue.cs diff --git a/CHANGELOG.md b/CHANGELOG.md index ff4f9d0fb..2683737ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [10.3.0] / 2026-05-22 +## [Unreleased] — 11.0 + +### Breaking changes +- **`Fallout.Utilities.Text.Json` Newtonsoft surface removed** (#116, STJ-3 of #83). The `[Obsolete]`-marked Newtonsoft.Json overloads added in 10.3.x are gone: + - **Deleted types:** `JObjectExtensions` (`GetChildren`/`GetPropertyValue`/`GetPropertyStringValue`/`GetPropertyValueOrNull` on `JObject`), `AllWritableContractResolver`, `Base64JsonConverter`. + - **`JsonExtensions` stripped to System.Text.Json only**: `DefaultSerializerSettings` removed (use `DefaultSerializerOptions`); the `JsonSerializerSettings`-taking overloads of `ToJson` / `GetJson` / `ReadJson` / `WriteJson` / `UpdateJson` and the `JObject`-returning `GetJson`/`ReadJson`/`UpdateJson(Action)` are gone. Equivalent STJ surface: same method names taking `JsonSerializerOptions` (now defaulted to `DefaultSerializerOptions` when omitted), plus `GetJsonObject` / `ReadJsonObject` / `UpdateJsonObject(Action)` for `JsonNode`-based access. + - **Migration**: replace `obj.ToJson(settings)` with `obj.ToJson(JsonExtensions.DefaultSerializerOptions)` (or pass your own `JsonSerializerOptions`); replace `content.GetJson()` with `content.GetJsonObject()`; replace `JObject.GetPropertyValue(name)` with `JsonObject.GetPropertyValue(name)` (same method name, different receiver type via `using System.Text.Json.Nodes`). + - **Still pending**: `Object.ToJObject` and the `Newtonsoft.Json` `PackageReference` remain in `Fallout.Utilities.Text.Json` until STJ-4 (Fallout.Tooling, #117) lands — `Fallout.Tooling.Options.InternalOptions` is typed `JObject` and drives the last caller. + + - **Fixed `Fallout.SolutionModel` 10.2.24–10.2.34 unrestorable** (#107): the vendored SolutionPersistence wrapper was `IsPackable=false`, so `dotnet pack` fell back to emitting the dependency under the *assembly* name (`Microsoft.VisualStudio.SolutionPersistence`) at the Fallout version — which doesn't exist on nuget.org. Wrapper now packs as `Fallout.VisualStudio.SolutionPersistence` (PackageId set explicitly; `AssemblyName` preserved for drop-in type identity), so `Fallout.SolutionModel.nuspec` declares the correct transitive dep. Also affected `Fallout.Common`, `Fallout.Build`, `Fallout.ProjectModel`, `Fallout.Components` — all fixed. - **`--skip-duplicate` on the publish push** (#108): release.yml's `IPublish.PushSettings` now enables skip-duplicate, so a partial publish failure (e.g. one package's API key permission gap) no longer makes reruns error on the already-uploaded versions. Pipeline is idempotent. - **Fixed `build.ps1` bootstrap on PowerShell 7.5+** (#15): the script now uses `Join-Path` for SDK resolution so newer PowerShell's stricter path handling doesn't break the launcher. diff --git a/src/Fallout.Common/CI/GitHubActions/GitHubActions.cs b/src/Fallout.Common/CI/GitHubActions/GitHubActions.cs index 5f2e13e36..d82373cee 100644 --- a/src/Fallout.Common/CI/GitHubActions/GitHubActions.cs +++ b/src/Fallout.Common/CI/GitHubActions/GitHubActions.cs @@ -114,10 +114,9 @@ internal GitHubActions() public JObject GitHubEvent => _eventContext.Value; public bool IsPullRequest => EventName == "pull_request"; -#pragma warning disable CS0618 // JObjectExtensions retires in v11; PullRequestNumber/Action follow when GitHubEvent migrates to JsonObject (API-break, separate PR). - public int? PullRequestNumber => GitHubEvent.GetPropertyValue("number"); - public string PullRequestAction => GitHubEvent.GetPropertyStringValue("action"); -#pragma warning restore CS0618 + // Note: GitHubEvent stays JObject (Newtonsoft) public surface for v11; full JsonObject migration is a separate API-break PR. + public int? PullRequestNumber => GitHubEvent.Property("number")?.Value.Value(); + public string PullRequestAction => GitHubEvent.Property("action")?.Value.Value(); public AbsolutePath StepSummaryFile => EnvironmentInfo.GetVariable("GITHUB_STEP_SUMMARY"); diff --git a/src/Fallout.Tooling/ProcessExtensions.cs b/src/Fallout.Tooling/ProcessExtensions.cs index 0bf06a77b..04e799bd4 100644 --- a/src/Fallout.Tooling/ProcessExtensions.cs +++ b/src/Fallout.Tooling/ProcessExtensions.cs @@ -7,6 +7,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Fallout.Common.Utilities; @@ -52,9 +53,8 @@ public static string StdToText(this IEnumerable output) public static T StdToJson(this IEnumerable output) { -#pragma warning disable CS0618 // GetJson(Newtonsoft) retires in v11; this whole StdToJson surface is part of the Fallout.Tooling migration follow-up. - return output.StdToText().GetJson(); -#pragma warning restore CS0618 + // Fallout.Tooling stays on Newtonsoft until STJ-4 (#117); call Newtonsoft directly instead of through the util lib. + return JsonConvert.DeserializeObject(output.StdToText()); } public static JObject StdToJson(this IEnumerable output) diff --git a/src/Fallout.Utilities.Text.Json/AllWritableContractResolver.cs b/src/Fallout.Utilities.Text.Json/AllWritableContractResolver.cs deleted file mode 100644 index f8a1a7bab..000000000 --- a/src/Fallout.Utilities.Text.Json/AllWritableContractResolver.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2026 Maintainers of Fallout. -// Originally based on NUKE by Matthias Koch and contributors. -// Distributed under the MIT License. -// https://github.com/ChrisonSimtian/Fallout/blob/main/LICENSE - -using System; -using System.Linq; -using System.Reflection; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; - -namespace Fallout.Common.Tooling; - -/// -/// Treats all properties as writable. -/// -[Obsolete("Newtonsoft-specific contract resolver. System.Text.Json handles records and init-only properties natively, so this workaround is unnecessary on the STJ path. Scheduled for removal in v11 (#83).")] -internal class AllWritableContractResolver : DefaultContractResolver -{ - protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) - { - var property = base.CreateProperty(member, memberSerialization); - property.Writable = true; - return property; - } -} diff --git a/src/Fallout.Utilities.Text.Json/Base64JsonConverter.cs b/src/Fallout.Utilities.Text.Json/Base64JsonConverter.cs deleted file mode 100644 index d4875f3bd..000000000 --- a/src/Fallout.Utilities.Text.Json/Base64JsonConverter.cs +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2026 Maintainers of Fallout. -// Originally based on NUKE by Matthias Koch and contributors. -// Distributed under the MIT License. -// https://github.com/ChrisonSimtian/Fallout/blob/main/LICENSE - -using System; -using System.ComponentModel; -using System.Globalization; -using System.Text; -using Newtonsoft.Json; - -namespace Fallout.Utilities.Text.Json; - -[Obsolete("Newtonsoft-specific Base64 JSON type converter with zero internal callers. Scheduled for removal in v11 (#83); consumers needing this should pin Newtonsoft.Json directly.")] -public class Base64JsonConverter : TypeConverter -{ - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) - { - if (value is string base64Json) - { - var json = Encoding.UTF8.GetString(Convert.FromBase64String(base64Json)); - return JsonConvert.DeserializeObject(json); - } - - return base.ConvertFrom(context, culture, value); - } - - public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType) - { - return false; - } -} diff --git a/src/Fallout.Utilities.Text.Json/JObject.GetChildren.cs b/src/Fallout.Utilities.Text.Json/JObject.GetChildren.cs deleted file mode 100644 index b663e298b..000000000 --- a/src/Fallout.Utilities.Text.Json/JObject.GetChildren.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2026 Maintainers of Fallout. -// Originally based on NUKE by Matthias Koch and contributors. -// Distributed under the MIT License. -// https://github.com/ChrisonSimtian/Fallout/blob/main/LICENSE - -using System; -using Newtonsoft.Json.Linq; - -namespace Fallout.Common.Utilities; - -public static partial class JObjectExtensions -{ - [Obsolete("Use the JsonObject overload in JsonNodeExtensions instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static JEnumerable GetChildren(this JObject jobject, string name) - where T : JToken - { -#pragma warning disable CS0618 // Newtonsoft helpers retire together. - return jobject.GetPropertyValue(name).Children(); -#pragma warning restore CS0618 - } - - [Obsolete("Use the JsonObject overload in JsonNodeExtensions instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static JEnumerable GetChildren(this JObject jobject, string name) - { -#pragma warning disable CS0618 // Newtonsoft helpers retire together. - return jobject.GetChildren(name); -#pragma warning restore CS0618 - } -} diff --git a/src/Fallout.Utilities.Text.Json/JObject.GetPropertyValue.cs b/src/Fallout.Utilities.Text.Json/JObject.GetPropertyValue.cs deleted file mode 100644 index 76455d404..000000000 --- a/src/Fallout.Utilities.Text.Json/JObject.GetPropertyValue.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2026 Maintainers of Fallout. -// Originally based on NUKE by Matthias Koch and contributors. -// Distributed under the MIT License. -// https://github.com/ChrisonSimtian/Fallout/blob/main/LICENSE - -using System; -using System.Linq; -using Newtonsoft.Json.Linq; - -namespace Fallout.Common.Utilities; - -public static partial class JObjectExtensions -{ - [Obsolete("Use the JsonObject overload in JsonNodeExtensions instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static T GetPropertyValueOrNull(this JObject jobject, string name) - { - var property = jobject.Property(name); - return property != null - ? property.Value.Value() - : default; - } - - [Obsolete("Use the JsonObject overload in JsonNodeExtensions instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static T GetPropertyValue(this JObject jobject, string name) - { - var property = jobject.Property(name).NotNull($"Property '{name}' not found"); - return property.Value.Value(); - } - - [Obsolete("Use the JsonObject overload in JsonNodeExtensions instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static JObject GetPropertyValue(this JObject jobject, string name) - { -#pragma warning disable CS0618 // Newtonsoft helpers retire together. - return jobject.GetPropertyValue(name); -#pragma warning restore CS0618 - } - - [Obsolete("Use the JsonObject overload in JsonNodeExtensions instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static string GetPropertyStringValue(this JObject jobject, string name) - { -#pragma warning disable CS0618 // Newtonsoft helpers retire together. - return jobject.GetPropertyValue(name); -#pragma warning restore CS0618 - } -} diff --git a/src/Fallout.Utilities.Text.Json/JsonExtensions.cs b/src/Fallout.Utilities.Text.Json/JsonExtensions.cs index 537922c0b..a9369b22b 100644 --- a/src/Fallout.Utilities.Text.Json/JsonExtensions.cs +++ b/src/Fallout.Utilities.Text.Json/JsonExtensions.cs @@ -4,30 +4,15 @@ // https://github.com/ChrisonSimtian/Fallout/blob/main/LICENSE using System; -using System.Linq; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using Fallout.Common.IO; -using Fallout.Common.Tooling; namespace Fallout.Common.Utilities; public static class JsonExtensions { - [Obsolete("Use DefaultSerializerOptions (JsonSerializerOptions) instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] -#pragma warning disable CS0618 // AllWritableContractResolver retires alongside. - public static JsonSerializerSettings DefaultSerializerSettings = - new() - { - NullValueHandling = NullValueHandling.Ignore, - DefaultValueHandling = DefaultValueHandling.Ignore, - ContractResolver = new AllWritableContractResolver() - }; -#pragma warning restore CS0618 - public static JsonSerializerOptions DefaultSerializerOptions { get; } = new() { @@ -36,133 +21,20 @@ public static class JsonExtensions PropertyNameCaseInsensitive = true, }; - // ───────────────────────────────────────────────────────────────────── - // Newtonsoft surface — [Obsolete] for v11 removal as part of #83. - // ───────────────────────────────────────────────────────────────────── - - /// - /// Serializes an object as JSON string via Newtonsoft.Json. - /// - [Obsolete("Use the JsonSerializerOptions overload instead. Newtonsoft.Json surface is scheduled for removal in v11 as part of the System.Text.Json migration (#83).")] - public static string ToJson( - this T obj, - JsonSerializerSettings serializerSettings = null, - Formatting formatting = Formatting.Indented) - { -#pragma warning disable CS0618 // DefaultSerializerSettings retires alongside. - return JsonConvert.SerializeObject(obj, formatting, serializerSettings ?? DefaultSerializerSettings); -#pragma warning restore CS0618 - } - - /// - /// Deserializes an object from a JSON string via Newtonsoft.Json. - /// - [Obsolete("Use the JsonSerializerOptions overload instead. Newtonsoft.Json surface is scheduled for removal in v11 as part of the System.Text.Json migration (#83).")] - public static T GetJson(this string content, JsonSerializerSettings serializerSettings = null) - { -#pragma warning disable CS0618 // DefaultSerializerSettings retires alongside. - return JsonConvert.DeserializeObject(content, serializerSettings ?? DefaultSerializerSettings); -#pragma warning restore CS0618 - } - - /// - /// Deserializes a Newtonsoft from a JSON string. - /// - [Obsolete("Use GetJsonObject (returns System.Text.Json.Nodes.JsonObject) instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static JObject GetJson(this string content, JsonSerializerSettings serializerSettings = null) - { -#pragma warning disable CS0618 // Self-call into the obsolete generic overload; both retire together in v11. - return content.GetJson(serializerSettings); -#pragma warning restore CS0618 - } - - /// - /// Serializes an object as JSON to a file via Newtonsoft.Json. - /// - [Obsolete("Use the JsonSerializerOptions overload instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static AbsolutePath WriteJson(this AbsolutePath path, T obj, JsonSerializerSettings serializerSettings) - { -#pragma warning disable CS0618 // ToJson (Newtonsoft overload) retires alongside. - var content = obj.ToJson(serializerSettings); -#pragma warning restore CS0618 - return path.WriteAllText(content); - } - - /// - /// Deserializes an object as JSON from a file via Newtonsoft.Json. - /// - [Obsolete("Use the JsonSerializerOptions overload instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static T ReadJson(this AbsolutePath path, JsonSerializerSettings serializerSettings) - { - var content = path.ReadAllText(); -#pragma warning disable CS0618 // GetJson (Newtonsoft overload) retires alongside. - return content.GetJson(serializerSettings); -#pragma warning restore CS0618 - } - - /// - /// Deserializes a Newtonsoft from a file. - /// - [Obsolete("Use ReadJsonObject (returns System.Text.Json.Nodes.JsonObject) instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static JObject ReadJson(this AbsolutePath path, JsonSerializerSettings serializerSettings = null) - { -#pragma warning disable CS0618 // ReadJson(Newtonsoft) retires alongside. - return path.ReadJson(serializerSettings); -#pragma warning restore CS0618 - } - - /// - /// Deserializes an object as JSON from a file, applies updates, and serializes it back via Newtonsoft.Json. - /// - [Obsolete("Use the JsonSerializerOptions overload instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static AbsolutePath UpdateJson( - this AbsolutePath path, - Action update, - JsonSerializerSettings serializerSettings = null) - { - var before = path.ReadAllText(); -#pragma warning disable CS0618 // Newtonsoft helpers retire together. - var obj = before.GetJson(serializerSettings); - update.Invoke(obj); - var after = obj.ToJson(serializerSettings); -#pragma warning restore CS0618 - return path.WriteAllText(after); - } - - /// - /// Deserializes a Newtonsoft from a file, applies updates, and writes it back. - /// - [Obsolete("Use UpdateJsonObject (takes Action) instead. Newtonsoft.Json surface is scheduled for removal in v11 (#83).")] - public static AbsolutePath UpdateJson( - this AbsolutePath path, - Action update, - JsonSerializerSettings serializerSettings = null) - { -#pragma warning disable CS0618 // UpdateJson(Newtonsoft) retires alongside. - return path.UpdateJson(update, serializerSettings); -#pragma warning restore CS0618 - } - - // ───────────────────────────────────────────────────────────────────── - // System.Text.Json surface — preferred. STJ overloads require explicit - // JsonSerializerOptions to avoid ambiguity with the Newtonsoft no-args - // path; callers wanting framework defaults should pass DefaultSerializerOptions. - // ───────────────────────────────────────────────────────────────────── - /// /// Serializes an object as JSON string via System.Text.Json. /// - public static string ToJson(this T obj, JsonSerializerOptions options) + public static string ToJson(this T obj, JsonSerializerOptions options = null) { - return System.Text.Json.JsonSerializer.Serialize(obj, options ?? DefaultSerializerOptions); + return JsonSerializer.Serialize(obj, options ?? DefaultSerializerOptions); } /// /// Deserializes an object from a JSON string via System.Text.Json. /// - public static T GetJson(this string content, JsonSerializerOptions options) + public static T GetJson(this string content, JsonSerializerOptions options = null) { - return System.Text.Json.JsonSerializer.Deserialize(content, options ?? DefaultSerializerOptions); + return JsonSerializer.Deserialize(content, options ?? DefaultSerializerOptions); } /// @@ -176,19 +48,17 @@ public static JsonObject GetJsonObject(this string content, JsonNodeOptions? nod /// /// Serializes an object as JSON to a file via System.Text.Json. /// - public static AbsolutePath WriteJson(this AbsolutePath path, T obj, JsonSerializerOptions options) + public static AbsolutePath WriteJson(this AbsolutePath path, T obj, JsonSerializerOptions options = null) { - var content = obj.ToJson(options); - return path.WriteAllText(content); + return path.WriteAllText(obj.ToJson(options)); } /// /// Deserializes an object as JSON from a file via System.Text.Json. /// - public static T ReadJson(this AbsolutePath path, JsonSerializerOptions options) + public static T ReadJson(this AbsolutePath path, JsonSerializerOptions options = null) { - var content = path.ReadAllText(); - return content.GetJson(options); + return path.ReadAllText().GetJson(options); } /// @@ -196,20 +66,17 @@ public static T ReadJson(this AbsolutePath path, JsonSerializerOptions option /// public static JsonObject ReadJsonObject(this AbsolutePath path, JsonNodeOptions? nodeOptions = null) { - var content = path.ReadAllText(); - return content.GetJsonObject(nodeOptions); + return path.ReadAllText().GetJsonObject(nodeOptions); } /// /// Deserializes from a file, applies updates, and writes back — System.Text.Json variant. /// - public static AbsolutePath UpdateJson(this AbsolutePath path, Action update, JsonSerializerOptions options) + public static AbsolutePath UpdateJson(this AbsolutePath path, Action update, JsonSerializerOptions options = null) { - var before = path.ReadAllText(); - var obj = before.GetJson(options); + var obj = path.ReadJson(options); update.Invoke(obj); - var after = obj.ToJson(options); - return path.WriteAllText(after); + return path.WriteJson(obj, options); } /// @@ -220,10 +87,8 @@ public static AbsolutePath UpdateJsonObject( Action update, JsonNodeOptions? nodeOptions = null) { - var content = path.ReadAllText(); - var obj = JsonNode.Parse(content, nodeOptions: nodeOptions)?.AsObject() ?? new JsonObject(); + var obj = path.ReadJsonObject(nodeOptions) ?? new JsonObject(); update.Invoke(obj); - var after = obj.ToJsonString(new JsonSerializerOptions { WriteIndented = true }); - return path.WriteAllText(after); + return path.WriteAllText(obj.ToJsonString(DefaultSerializerOptions)); } } diff --git a/tests/Fallout.Common.Tests/SettingsTest.cs b/tests/Fallout.Common.Tests/SettingsTest.cs index 281945c2f..cf546f455 100644 --- a/tests/Fallout.Common.Tests/SettingsTest.cs +++ b/tests/Fallout.Common.Tests/SettingsTest.cs @@ -8,6 +8,7 @@ using System.Linq; using System.Threading.Tasks; using FluentAssertions; +using Newtonsoft.Json; using Fallout.Common.Tools.MSBuild; using Fallout.Common.Tools.OpenCover; using Fallout.Common.Tools.Xunit; @@ -173,16 +174,15 @@ public void TestDocker() [Fact] public Task TestDiscord() { -#pragma warning disable CS0618 // Test pins Options.JsonSerializerSettings round-trip; STJ equivalents follow in Fallout.Tooling's #83 migration. - var result = new DiscordMessage() + // Options.JsonSerializerSettings is Newtonsoft; STJ equivalent lands with Fallout.Tooling's STJ-4 migration (#117). + var message = new DiscordMessage() .SetNonce("nonce") .SetChannelId("channel-id") .AddEmbeds(_ => _ .SetType(DiscordEmbedType.article) .SetAuthor(_ => _ - .SetName("author-name"))) - .ToJson(Options.JsonSerializerSettings); -#pragma warning restore CS0618 + .SetName("author-name"))); + var result = JsonConvert.SerializeObject(message, Formatting.Indented, Options.JsonSerializerSettings); return Verifier.Verify(result); } diff --git a/tests/Fallout.Tooling.Tests/OptionsTest.cs b/tests/Fallout.Tooling.Tests/OptionsTest.cs index 2b74cd19d..9a7c4e41c 100644 --- a/tests/Fallout.Tooling.Tests/OptionsTest.cs +++ b/tests/Fallout.Tooling.Tests/OptionsTest.cs @@ -10,6 +10,7 @@ using System.Linq; using System.Threading.Tasks; using FluentAssertions; +using Newtonsoft.Json; using Fallout.Common.Tooling; using Fallout.Common.Utilities; using Fallout.Common.Utilities.Collections; @@ -147,9 +148,8 @@ public Task TestSerialization() options.Set(() => LookupValue, new LookupTable { ["key"] = new[] { 1, 2, 3 } }); options.Set(() => NestedValue, options); -#pragma warning disable CS0618 // Test pins Options.JsonSerializerSettings round-trip; STJ equivalents follow in Fallout.Tooling's #83 migration. - return Verifier.Verify(options.ToJson(Options.JsonSerializerSettings)); -#pragma warning restore CS0618 + // Options.JsonSerializerSettings is Newtonsoft; STJ equivalent lands with Fallout.Tooling's STJ-4 migration (#117). + return Verifier.Verify(JsonConvert.SerializeObject(options, Formatting.Indented, Options.JsonSerializerSettings)); } }