Skip to content

Commit

Permalink
setup central package management and update package versions (#20)
Browse files Browse the repository at this point in the history
* setup central package management and update package versions

* change ycs to use system.text.json instead of newtonsoft json
  • Loading branch information
hahn-kev authored Nov 29, 2024
1 parent 481acfc commit 3a5d037
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 33 deletions.
27 changes: 27 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.11" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageVersion Include="System.IO.Hashing" Version="9.0.0" />
<PackageVersion Include="System.Linq.Async" Version="6.0.1" />
<PackageVersion Include="BenchmarkDotNet" Version="0.14.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.2" />
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
<PackageVersion Include="JetBrains.Profiler.SelfApi" Version="2.5.12" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageVersion Include="System.Text.Json" Version="9.0.0" />
<PackageVersion Include="Verify.DiffPlex" Version="3.1.2" />
<PackageVersion Include="Verify.EntityFramework" Version="12.4.0" />
<PackageVersion Include="Verify.Xunit" Version="28.2.1" />
<PackageVersion Include="xunit" Version="2.9.2" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="coverlet.collector" Version="6.0.2" />
<PackageVersion Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.12.19" />
<PackageVersion Include="linq2db.AspNet" Version="5.4.1" />
<PackageVersion Include="linq2db.EntityFrameworkCore" Version="8.1.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.10.48" PrivateAssets="all"/>
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" PrivateAssets="all"/>
</ItemGroup>
</Project>
6 changes: 3 additions & 3 deletions src/SIL.Harmony.Core/SIL.Harmony.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="System.IO.Hashing" Version="8.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" />
<PackageReference Include="System.IO.Hashing" />
<PackageReference Include="System.Linq.Async" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/SIL.Harmony.Linq2db/SIL.Harmony.Linq2db.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="linq2db.AspNet" Version="5.4.1" />
<PackageReference Include="linq2db.EntityFrameworkCore" Version="8.1.0" />
<PackageReference Include="linq2db.AspNet" />
<PackageReference Include="linq2db.EntityFrameworkCore" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@
Relational:ViewName:
Relational:ViewSchema:
Annotations:
ProductVersion: 8.0.4
ProductVersion: 8.0.11
24 changes: 12 additions & 12 deletions src/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,27 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<PackageReference Include="FluentAssertions" Version="6.12.0" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PackageReference Include="BenchmarkDotNet" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="GitHubActionsTestLogger">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="JetBrains.Profiler.SelfApi" Version="2.5.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Verify.DiffPlex" Version="2.3.0" />
<PackageReference Include="Verify.EntityFramework" Version="12.1.0" />
<PackageReference Include="Verify.Xunit" Version="23.2.0" />
<PackageReference Include="xunit" Version="2.7.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7">
<PackageReference Include="JetBrains.Profiler.SelfApi" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Verify.DiffPlex" />
<PackageReference Include="Verify.EntityFramework" />
<PackageReference Include="Verify.Xunit" />
<PackageReference Include="xunit" />
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Linq.Async" Version="6.0.1"/>
<PackageReference Include="System.Linq.Async"/>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/SIL.Harmony/SIL.Harmony.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" />
</ItemGroup>

<ItemGroup>
Expand Down
22 changes: 13 additions & 9 deletions src/Ycs/Structs/ContentJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,26 @@
// </copyright>
// ------------------------------------------------------------------------------

using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;

namespace Ycs
{
public class ContentJson : IContentEx
{
internal const int _ref = 2;

private readonly List<object> _content;
private readonly List<JsonNode> _content;

internal ContentJson(IEnumerable<object> data)
internal ContentJson(IEnumerable<JsonNode> data)
{
_content = new List<object>(data);
_content = new List<JsonNode>(data);
}

private ContentJson(List<object> other)
private ContentJson(List<JsonNode> other)
{
_content = other;
}
Expand All @@ -29,7 +33,7 @@ private ContentJson(List<object> other)
public bool Countable => true;
public int Length => _content?.Count ?? 0;

public IReadOnlyList<object> GetContent() => _content.AsReadOnly();
public IReadOnlyList<object> GetContent() => new ReadOnlyCollection<object>(_content.OfType<object>().ToList());

public IContent Copy() => new ContentJson(_content);

Expand Down Expand Up @@ -68,22 +72,22 @@ 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);
}
}

internal static ContentJson Read(IUpdateDecoder decoder)
{
var len = decoder.ReadLength();
var content = new List<object>(len);
var content = new List<JsonNode>(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<JsonNode>(jsonStr);
content.Add(jsonObj);
}

Expand Down
4 changes: 3 additions & 1 deletion src/Ycs/Utils/UpdateDecoderV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// ------------------------------------------------------------------------------

using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Nodes;

namespace Ycs
{
Expand Down Expand Up @@ -197,7 +199,7 @@ public object ReadJson()
CheckDisposed();

var jsonString = Reader.ReadVarString();
var result = Newtonsoft.Json.JsonConvert.DeserializeObject(jsonString);
var result = JsonSerializer.Deserialize<JsonNode>(jsonString);
return result;
}

Expand Down
3 changes: 2 additions & 1 deletion src/Ycs/Utils/UpdateEncoderV2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// ------------------------------------------------------------------------------

using System.Diagnostics;
using System.Text.Json;

namespace Ycs
{
Expand Down Expand Up @@ -201,7 +202,7 @@ public void WriteKey(string key)

public void WriteJson<T>(T any)
{
var jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(any, typeof(T), null);
var jsonString = JsonSerializer.Serialize(any);
RestWriter.WriteVarString(jsonString);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Ycs/Ycs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Text.Json" />
</ItemGroup>

</Project>

0 comments on commit 3a5d037

Please sign in to comment.