Skip to content

Commit

Permalink
Do not support JSON serialization on Unity/Mono
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlia committed Sep 19, 2022
1 parent 14b5bd2 commit c51fd74
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 9 deletions.
7 changes: 5 additions & 2 deletions .circleci/config.yml
Expand Up @@ -341,6 +341,7 @@ commands:
"Libplanet.Net.Tests.Protocols.ProtocolTest"
"Libplanet.Net.Tests.SwarmTest"
"Libplanet.Net.Tests.Transports.NetMQTransportTest"
"Libplanet.Node.Tests.SwarmConfigTest"
)
args=(
"--hang-seconds=60"
Expand All @@ -358,8 +359,10 @@ commands:
done
for project in *.Tests; do
if [[
$project != *"Explorer"*
&& $project != *"RocksDBStore"*
$project != Libplanet.Explorer.Tests
&& $project != Libplanet.Extensions.Cocona.Tests
&& $project != Libplanet.RocksDBStore.Tests
&& $project != Libplanet.Tools.Tests
]]
then
args+=("$PWD/$project/bin/Release/net47/$project.dll")
Expand Down
3 changes: 2 additions & 1 deletion CHANGES.md
Expand Up @@ -24,7 +24,8 @@ To be released.

- Many types became serialized and deserialized better with
[`System.Text.Json.JsonSerializer`] as they now have their own
[custom converters]. [[#2322]]
[custom converters]. Note that these serializations are unavailable
on Unity due to its incomplete reflection support. [[#2322]]

- An `Address` became represented as a single hexadecimal string in JSON.
- A `BlockHash` became represented as a single hexadecimal string in JSON.
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Tests/AddressTest.cs
Expand Up @@ -329,7 +329,7 @@ public void ReplaceHexUpperCasePrefixString()
);
}

[Fact]
[SkippableFact]
public void JsonSerialization()
{
var address = new Address("0123456789ABcdefABcdEfABcdEFabcDEFabCDEF");
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Tests/Assets/CurrencyTest.cs
Expand Up @@ -256,7 +256,7 @@ public void Serialize()
Assert.Equal(bar, new Currency(bar.Serialize()));
}

[Fact]
[SkippableFact]
public void JsonSerialization()
{
#pragma warning disable CS0618 // must test obsoleted Currency.Legacy() for backwards compatibility
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Tests/Assets/FungibleAssetValueTest.cs
Expand Up @@ -533,7 +533,7 @@ public void Parse()
Assert.Equal(new FungibleAssetValue(FOO, -12, 0), FungibleAssetValue.Parse(FOO, "-12"));
}

[Fact]
[SkippableFact]
public void JsonSerialization()
{
var v = new FungibleAssetValue(FOO, 123, 45);
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Tests/Blocks/BlockHashTest.cs
Expand Up @@ -140,7 +140,7 @@ public void SerializeAndDeserialize()
Assert.Equal(deserialized, expected);
}

[Fact]
[SkippableFact]
public void JsonSerialization()
{
BlockHash hash = BlockHash.FromString(
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Tests/HashDigestTest.cs
Expand Up @@ -175,7 +175,7 @@ public void SerializeAndDeserializeSHA256()
Assert.Equal(deserializedHashDigest, expectedHashDigest);
}

[Fact]
[SkippableFact]
public void JsonSerialization()
{
HashDigest<SHA1> digest =
Expand Down
5 changes: 5 additions & 0 deletions Libplanet.Tests/TestUtils.cs
Expand Up @@ -550,6 +550,11 @@ public static byte[] GetRandomBytes(int size)
public static void AssertJsonSerializable<T>(T obj, string expectedJson)
where T : IEquatable<T>
{
Skip.IfNot(
Type.GetType("Mono.Runtime") is null,
"System.Text.Json 6.0.0+ does not work well with Unity/Mono."
);

var buffer = new MemoryStream();
JsonSerializer.Serialize(buffer, obj);
buffer.Seek(0L, SeekOrigin.Begin);
Expand Down
2 changes: 1 addition & 1 deletion Libplanet.Tests/Tx/TxIdTest.cs
Expand Up @@ -229,7 +229,7 @@ public void Compare()
);
}

[Fact]
[SkippableFact]
public void JsonSerialization()
{
TxId txid = TxId.FromHex(
Expand Down

0 comments on commit c51fd74

Please sign in to comment.