From 3ef86e124c63f0c9e2cfa86e530d95aeffd90a56 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 6 May 2026 19:10:01 +0100 Subject: [PATCH 1/3] Update packages and migrate from Newtonsoft.Json to System.Text.Json Bump Shared, Results, IntegrationTesting, and related NuGet packages to 2026.5.5. Update MessagingService.Client and ClientProxyBase versions. Remove Newtonsoft.Json and Microsoft.AspNetCore.Mvc.NewtonsoftJson dependencies. Refactor code to use System.Text.Json and Shared.Serialisation.StringSerialiser for all (de)serialization, affecting DTOs and integration tests. --- .../SecurityService.BusinessLogic.csproj | 4 ++-- .../SecurityService.Client.csproj | 4 ++-- .../Responses.cs | 23 +++++++++---------- ...SecurityService.DataTransferObjects.csproj | 2 +- ...yService.IntegrationTesting.Helpers.csproj | 2 +- .../ApiResource/ApiResourceSteps.cs | 1 - .../SecurityService.IntegrationTests.csproj | 2 +- .../Users/UsersSteps.cs | 1 - .../Common/DockerHelper.cs | 3 +-- .../ForgotPassword/ForgotPasswordSteps.cs | 4 ++-- ...vice.OpenIdConnect.IntegrationTests.csproj | 2 +- .../UserLogin/UserLoginSteps.cs | 6 ++--- SecurityService/SecurityService.csproj | 5 ++-- .../SecurityServiceTestUI.csproj | 2 +- 14 files changed, 28 insertions(+), 33 deletions(-) diff --git a/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj b/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj index 6c8f3d23..6b3cc2ce 100644 --- a/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj +++ b/SecurityService.BusinessLogic/SecurityService.BusinessLogic.csproj @@ -6,14 +6,14 @@ - + - + diff --git a/SecurityService.Client/SecurityService.Client.csproj b/SecurityService.Client/SecurityService.Client.csproj index 7447c44d..9259c32a 100644 --- a/SecurityService.Client/SecurityService.Client.csproj +++ b/SecurityService.Client/SecurityService.Client.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/SecurityService.DataTransferObjects/Responses.cs b/SecurityService.DataTransferObjects/Responses.cs index ea5d1dbc..4c94900d 100644 --- a/SecurityService.DataTransferObjects/Responses.cs +++ b/SecurityService.DataTransferObjects/Responses.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; -using System.Text.Json.Serialization; + +using System.Text.Json; namespace SecurityService.DataTransferObjects; @@ -100,21 +100,20 @@ public class TokenResponse public Int64 ExpiresIn { get; private set; } public DateTimeOffset Issued { get; private set; } public String RefreshToken { get; private set; } - public static TokenResponse Create(String token) - { - dynamic auth = JsonConvert.DeserializeObject(token); + public static TokenResponse Create(String token) { + using var doc = JsonDocument.Parse(token); + var root = doc.RootElement; - Int64 expiresIn = auth["expires_in"].Value; - String accessToken = auth["access_token"].Value; + long expiresIn = root.GetProperty("expires_in").GetInt64(); + string accessToken = root.GetProperty("access_token").GetString(); DateTimeOffset issued = DateTimeOffset.Now; - DateTimeOffset expires = DateTimeOffset.Now.AddSeconds(expiresIn); + DateTimeOffset expires = issued.AddSeconds(expiresIn); - String refreshToken = null; - //For client credentials, the refresh_token will not be present - if (auth["refresh_token"] != null) + string refreshToken = null; + if (root.TryGetProperty("refresh_token", out var refreshElement)) { - refreshToken = auth["refresh_token"].Value; + refreshToken = refreshElement.GetString(); } return TokenResponse.Create(accessToken, refreshToken, expiresIn, issued, expires); diff --git a/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj b/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj index f0f94722..759e34c5 100644 --- a/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj +++ b/SecurityService.DataTransferObjects/SecurityService.DataTransferObjects.csproj @@ -5,6 +5,6 @@ enable - + diff --git a/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj b/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj index 535f77b4..8c4bc8a8 100644 --- a/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj +++ b/SecurityService.IntegrationTesting.Helpers/SecurityService.IntegrationTesting.Helpers.csproj @@ -10,7 +10,7 @@ - + diff --git a/SecurityService.IntegrationTests/ApiResource/ApiResourceSteps.cs b/SecurityService.IntegrationTests/ApiResource/ApiResourceSteps.cs index e7a45200..b96938ec 100644 --- a/SecurityService.IntegrationTests/ApiResource/ApiResourceSteps.cs +++ b/SecurityService.IntegrationTests/ApiResource/ApiResourceSteps.cs @@ -12,7 +12,6 @@ namespace SecurityService.IntegrationTests.ApiResource using Clients; using IntegrationTesting.Helpers; using IntergrationTests.Common; - using Newtonsoft.Json; using Reqnroll; using Shouldly; diff --git a/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj b/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj index 0827d0a8..a28d4dab 100644 --- a/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj +++ b/SecurityService.IntegrationTests/SecurityService.IntegrationTests.csproj @@ -24,7 +24,7 @@ - + diff --git a/SecurityService.IntegrationTests/Users/UsersSteps.cs b/SecurityService.IntegrationTests/Users/UsersSteps.cs index 3a5bd5eb..f8a232bb 100644 --- a/SecurityService.IntegrationTests/Users/UsersSteps.cs +++ b/SecurityService.IntegrationTests/Users/UsersSteps.cs @@ -10,7 +10,6 @@ using Common; using DataTransferObjects; using IntegrationTesting.Helpers; - using Newtonsoft.Json; using Reqnroll; using Shouldly; diff --git a/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs b/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs index 34ff1742..01174999 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs @@ -8,7 +8,6 @@ namespace SecurityService.IntergrationTests.Common { using Client; - using Newtonsoft.Json; using Shared.HealthChecks; using Shared.IntegrationTesting; using Shared.Logger; @@ -119,7 +118,7 @@ await Retry.For(async () => { await this.HealthCheckClient.PerformHealthCheck("https", "127.0.0.1", this.SecurityServiceTestUIPort, CancellationToken.None); healthCheck.IsSuccess.ShouldBeTrue($"Health check for Test UI failed with [{healthCheck.Message}]"); - HealthCheckResult result = JsonConvert.DeserializeObject(healthCheck.Data); + HealthCheckResult result = StringSerialiser.Deserialise(healthCheck.Data); this.Trace($"health check complete for Test UI result is [{healthCheck}]"); diff --git a/SecurityService.OpenIdConnect.IntegrationTests/ForgotPassword/ForgotPasswordSteps.cs b/SecurityService.OpenIdConnect.IntegrationTests/ForgotPassword/ForgotPasswordSteps.cs index bfcea9e3..7de23f0f 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/ForgotPassword/ForgotPasswordSteps.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/ForgotPassword/ForgotPasswordSteps.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using Shared.Serialisation; namespace SecurityService.OpenIdConnect.IntegrationTests.ForgotPassword { @@ -11,7 +12,6 @@ namespace SecurityService.OpenIdConnect.IntegrationTests.ForgotPassword using System.Threading; using HtmlAgilityPack; using IntergrationTests.Common; - using Newtonsoft.Json; using OpenQA.Selenium; using Reqnroll; using SecurityService.IntegrationTests.UserLogin; @@ -87,7 +87,7 @@ public async Task ThenIGetAnEmailWithAForgotPasswordLink() { MessageId = Guid.Empty, Body = String.Empty }; - var x = JsonConvert.DeserializeAnonymousType(await response.Content.ReadAsStringAsync(CancellationToken.None), emailMessage); + var x = StringSerialiser.DeserialiseAnonymousType(await response.Content.ReadAsStringAsync(CancellationToken.None), emailMessage); var doc = new HtmlDocument(); doc.LoadHtml(x.Body); diff --git a/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj b/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj index bbf1025d..69277ac7 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj +++ b/SecurityService.OpenIdConnect.IntegrationTests/SecurityService.OpenIdConnect.IntegrationTests.csproj @@ -24,7 +24,7 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs b/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs index 3f42726d..c5a11682 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/UserLogin/UserLoginSteps.cs @@ -1,4 +1,5 @@ using System; +using Shared.Serialisation; namespace SecurityService.IntegrationTests.UserLogin { @@ -12,7 +13,6 @@ namespace SecurityService.IntegrationTests.UserLogin using System.Threading.Tasks; using HtmlAgilityPack; using IntergrationTests.Common; - using Newtonsoft.Json; using OpenQA.Selenium; using Reqnroll; using Shared.IntegrationTesting; @@ -112,7 +112,7 @@ public async Task ThenIGetAnEmailWithAConfirmEmailAddressLink() MessageId = Guid.Empty, Body = String.Empty }; - var x = JsonConvert.DeserializeAnonymousType(await response.Content.ReadAsStringAsync(CancellationToken.None), emailMessage); + var x = StringSerialiser.DeserialiseAnonymousType(await response.Content.ReadAsStringAsync(CancellationToken.None), emailMessage); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(x.Body); @@ -140,7 +140,7 @@ public async Task ThenIGetAWelcomeEmailWithMyLoginDetails() MessageId = Guid.Empty, Body = String.Empty }; - var x = JsonConvert.DeserializeAnonymousType(await response.Content.ReadAsStringAsync(CancellationToken.None), emailMessage); + var x = StringSerialiser.DeserialiseAnonymousType(await response.Content.ReadAsStringAsync(CancellationToken.None), emailMessage); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(x.Body); diff --git a/SecurityService/SecurityService.csproj b/SecurityService/SecurityService.csproj index 3d039bda..86993fe6 100644 --- a/SecurityService/SecurityService.csproj +++ b/SecurityService/SecurityService.csproj @@ -19,7 +19,6 @@ - @@ -33,8 +32,8 @@ - - + + diff --git a/SecurityServiceTestUI/SecurityServiceTestUI.csproj b/SecurityServiceTestUI/SecurityServiceTestUI.csproj index 2ed8e586..db57c900 100644 --- a/SecurityServiceTestUI/SecurityServiceTestUI.csproj +++ b/SecurityServiceTestUI/SecurityServiceTestUI.csproj @@ -11,7 +11,7 @@ - + From 1b8e932bd9f14aee2a52c242c10e1fe8a6ba69ff Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 6 May 2026 19:31:01 +0100 Subject: [PATCH 2/3] :| --- .../Common/DockerHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs b/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs index 01174999..513da601 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs @@ -56,7 +56,7 @@ public class DockerHelper : Shared.IntegrationTesting.TestContainers.DockerHelpe /// The logger. public DockerHelper() : base() { - + StringSerialiser.Initialise(new SerialiserOptions(SerialiserPropertyFormat.SnakeCase)); } #endregion From 712b6b2e1f4ae5abb3b7e381cb029f3827907073 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Wed, 6 May 2026 19:33:02 +0100 Subject: [PATCH 3/3] :| --- .../Common/DockerHelper.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs b/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs index 513da601..ebd68344 100644 --- a/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs +++ b/SecurityService.OpenIdConnect.IntegrationTests/Common/DockerHelper.cs @@ -4,6 +4,7 @@ using DotNet.Testcontainers.Networks; using Shared.IntegrationTesting.TestContainers; using System.Runtime.InteropServices; +using System.Text.Json; namespace SecurityService.IntergrationTests.Common { @@ -56,7 +57,7 @@ public class DockerHelper : Shared.IntegrationTesting.TestContainers.DockerHelpe /// The logger. public DockerHelper() : base() { - StringSerialiser.Initialise(new SerialiserOptions(SerialiserPropertyFormat.SnakeCase)); + StringSerialiser.Initialise(new SystemTextJsonSerializer(SystemTextJsonSerializer.GetDefaultJsonSerializerOptions())); } #endregion