Skip to content

Commit

Permalink
Replace Newtonsoft with Utf8Json (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanWold authored Aug 15, 2022
1 parent d97f75a commit 8ff0e59
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Metalsharp/Metalsharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

<ItemGroup>
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="Cryptisk.Utf8Json" Version="1.4.0" />
<PackageReference Include="Markdig" Version="0.30.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="YamlDotNet" Version="12.0.0" />
</ItemGroup>

Expand Down
4 changes: 1 addition & 3 deletions Metalsharp/MetalsharpFile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;

namespace Metalsharp;
Expand Down Expand Up @@ -48,7 +47,6 @@ public class MetalsharpFile
/// <param name="metadata">
/// The metadata of the file, stored as a string, object dictionary.
/// </param>
[JsonConstructor]
public MetalsharpFile(string text, string filePath, Dictionary<string, object> metadata)
{
Text = text;
Expand Down
4 changes: 3 additions & 1 deletion Metalsharp/MetalsharpProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using Metalsharp.Logging;

namespace Metalsharp;
Expand Down Expand Up @@ -82,7 +83,8 @@ public MetalsharpProject(MetalsharpConfiguration configuration = null)
/// <summary>
/// The logger.
/// </summary>
[Newtonsoft.Json.JsonIgnore]
//[Newtonsoft.Json.JsonIgnore]
[IgnoreDataMember]
public Log Log =>
_log ??= new Log(Configuration.Verbosity);
private Log _log;
Expand Down
7 changes: 3 additions & 4 deletions Metalsharp/Plugins/Branch/Branch.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Newtonsoft.Json;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using static Newtonsoft.Json.JsonConvert;
using Utf8Json;

namespace Metalsharp;

Expand Down Expand Up @@ -53,7 +52,7 @@ public Branch(params Action<MetalsharpProject>[] branches) =>
/// </param>
public void Execute(MetalsharpProject project) => _branches.ForEach(b =>
{
var projectClone = DeserializeObject<MetalsharpProject>(SerializeObject(project));
var projectClone = JsonSerializer.Deserialize<MetalsharpProject>(JsonSerializer.Serialize(project));
projectClone.Log.Debug("Executing new branch");
b(projectClone);
Expand Down
3 changes: 2 additions & 1 deletion Metalsharp/Plugins/Frontmatter/Frontmatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Utf8Json;

namespace Metalsharp;

Expand Down Expand Up @@ -181,7 +182,7 @@ private static bool TryGetJsonFrontmatter(string document, out Dictionary<string
{
try
{
var jsonFrontmatter = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, object>>(split[1].Trim());
var jsonFrontmatter = JsonSerializer.Deserialize<Dictionary<string, object>>(split[1].Trim());
var arrayRemainder = string.Join(";;;", split.Skip(2));

frontmatter = jsonFrontmatter;
Expand Down

0 comments on commit 8ff0e59

Please sign in to comment.