mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-22 12:18:53 +00:00
Fix verification for C# unions (#7970)
* Fix verification for unions * Run scripts\generate_code.py --------- Co-authored-by: Michael Le <michael.le647@gmail.com>
This commit is contained in:
@@ -431,6 +431,10 @@ class CSharpGenerator : public BaseGenerator {
|
|||||||
if (opts.generate_object_based_api) {
|
if (opts.generate_object_based_api) {
|
||||||
GenEnum_ObjectAPI(enum_def, code_ptr, opts);
|
GenEnum_ObjectAPI(enum_def, code_ptr, opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (enum_def.is_union) {
|
||||||
|
code += GenUnionVerify(enum_def.underlying_type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasUnionStringValue(const EnumDef &enum_def) const {
|
bool HasUnionStringValue(const EnumDef &enum_def) const {
|
||||||
@@ -1755,8 +1759,6 @@ class CSharpGenerator : public BaseGenerator {
|
|||||||
code += " }\n";
|
code += " }\n";
|
||||||
code += "}\n\n";
|
code += "}\n\n";
|
||||||
|
|
||||||
code += GenUnionVerify(enum_def.underlying_type);
|
|
||||||
|
|
||||||
// JsonConverter
|
// JsonConverter
|
||||||
if (opts.cs_gen_json_serializer) {
|
if (opts.cs_gen_json_serializer) {
|
||||||
if (enum_def.attributes.Lookup("private")) {
|
if (enum_def.attributes.Lookup("private")) {
|
||||||
|
|||||||
@@ -99,6 +99,26 @@ namespace Google.FlatBuffers.Test
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ArrayEqual<T>(ArraySegment<T> expected, T[] actual)
|
||||||
|
{
|
||||||
|
#if NETCOREAPP
|
||||||
|
ArrayEqual(expected.ToArray(), actual);
|
||||||
|
#else
|
||||||
|
if (expected.Count != actual.Length)
|
||||||
|
{
|
||||||
|
throw new AssertFailedException(expected, actual);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < expected.Count; ++i)
|
||||||
|
{
|
||||||
|
if (!expected.Array[expected.Offset + i].Equals(actual[i]))
|
||||||
|
{
|
||||||
|
throw new AssertArrayFailedException(i, expected, actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public static void IsTrue(bool value)
|
public static void IsTrue(bool value)
|
||||||
{
|
{
|
||||||
if (!value)
|
if (!value)
|
||||||
|
|||||||
@@ -422,7 +422,7 @@ namespace Google.FlatBuffers.Test
|
|||||||
|
|
||||||
// Get the full array back out and ensure they are equivalent
|
// Get the full array back out and ensure they are equivalent
|
||||||
var bbArray = uut.ToArray<T>(nOffset, data.Count);
|
var bbArray = uut.ToArray<T>(nOffset, data.Count);
|
||||||
Assert.ArrayEqual(data.ToArray(), bbArray);
|
Assert.ArrayEqual(data, bbArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public unsafe void ByteBuffer_Put_IntPtr_Helper<T>(T[] data, int typeSize)
|
public unsafe void ByteBuffer_Put_IntPtr_Helper<T>(T[] data, int typeSize)
|
||||||
@@ -643,7 +643,7 @@ namespace Google.FlatBuffers.Test
|
|||||||
float[] data = null;
|
float[] data = null;
|
||||||
Assert.Throws<ArgumentNullException>(() => uut.Put(1024, data));
|
Assert.Throws<ArgumentNullException>(() => uut.Put(1024, data));
|
||||||
|
|
||||||
ArraySegment<float> dataArraySegment = default;
|
ArraySegment<float> dataArraySegment = default(ArraySegment<float>);
|
||||||
Assert.Throws<ArgumentNullException>(() => uut.Put(1024, dataArraySegment));
|
Assert.Throws<ArgumentNullException>(() => uut.Put(1024, dataArraySegment));
|
||||||
|
|
||||||
IntPtr dataPtr = IntPtr.Zero;
|
IntPtr dataPtr = IntPtr.Zero;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Google.FlatBuffers.Test
|
namespace Google.FlatBuffers.Test
|
||||||
{
|
{
|
||||||
@@ -586,12 +587,14 @@ namespace Google.FlatBuffers.Test
|
|||||||
[FlatBuffersTestMethod]
|
[FlatBuffersTestMethod]
|
||||||
public void FlatBufferBuilder_Add_ArraySegment_Default_Throws()
|
public void FlatBufferBuilder_Add_ArraySegment_Default_Throws()
|
||||||
{
|
{
|
||||||
var fbb = CreateBuffer(false);
|
#if NETCOREAPP
|
||||||
|
var fbb = CreateBuffer(false);
|
||||||
|
|
||||||
// Construct the data array
|
// Construct the data array
|
||||||
ArraySegment<float> data = default;
|
ArraySegment<float> data = default(ArraySegment<float>);
|
||||||
|
|
||||||
Assert.Throws<ArgumentNullException>(() => fbb.Add(data));
|
Assert.Throws<ArgumentNullException>(() => fbb.Add(data));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[FlatBuffersTestMethod]
|
[FlatBuffersTestMethod]
|
||||||
|
|||||||
@@ -66,6 +66,9 @@
|
|||||||
<Compile Include="..\..\net\FlatBuffers\FlatBufferConstants.cs">
|
<Compile Include="..\..\net\FlatBuffers\FlatBufferConstants.cs">
|
||||||
<Link>FlatBuffers\FlatBufferConstants.cs</Link>
|
<Link>FlatBuffers\FlatBufferConstants.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\..\net\FlatBuffers\FlatBufferVerify.cs">
|
||||||
|
<Link>FlatBuffers\FlatBufferVerify.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\..\net\FlatBuffers\Struct.cs">
|
<Compile Include="..\..\net\FlatBuffers\Struct.cs">
|
||||||
<Link>FlatBuffers\Struct.cs</Link>
|
<Link>FlatBuffers\Struct.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -120,6 +123,9 @@
|
|||||||
<Compile Include="..\MyGame\Example\ArrayStruct.cs">
|
<Compile Include="..\MyGame\Example\ArrayStruct.cs">
|
||||||
<Link>MyGame\Example\ArrayStruct.cs</Link>
|
<Link>MyGame\Example\ArrayStruct.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\MyGame\Example\LongEnum.cs">
|
||||||
|
<Link>MyGame\Example\LongEnum.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\MyGame\Example\NestedStruct.cs">
|
<Compile Include="..\MyGame\Example\NestedStruct.cs">
|
||||||
<Link>MyGame\Example\NestedStruct.cs</Link>
|
<Link>MyGame\Example\NestedStruct.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|||||||
@@ -37,28 +37,6 @@ public class KeywordsInUnionUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class KeywordsInUnionVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((KeywordsInUnion)typeId)
|
|
||||||
{
|
|
||||||
case KeywordsInUnion.@static:
|
|
||||||
result = KeywordTest.KeywordsInTableVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case KeywordsInUnion.@internal:
|
|
||||||
result = KeywordTest.KeywordsInTableVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class KeywordsInUnionUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class KeywordsInUnionUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(KeywordsInUnionUnion) || objectType == typeof(System.Collections.Generic.List<KeywordsInUnionUnion>);
|
return objectType == typeof(KeywordsInUnionUnion) || objectType == typeof(System.Collections.Generic.List<KeywordsInUnionUnion>);
|
||||||
@@ -102,4 +80,26 @@ public class KeywordsInUnionUnion_JsonConverter : Newtonsoft.Json.JsonConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class KeywordsInUnionVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((KeywordsInUnion)typeId)
|
||||||
|
{
|
||||||
|
case KeywordsInUnion.@static:
|
||||||
|
result = KeywordTest.KeywordsInTableVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case KeywordsInUnion.@internal:
|
||||||
|
result = KeywordTest.KeywordsInTableVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,31 +41,6 @@ public class AnyUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class AnyVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((Any)typeId)
|
|
||||||
{
|
|
||||||
case Any.Monster:
|
|
||||||
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case Any.TestSimpleTableWithEnum:
|
|
||||||
result = MyGame.Example.TestSimpleTableWithEnumVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case Any.MyGame_Example2_Monster:
|
|
||||||
result = MyGame.Example2.MonsterVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AnyUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class AnyUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(AnyUnion) || objectType == typeof(System.Collections.Generic.List<AnyUnion>);
|
return objectType == typeof(AnyUnion) || objectType == typeof(System.Collections.Generic.List<AnyUnion>);
|
||||||
@@ -110,4 +85,29 @@ public class AnyUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class AnyVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((Any)typeId)
|
||||||
|
{
|
||||||
|
case Any.Monster:
|
||||||
|
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case Any.TestSimpleTableWithEnum:
|
||||||
|
result = MyGame.Example.TestSimpleTableWithEnumVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case Any.MyGame_Example2_Monster:
|
||||||
|
result = MyGame.Example2.MonsterVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,31 +41,6 @@ public class AnyAmbiguousAliasesUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class AnyAmbiguousAliasesVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((AnyAmbiguousAliases)typeId)
|
|
||||||
{
|
|
||||||
case AnyAmbiguousAliases.M1:
|
|
||||||
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case AnyAmbiguousAliases.M2:
|
|
||||||
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case AnyAmbiguousAliases.M3:
|
|
||||||
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AnyAmbiguousAliasesUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class AnyAmbiguousAliasesUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(AnyAmbiguousAliasesUnion) || objectType == typeof(System.Collections.Generic.List<AnyAmbiguousAliasesUnion>);
|
return objectType == typeof(AnyAmbiguousAliasesUnion) || objectType == typeof(System.Collections.Generic.List<AnyAmbiguousAliasesUnion>);
|
||||||
@@ -110,4 +85,29 @@ public class AnyAmbiguousAliasesUnion_JsonConverter : Newtonsoft.Json.JsonConver
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class AnyAmbiguousAliasesVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((AnyAmbiguousAliases)typeId)
|
||||||
|
{
|
||||||
|
case AnyAmbiguousAliases.M1:
|
||||||
|
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case AnyAmbiguousAliases.M2:
|
||||||
|
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case AnyAmbiguousAliases.M3:
|
||||||
|
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,31 +41,6 @@ public class AnyUniqueAliasesUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class AnyUniqueAliasesVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((AnyUniqueAliases)typeId)
|
|
||||||
{
|
|
||||||
case AnyUniqueAliases.M:
|
|
||||||
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case AnyUniqueAliases.TS:
|
|
||||||
result = MyGame.Example.TestSimpleTableWithEnumVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case AnyUniqueAliases.M2:
|
|
||||||
result = MyGame.Example2.MonsterVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class AnyUniqueAliasesUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class AnyUniqueAliasesUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(AnyUniqueAliasesUnion) || objectType == typeof(System.Collections.Generic.List<AnyUniqueAliasesUnion>);
|
return objectType == typeof(AnyUniqueAliasesUnion) || objectType == typeof(System.Collections.Generic.List<AnyUniqueAliasesUnion>);
|
||||||
@@ -110,4 +85,29 @@ public class AnyUniqueAliasesUnion_JsonConverter : Newtonsoft.Json.JsonConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class AnyUniqueAliasesVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((AnyUniqueAliases)typeId)
|
||||||
|
{
|
||||||
|
case AnyUniqueAliases.M:
|
||||||
|
result = MyGame.Example.MonsterVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case AnyUniqueAliases.TS:
|
||||||
|
result = MyGame.Example.TestSimpleTableWithEnumVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case AnyUniqueAliases.M2:
|
||||||
|
result = MyGame.Example2.MonsterVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,25 +33,6 @@ public class UnionInNestedNSUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class UnionInNestedNSVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((UnionInNestedNS)typeId)
|
|
||||||
{
|
|
||||||
case UnionInNestedNS.TableInNestedNS:
|
|
||||||
result = NamespaceA.NamespaceB.TableInNestedNSVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class UnionInNestedNSUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class UnionInNestedNSUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(UnionInNestedNSUnion) || objectType == typeof(System.Collections.Generic.List<UnionInNestedNSUnion>);
|
return objectType == typeof(UnionInNestedNSUnion) || objectType == typeof(System.Collections.Generic.List<UnionInNestedNSUnion>);
|
||||||
@@ -94,4 +75,23 @@ public class UnionInNestedNSUnion_JsonConverter : Newtonsoft.Json.JsonConverter
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class UnionInNestedNSVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((UnionInNestedNS)typeId)
|
||||||
|
{
|
||||||
|
case UnionInNestedNS.TableInNestedNS:
|
||||||
|
result = NamespaceA.NamespaceB.TableInNestedNSVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,25 +37,6 @@ public class ValueUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class ValueVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((Value)typeId)
|
|
||||||
{
|
|
||||||
case Value.IntValue:
|
|
||||||
result = union_value_collsion.IntValueVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ValueUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class ValueUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(ValueUnion) || objectType == typeof(System.Collections.Generic.List<ValueUnion>);
|
return objectType == typeof(ValueUnion) || objectType == typeof(System.Collections.Generic.List<ValueUnion>);
|
||||||
@@ -97,6 +78,25 @@ public class ValueUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class ValueVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((Value)typeId)
|
||||||
|
{
|
||||||
|
case Value.IntValue:
|
||||||
|
result = union_value_collsion.IntValueVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
[Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))]
|
||||||
public enum Other : byte
|
public enum Other : byte
|
||||||
{
|
{
|
||||||
@@ -125,25 +125,6 @@ public class OtherUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class OtherVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((Other)typeId)
|
|
||||||
{
|
|
||||||
case Other.IntValue:
|
|
||||||
result = union_value_collsion.IntValueVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class OtherUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class OtherUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(OtherUnion) || objectType == typeof(System.Collections.Generic.List<OtherUnion>);
|
return objectType == typeof(OtherUnion) || objectType == typeof(System.Collections.Generic.List<OtherUnion>);
|
||||||
@@ -185,6 +166,25 @@ public class OtherUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class OtherVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((Other)typeId)
|
||||||
|
{
|
||||||
|
case Other.IntValue:
|
||||||
|
result = union_value_collsion.IntValueVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public struct IntValue : IFlatbufferObject
|
public struct IntValue : IFlatbufferObject
|
||||||
{
|
{
|
||||||
private Table __p;
|
private Table __p;
|
||||||
|
|||||||
@@ -50,40 +50,6 @@ public class CharacterUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class CharacterVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((Character)typeId)
|
|
||||||
{
|
|
||||||
case Character.MuLan:
|
|
||||||
result = AttackerVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
case Character.Rapunzel:
|
|
||||||
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
|
||||||
break;
|
|
||||||
case Character.Belle:
|
|
||||||
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
|
||||||
break;
|
|
||||||
case Character.BookFan:
|
|
||||||
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
|
||||||
break;
|
|
||||||
case Character.Other:
|
|
||||||
result = verifier.VerifyUnionString(tablePos);
|
|
||||||
break;
|
|
||||||
case Character.Unused:
|
|
||||||
result = verifier.VerifyUnionString(tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class CharacterUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class CharacterUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(CharacterUnion) || objectType == typeof(System.Collections.Generic.List<CharacterUnion>);
|
return objectType == typeof(CharacterUnion) || objectType == typeof(System.Collections.Generic.List<CharacterUnion>);
|
||||||
@@ -130,3 +96,37 @@ public class CharacterUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class CharacterVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((Character)typeId)
|
||||||
|
{
|
||||||
|
case Character.MuLan:
|
||||||
|
result = AttackerVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
case Character.Rapunzel:
|
||||||
|
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
||||||
|
break;
|
||||||
|
case Character.Belle:
|
||||||
|
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
||||||
|
break;
|
||||||
|
case Character.BookFan:
|
||||||
|
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
||||||
|
break;
|
||||||
|
case Character.Other:
|
||||||
|
result = verifier.VerifyUnionString(tablePos);
|
||||||
|
break;
|
||||||
|
case Character.Unused:
|
||||||
|
result = verifier.VerifyUnionString(tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,28 +34,6 @@ public class GadgetUnion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static public class GadgetVerify
|
|
||||||
{
|
|
||||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
|
||||||
{
|
|
||||||
bool result = true;
|
|
||||||
switch((Gadget)typeId)
|
|
||||||
{
|
|
||||||
case Gadget.FallingTub:
|
|
||||||
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
|
||||||
break;
|
|
||||||
case Gadget.HandFan:
|
|
||||||
result = HandFanVerify.Verify(verifier, tablePos);
|
|
||||||
break;
|
|
||||||
default: result = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GadgetUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
public class GadgetUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
||||||
public override bool CanConvert(System.Type objectType) {
|
public override bool CanConvert(System.Type objectType) {
|
||||||
return objectType == typeof(GadgetUnion) || objectType == typeof(System.Collections.Generic.List<GadgetUnion>);
|
return objectType == typeof(GadgetUnion) || objectType == typeof(System.Collections.Generic.List<GadgetUnion>);
|
||||||
@@ -98,3 +76,25 @@ public class GadgetUnion_JsonConverter : Newtonsoft.Json.JsonConverter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static public class GadgetVerify
|
||||||
|
{
|
||||||
|
static public bool Verify(Google.FlatBuffers.Verifier verifier, byte typeId, uint tablePos)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
switch((Gadget)typeId)
|
||||||
|
{
|
||||||
|
case Gadget.FallingTub:
|
||||||
|
result = verifier.VerifyUnionData(tablePos, 4, 4);
|
||||||
|
break;
|
||||||
|
case Gadget.HandFan:
|
||||||
|
result = HandFanVerify.Verify(verifier, tablePos);
|
||||||
|
break;
|
||||||
|
default: result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user