Skip to content

Commit 538c8fe

Browse files
qtuuPandaMagnus
andauthored
Using system.text.json instead of newtonsoft (#99)
* change dependency in project files * adapt usages * Update analyzers and exclude from pack (#100) * change dependency in project files * adapt usages * bump TestFramework package version to 1.1.3 Co-authored-by: Mike Curn <[email protected]>
1 parent b740235 commit 538c8fe

File tree

5 files changed

+7
-14
lines changed

5 files changed

+7
-14
lines changed

IntelliTect.TestTools.TestFramework/ExampleTests/ExampleTests/ExampleTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
<ItemGroup>
1010
<PackageReference Include="IntelliTect.TestTools.TestFramework" Version="1.1.1" />
11-
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
1211
<PackageReference Include="Selenium.WebDriver" Version="4.0.0-alpha01" />
12+
<PackageReference Include="System.Text.Json" Version="4.7.2" />
1313
<PackageReference Include="xunit" Version="2.3.1" />
1414
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
1515
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />

IntelliTect.TestTools.TestFramework/ExampleTests/ExampleTests/Harness/BasePage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Newtonsoft.Json;
1+
using System.Text.Json.Serialization;
22
using OpenQA.Selenium;
33

44
namespace ExampleTests.Harness

IntelliTect.TestTools.TestFramework/ExampleTests/ExampleTests/Harness/IntelliTectWebpage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
using Newtonsoft.Json;
2-
using OpenQA.Selenium;
1+
using OpenQA.Selenium;
2+
using System.Text.Json.Serialization;
33

44
namespace ExampleTests.Harness
55
{

IntelliTect.TestTools.TestFramework/IntelliTect.TestTools.TestFramework/IntelliTect.TestTools.TestFramework.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</PackageReference>
1414
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.2.0" />
1515
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
16-
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
16+
<PackageReference Include="System.Text.Json" Version="4.7.2" />
1717
</ItemGroup>
1818

1919
</Project>

IntelliTect.TestTools.TestFramework/IntelliTect.TestTools.TestFramework/TestBuilder.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using Microsoft.Extensions.DependencyInjection;
2-
using Newtonsoft.Json;
2+
using System.Text.Json;
33
using System;
44
using System.Collections.Generic;
55
using System.Diagnostics;
@@ -196,14 +196,7 @@ public void ExecuteTestCase()
196196

197197
private static string GetObjectDataAsJsonString(object obj)
198198
{
199-
try
200-
{
201-
return JsonConvert.SerializeObject(obj, Formatting.Indented, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects });
202-
}
203-
catch (JsonSerializationException e)
204-
{
205-
return $"Unable to serialize to JSON. Mark the relevant property or constructor with the [JsonIgnore] attribute: {e.Message}";
206-
}
199+
return JsonSerializer.Serialize(obj, new JsonSerializerOptions { WriteIndented = true });
207200
}
208201

209202
private object GetTestBlock(IServiceScope scope, Type tbType)

0 commit comments

Comments
 (0)