diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..5db9340 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,27 @@ + + + true + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 4a44902..9f63e20 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -18,6 +18,6 @@ - + diff --git a/src/SIL.Harmony.Core/SIL.Harmony.Core.csproj b/src/SIL.Harmony.Core/SIL.Harmony.Core.csproj index acdee42..b390362 100644 --- a/src/SIL.Harmony.Core/SIL.Harmony.Core.csproj +++ b/src/SIL.Harmony.Core/SIL.Harmony.Core.csproj @@ -9,9 +9,9 @@ - - - + + + diff --git a/src/SIL.Harmony.Linq2db/SIL.Harmony.Linq2db.csproj b/src/SIL.Harmony.Linq2db/SIL.Harmony.Linq2db.csproj index 753f30e..d530422 100644 --- a/src/SIL.Harmony.Linq2db/SIL.Harmony.Linq2db.csproj +++ b/src/SIL.Harmony.Linq2db/SIL.Harmony.Linq2db.csproj @@ -10,8 +10,8 @@ - - + + diff --git a/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt b/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt index 32ce952..219be98 100644 --- a/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt +++ b/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt @@ -151,4 +151,4 @@ Relational:ViewName: Relational:ViewSchema: Annotations: - ProductVersion: 8.0.4 \ No newline at end of file + ProductVersion: 8.0.11 \ No newline at end of file diff --git a/src/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj b/src/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj index c5b24ee..115f200 100644 --- a/src/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj +++ b/src/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj @@ -7,27 +7,27 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + diff --git a/src/SIL.Harmony/SIL.Harmony.csproj b/src/SIL.Harmony/SIL.Harmony.csproj index 6bb7e63..8771fa5 100644 --- a/src/SIL.Harmony/SIL.Harmony.csproj +++ b/src/SIL.Harmony/SIL.Harmony.csproj @@ -10,11 +10,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/src/Ycs/Structs/ContentJson.cs b/src/Ycs/Structs/ContentJson.cs index 48f8698..dc4fe51 100644 --- a/src/Ycs/Structs/ContentJson.cs +++ b/src/Ycs/Structs/ContentJson.cs @@ -4,7 +4,11 @@ // // ------------------------------------------------------------------------------ +using System.Collections.ObjectModel; using System.Diagnostics; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Text.Json.Serialization; namespace Ycs { @@ -12,14 +16,14 @@ public class ContentJson : IContentEx { internal const int _ref = 2; - private readonly List _content; + private readonly List _content; - internal ContentJson(IEnumerable data) + internal ContentJson(IEnumerable data) { - _content = new List(data); + _content = new List(data); } - private ContentJson(List other) + private ContentJson(List other) { _content = other; } @@ -29,7 +33,7 @@ private ContentJson(List other) public bool Countable => true; public int Length => _content?.Count ?? 0; - public IReadOnlyList GetContent() => _content.AsReadOnly(); + public IReadOnlyList GetContent() => new ReadOnlyCollection(_content.OfType().ToList()); public IContent Copy() => new ContentJson(_content); @@ -68,7 +72,7 @@ void IContentEx.Write(IUpdateEncoder encoder, int offset) encoder.WriteLength(len); for (int i = offset; i < len; i++) { - var jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(_content[i]); + var jsonStr = JsonSerializer.Serialize(_content[i]); encoder.WriteString(jsonStr); } } @@ -76,14 +80,14 @@ void IContentEx.Write(IUpdateEncoder encoder, int offset) internal static ContentJson Read(IUpdateDecoder decoder) { var len = decoder.ReadLength(); - var content = new List(len); + var content = new List(len); for (int i = 0; i < len; i++) { var jsonStr = decoder.ReadString(); - object jsonObj = string.Equals(jsonStr, "undefined") + JsonNode jsonObj = string.Equals(jsonStr, "undefined") ? null - : Newtonsoft.Json.JsonConvert.DeserializeObject(jsonStr); + : JsonSerializer.Deserialize(jsonStr); content.Add(jsonObj); } diff --git a/src/Ycs/Utils/UpdateDecoderV2.cs b/src/Ycs/Utils/UpdateDecoderV2.cs index d29344d..d4860ae 100644 --- a/src/Ycs/Utils/UpdateDecoderV2.cs +++ b/src/Ycs/Utils/UpdateDecoderV2.cs @@ -5,6 +5,8 @@ // ------------------------------------------------------------------------------ using System.Diagnostics; +using System.Text.Json; +using System.Text.Json.Nodes; namespace Ycs { @@ -197,7 +199,7 @@ public object ReadJson() CheckDisposed(); var jsonString = Reader.ReadVarString(); - var result = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString); + var result = JsonSerializer.Deserialize(jsonString); return result; } diff --git a/src/Ycs/Utils/UpdateEncoderV2.cs b/src/Ycs/Utils/UpdateEncoderV2.cs index 918bf9e..56a3554 100644 --- a/src/Ycs/Utils/UpdateEncoderV2.cs +++ b/src/Ycs/Utils/UpdateEncoderV2.cs @@ -5,6 +5,7 @@ // ------------------------------------------------------------------------------ using System.Diagnostics; +using System.Text.Json; namespace Ycs { @@ -201,7 +202,7 @@ public void WriteKey(string key) public void WriteJson(T any) { - var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(any, typeof(T), null); + var jsonString = JsonSerializer.Serialize(any); RestWriter.WriteVarString(jsonString); } diff --git a/src/Ycs/Ycs.csproj b/src/Ycs/Ycs.csproj index f0e667e..3d1f59e 100644 --- a/src/Ycs/Ycs.csproj +++ b/src/Ycs/Ycs.csproj @@ -15,7 +15,7 @@ true - +