summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormugisoba <51015092+mugisoba@users.noreply.github.com>2020-05-22 01:14:20 +0900
committerGitHub <noreply@github.com>2020-05-21 09:14:20 -0700
commitac203b20926b13a35ff85277d2e5d3c38698eee8 (patch)
treeccc0f89930d52ae53cb23ae80890e34c1a353bf7
parent8dd1bf25b51ed7ccc2b4b70bef15b8beac4c31f1 (diff)
downloadflatbuffers-ac203b20926b13a35ff85277d2e5d3c38698eee8.tar.gz
flatbuffers-ac203b20926b13a35ff85277d2e5d3c38698eee8.tar.bz2
flatbuffers-ac203b20926b13a35ff85277d2e5d3c38698eee8.zip
[C#] Add file identifier to ObjectAPI Serialization Utility. (#5920)
* use Finish***Buffer instead. * add file_identifier test.
-rw-r--r--src/idl_gen_csharp.cpp8
-rw-r--r--tests/FlatBuffers.Test/FlatBuffersExampleTests.cs3
-rw-r--r--tests/MyGame/Example/ArrayTable.cs2
-rw-r--r--tests/MyGame/Example/Monster.cs2
-rw-r--r--tests/MyGame/MonsterExtra.cs2
-rw-r--r--tests/union_vector/Movie.cs2
6 files changed, 12 insertions, 7 deletions
diff --git a/src/idl_gen_csharp.cpp b/src/idl_gen_csharp.cpp
index 96a5da80..0dd07d3b 100644
--- a/src/idl_gen_csharp.cpp
+++ b/src/idl_gen_csharp.cpp
@@ -1823,7 +1823,9 @@ class CSharpGenerator : public BaseGenerator {
code += "[idx" + NumToString(j++) + "]";
}
code += ";";
- for (size_t i = 0; i < array_only_lengths.size(); ++i) { code += "}"; }
+ for (size_t i = 0; i < array_only_lengths.size(); ++i) {
+ code += "}";
+ }
} else {
code += "_o";
for (size_t i = 0; i < array_lengths.size(); ++i) {
@@ -2035,8 +2037,8 @@ class CSharpGenerator : public BaseGenerator {
code += " }\n";
code += " public byte[] SerializeToBinary() {\n";
code += " var fbb = new FlatBufferBuilder(0x10000);\n";
- code +=
- " fbb.Finish(" + struct_def.name + ".Pack(fbb, this).Value);\n";
+ code += " " + struct_def.name + ".Finish" + struct_def.name +
+ "Buffer(fbb, " + struct_def.name + ".Pack(fbb, this));\n";
code += " return fbb.DataBuffer.ToSizedArray();\n";
code += " }\n";
}
diff --git a/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs b/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
index c0aa0d1c..97a32aeb 100644
--- a/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
+++ b/tests/FlatBuffers.Test/FlatBuffersExampleTests.cs
@@ -676,6 +676,7 @@ namespace FlatBuffers.Test
AreEqual(a, d);
var fbBuffer = b.SerializeToBinary();
+ Assert.IsTrue(Monster.MonsterBufferHasIdentifier(new ByteBuffer(fbBuffer)));
var e = MonsterT.DeserializeFromBinary(fbBuffer);
AreEqual(a, e);
}
@@ -779,6 +780,7 @@ namespace FlatBuffers.Test
AreEqual(a, d);
var fbBuffer = b.SerializeToBinary();
+ Assert.IsTrue(ArrayTable.ArrayTableBufferHasIdentifier(new ByteBuffer(fbBuffer)));
var e = ArrayTableT.DeserializeFromBinary(fbBuffer);
AreEqual(a, e);
}
@@ -826,6 +828,7 @@ namespace FlatBuffers.Test
AreEqual(a, d);
var fbBuffer = b.SerializeToBinary();
+ Assert.IsTrue(Movie.MovieBufferHasIdentifier(new ByteBuffer(fbBuffer)));
var e = MovieT.DeserializeFromBinary(fbBuffer);
AreEqual(a, e);
}
diff --git a/tests/MyGame/Example/ArrayTable.cs b/tests/MyGame/Example/ArrayTable.cs
index 4f743d0d..b5b599fe 100644
--- a/tests/MyGame/Example/ArrayTable.cs
+++ b/tests/MyGame/Example/ArrayTable.cs
@@ -66,7 +66,7 @@ public class ArrayTableT
}
public byte[] SerializeToBinary() {
var fbb = new FlatBufferBuilder(0x10000);
- fbb.Finish(ArrayTable.Pack(fbb, this).Value);
+ ArrayTable.FinishArrayTableBuffer(fbb, ArrayTable.Pack(fbb, this));
return fbb.DataBuffer.ToSizedArray();
}
}
diff --git a/tests/MyGame/Example/Monster.cs b/tests/MyGame/Example/Monster.cs
index 73e39c59..6731cffa 100644
--- a/tests/MyGame/Example/Monster.cs
+++ b/tests/MyGame/Example/Monster.cs
@@ -891,7 +891,7 @@ public class MonsterT
}
public byte[] SerializeToBinary() {
var fbb = new FlatBufferBuilder(0x10000);
- fbb.Finish(Monster.Pack(fbb, this).Value);
+ Monster.FinishMonsterBuffer(fbb, Monster.Pack(fbb, this));
return fbb.DataBuffer.ToSizedArray();
}
}
diff --git a/tests/MyGame/MonsterExtra.cs b/tests/MyGame/MonsterExtra.cs
index f2f49314..d74ae8bd 100644
--- a/tests/MyGame/MonsterExtra.cs
+++ b/tests/MyGame/MonsterExtra.cs
@@ -196,7 +196,7 @@ public class MonsterExtraT
}
public byte[] SerializeToBinary() {
var fbb = new FlatBufferBuilder(0x10000);
- fbb.Finish(MonsterExtra.Pack(fbb, this).Value);
+ MonsterExtra.FinishMonsterExtraBuffer(fbb, MonsterExtra.Pack(fbb, this));
return fbb.DataBuffer.ToSizedArray();
}
}
diff --git a/tests/union_vector/Movie.cs b/tests/union_vector/Movie.cs
index f3d8e6ee..2358600f 100644
--- a/tests/union_vector/Movie.cs
+++ b/tests/union_vector/Movie.cs
@@ -196,7 +196,7 @@ public class MovieT
}
public byte[] SerializeToBinary() {
var fbb = new FlatBufferBuilder(0x10000);
- fbb.Finish(Movie.Pack(fbb, this).Value);
+ Movie.FinishMovieBuffer(fbb, Movie.Pack(fbb, this));
return fbb.DataBuffer.ToSizedArray();
}
}