Skip to content

Commit

Permalink
fix: inability to install extension (#231)
Browse files Browse the repository at this point in the history
Newtonsoft.json dll is explicitly ignored by the Playnite Toolbox
utility which is used to pack the extension. For this reason, packaged
extensions are installed without this dll and throw an error when
Playnite is run.

Although Playnite SDK provides a serialization utility, it does not
allow configuration of casing (camel case). For this reason,
System.Text.Json is used as Newtonsoft's replacement.

Fixes #230
  • Loading branch information
andrew-codes authored Apr 11, 2024
2 parents d783fed + f28db8c commit 2916e43
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
25 changes: 22 additions & 3 deletions apps/PlayniteWebPlugin/src/PlayniteWeb.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,29 @@
<IntermediateOutputPath>C:\Users\andrew\AppData\Local\Temp\vs3D76.tmp\Release\</IntermediateOutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="MQTTnet, Version=4.3.3.952, Culture=neutral, PublicKeyToken=fdb7629f2e364a63, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\MQTTnet.4.3.3.952\lib\net461\MQTTnet.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\..\..\.nuget\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Playnite.SDK, Version=6.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\PlayniteSDK.6.11.0\lib\net462\Playnite.SDK.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Reactive, Version=6.0.0.0, Culture=neutral, PublicKeyToken=94bc3704cddfc263, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.Reactive.6.0.0\lib\netstandard2.0\System.Reactive.dll</HintPath>
</Reference>
Expand All @@ -57,9 +67,18 @@
<HintPath>
..\..\..\.nuget\System.Security.Cryptography.ProtectedData.8.0.0\lib\net462\System.Security.Cryptography.ProtectedData.dll</HintPath>
</Reference>
<Reference Include="System.Text.Encodings.Web, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.Text.Encodings.Web.8.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
</Reference>
<Reference Include="System.Text.Json, Version=8.0.0.3, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.Text.Json.8.0.3\lib\net462\System.Text.Json.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\..\..\.nuget\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
Expand Down
2 changes: 1 addition & 1 deletion apps/PlayniteWebPlugin/src/Services/ISerializeObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace PlayniteWeb.Services
{
public interface ISerializeObjects
{
string Serialize<T>(T data);
string Serialize(object data);
}
}
17 changes: 3 additions & 14 deletions apps/PlayniteWebPlugin/src/Services/ObjectSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System.Text.Json;

namespace PlayniteWeb.Services
{
public class ObjectSerializer : ISerializeObjects
{
private readonly JsonSerializer serializer;

public ObjectSerializer() => serializer = new JsonSerializer() { ContractResolver = new CamelCasePropertyNamesContractResolver() };

public string Serialize<T>(T data)
public string Serialize(object data)
{
using (var outStream = new StringWriter())
using (var writer = new JsonTextWriter(outStream))
{
serializer.Serialize(writer, data);
return outStream.ToString();
}
return JsonSerializer.Serialize(data, new JsonSerializerOptions(JsonSerializerDefaults.Web));
}
}
}
2 changes: 1 addition & 1 deletion apps/PlayniteWebPlugin/src/extension.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Id: PlayniteWeb_ec3439e3-51ee-43cb-9a8a-5d82cf45edac
Name: Playnite Web
Author: Andrew Smith
Version: 0.1
Version: 2.0.1
Module: PlayniteWeb.dll
Type: GenericPlugin
Icon: Resources\icon.png
8 changes: 7 additions & 1 deletion apps/PlayniteWebPlugin/src/packages.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net462" />
<package id="MQTTnet" version="4.3.3.952" targetFramework="net462" />
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net462" />
<package id="PlayniteSDK" version="6.11.0" targetFramework="net462" />
<package id="System.Buffers" version="4.5.1" targetFramework="net462" />
<package id="System.Memory" version="4.5.5" targetFramework="net462" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net462" />
<package id="System.Reactive" version="6.0.0" targetFramework="net462" />
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net462" />
<package id="System.Runtime.InteropServices.WindowsRuntime" version="4.3.0" targetFramework="net462" />
<package id="System.Security.Cryptography.ProtectedData" version="8.0.0" targetFramework="net462" />
<package id="System.Text.Encodings.Web" version="8.0.0" targetFramework="net462" />
<package id="System.Text.Json" version="8.0.3" targetFramework="net462" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net462" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net462" />
</packages>

0 comments on commit 2916e43

Please sign in to comment.