From 4fe848e80d9e5194c21184cd9c19208dd2d53e77 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 13 Nov 2024 10:35:50 +0700 Subject: [PATCH 1/7] setup central package management and update package versions --- Directory.Packages.props | 26 +++++++++++++++++++ src/Directory.Build.props | 2 +- src/SIL.Harmony.Core/SIL.Harmony.Core.csproj | 6 ++--- .../SIL.Harmony.Tests.csproj | 24 ++++++++--------- src/SIL.Harmony/SIL.Harmony.csproj | 4 +-- 5 files changed, 44 insertions(+), 18 deletions(-) create mode 100644 Directory.Packages.props diff --git a/Directory.Packages.props b/Directory.Packages.props new file mode 100644 index 0000000..85b64c3 --- /dev/null +++ b/Directory.Packages.props @@ -0,0 +1,26 @@ + + + true + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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.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 - + From 1a4118049eb166751346daa72f5f7c6534af13b3 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 13 Nov 2024 11:13:32 +0700 Subject: [PATCH 2/7] replace linq2db package references with versions --- Directory.Packages.props | 49 ++++++++++--------- .../SIL.Harmony.Linq2db.csproj | 4 +- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 85b64c3..68959fb 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,26 +1,27 @@ - - true - - - - - - - - - - - - - - - - - - - - - - + + true + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file 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 @@ - - + + From 0e33804219fb186d9ea1f351310f789ac58d9980 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 13 Nov 2024 11:13:51 +0700 Subject: [PATCH 3/7] change ycs to use system.text.json instead of newtonsoft json --- src/Ycs/Structs/ContentJson.cs | 22 +++++++++++++--------- src/Ycs/Utils/UpdateDecoderV2.cs | 4 +++- src/Ycs/Utils/UpdateEncoderV2.cs | 3 ++- src/Ycs/Ycs.csproj | 2 +- 4 files changed, 19 insertions(+), 12 deletions(-) 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 - + From d2b01b1b687ef83845980a70031ebc49f827a0fb Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 13 Nov 2024 11:20:21 +0700 Subject: [PATCH 4/7] update linq2db version to support EF 9 --- Directory.Packages.props | 4 ++-- src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 68959fb..73342d9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -21,7 +21,7 @@ - - + + \ No newline at end of file diff --git a/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt b/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt index 32ce952..1eb5c1e 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: 9.0.0 \ No newline at end of file From 7d0a3efe5f99a7c92de37309a1a2e3abe4171cf4 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Tue, 19 Nov 2024 10:34:22 +0700 Subject: [PATCH 5/7] update linq2db efcore to the ef core 9 version --- Directory.Packages.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 73342d9..9fbfdf7 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -22,6 +22,6 @@ - + \ No newline at end of file From c13987d13f7fa4c37e0ebdd28b04e42a31df7e4c Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 27 Nov 2024 16:20:30 +0700 Subject: [PATCH 6/7] rollback to EF 8 --- Directory.Packages.props | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 9fbfdf7..5db9340 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,9 +3,9 @@ true - - - + + + @@ -22,6 +22,6 @@ - + - \ No newline at end of file + From 6b7619c3d6bf433bda590c7d6d853e1160b38093 Mon Sep 17 00:00:00 2001 From: Kevin Hahn Date: Wed, 27 Nov 2024 16:40:41 +0700 Subject: [PATCH 7/7] fix verification test --- src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt b/src/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txt index 1eb5c1e..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: 9.0.0 \ No newline at end of file + ProductVersion: 8.0.11 \ No newline at end of file