[C#] support Json Serialization (#5752)

* support json serialization

* fix invalid json format.
* string must be written with double quotes.
* remove commma after the last object member.

* fix indent

* Revert "fix invalid json format."

This reverts commit d6820ed50c.

* quated string value.

* add cs-gen-json-serializer flag.

* fix preprocessor indent

* ENABLE_JSON_SERIALIZATION -> ENABLE_JSON_SERIALIZATION_TEST

* share TestBuffer method

* remove ENABLE_JSON_SERIALIZATION

* remove duplicated test data

* [windows] add nuget restore and copy test data.

* [docker mono] share msbuild settings with windows. add nuget restore and copy test data.

* add some note for json api.
This commit is contained in:
mugisoba
2020-02-11 10:43:36 +09:00
committed by GitHub
parent 8f56990f6c
commit 173e10fdf1
43 changed files with 680 additions and 42 deletions

View File

@@ -1,23 +1,41 @@
#!/bin/sh
# Restore nuget packages
mkdir dotnet_tmp
curl -OL https://dot.net/v1/dotnet-install.sh
chmod +x dotnet-install.sh
./dotnet-install.sh --version 3.1.101 --install-dir dotnet_tmp
dotnet_tmp/dotnet new sln
dotnet_tmp/dotnet sln add FlatBuffers.Test.csproj
curl -OL https://dist.nuget.org/win-x86-commandline/v5.4.0/nuget.exe
mono nuget.exe restore
# Copy Test Files
cp ../monsterdata_test.mon Resources/
cp ../monsterdata_test.json Resources/
# Testing C# on Linux using Mono.
mcs -debug -out:./fbnettest.exe \
../../net/FlatBuffers/*.cs ../MyGame/Example/*.cs ../MyGame/Example2/*.cs ../MyGame/*.cs ../union_vector/*.cs \
FlatBuffersTestClassAttribute.cs FlatBuffersTestMethodAttribute.cs Assert.cs FlatBuffersExampleTests.cs Program.cs ByteBufferTests.cs FlatBufferBuilderTests.cs FlatBuffersFuzzTests.cs FuzzTestData.cs Lcg.cs TestTable.cs
mono --debug ./fbnettest.exe
rm fbnettest.exe
msbuild -property:Configuration=Release,OutputPath=tempcs -verbosity:minimal FlatBuffers.Test.csproj
mono tempcs/FlatBuffers.Test.exe
rm -fr tempcs
rm Resources/monsterdata_cstest.mon
rm Resources/monsterdata_cstest_sp.mon
# Repeat with unsafe versions
mcs -debug -out:./fbnettest.exe \
-unsafe -d:UNSAFE_BYTEBUFFER \
../../net/FlatBuffers/*.cs ../MyGame/Example/*.cs ../MyGame/Example2/*.cs ../MyGame/*.cs ../union_vector/*.cs\
FlatBuffersTestClassAttribute.cs FlatBuffersTestMethodAttribute.cs Assert.cs FlatBuffersExampleTests.cs Program.cs ByteBufferTests.cs FlatBufferBuilderTests.cs FlatBuffersFuzzTests.cs FuzzTestData.cs Lcg.cs TestTable.cs
mono --debug ./fbnettest.exe
rm fbnettest.exe
msbuild -property:Configuration=Release,UnsafeByteBuffer=true,OutputPath=tempcsUnsafe -verbosity:minimal FlatBuffers.Test.csproj
mono tempcsUnsafe/FlatBuffers.Test.exe
rm -fr tempcsUnsafe
rm Resources/monsterdata_cstest.mon
rm Resources/monsterdata_cstest_sp.mon
# Remove Temp Files
rm -fr dotnet_tmp
rm -fr packages
rm dotnet-install.sh
rm nuget.exe
rm FlatBuffers.Test.sln
rm Resources/monsterdata_test.mon
rm Resources/monsterdata_test.json