mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 12:41:36 +00:00
[CS] Verifier (#7850)
* Fix C/C++ Create<Type>Direct with sorted vectors If a struct has a key the vector has to be sorted. To sort the vector you can't use "const". * Changes due to code review * Improve code readability * Add generate of JSON schema to string to lib * option indent_step is supported * Remove unused variables * Fix break in test * Fix style to be consistent with rest of the code * [TS] Fix reserved words as arguments (#6955) * [TS] Fix generation of reserved words in object api (#7106) * [TS] Fix generation of object api * [TS] Fix MakeCamel -> ConvertCase * [C#] Fix collision of field name and type name * [TS] Add test for struct of struct of struct * Update generated files * Add missing files * [TS] Fix query of null/undefined fields in object api * Add .Net verfier * Add some fuzz tests for .Net * Remove additional files * Fix .net test * Changes due to PR * Fix generated files --------- Co-authored-by: Derek Bailey <derekbailey@google.com>
This commit is contained in:
@@ -37,6 +37,25 @@ 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 override bool CanConvert(System.Type objectType) {
|
||||
return objectType == typeof(ValueUnion) || objectType == typeof(System.Collections.Generic.List<ValueUnion>);
|
||||
@@ -106,6 +125,25 @@ 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 override bool CanConvert(System.Type objectType) {
|
||||
return objectType == typeof(OtherUnion) || objectType == typeof(System.Collections.Generic.List<OtherUnion>);
|
||||
@@ -198,6 +236,16 @@ public class IntValueT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public class IntValueVerify
|
||||
{
|
||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, uint tablePos)
|
||||
{
|
||||
return verifier.VerifyTableStart(tablePos)
|
||||
&& verifier.VerifyField(tablePos, 4 /*Value*/, 4 /*int*/, 4, false)
|
||||
&& verifier.VerifyTableEnd(tablePos);
|
||||
}
|
||||
}
|
||||
public struct Collide : IFlatbufferObject
|
||||
{
|
||||
private Table __p;
|
||||
@@ -302,6 +350,17 @@ public class CollideT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static public class CollideVerify
|
||||
{
|
||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, uint tablePos)
|
||||
{
|
||||
return verifier.VerifyTableStart(tablePos)
|
||||
&& verifier.VerifyString(tablePos, 4 /*Collide*/, true)
|
||||
&& verifier.VerifyString(tablePos, 6 /*Value*/, false)
|
||||
&& verifier.VerifyTableEnd(tablePos);
|
||||
}
|
||||
}
|
||||
public struct Collision : IFlatbufferObject
|
||||
{
|
||||
private Table __p;
|
||||
@@ -309,6 +368,7 @@ public struct Collision : IFlatbufferObject
|
||||
public static void ValidateVersion() { FlatBufferConstants.FLATBUFFERS_23_3_3(); }
|
||||
public static Collision GetRootAsCollision(ByteBuffer _bb) { return GetRootAsCollision(_bb, new Collision()); }
|
||||
public static Collision GetRootAsCollision(ByteBuffer _bb, Collision obj) { return (obj.__assign(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
|
||||
public static bool VerifyCollision(ByteBuffer _bb) {Google.FlatBuffers.Verifier verifier = new Google.FlatBuffers.Verifier(_bb); return verifier.VerifyBuffer("", false, CollisionVerify.Verify); }
|
||||
public void __init(int _i, ByteBuffer _bb) { __p = new Table(_i, _bb); }
|
||||
public Collision __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
|
||||
|
||||
@@ -454,4 +514,18 @@ public class CollisionT
|
||||
}
|
||||
|
||||
|
||||
static public class CollisionVerify
|
||||
{
|
||||
static public bool Verify(Google.FlatBuffers.Verifier verifier, uint tablePos)
|
||||
{
|
||||
return verifier.VerifyTableStart(tablePos)
|
||||
&& verifier.VerifyField(tablePos, 4 /*SomeValueType*/, 1 /*union_value_collsion.Value*/, 1, false)
|
||||
&& verifier.VerifyUnion(tablePos, 4, 6 /*SomeValue*/, union_value_collsion.ValueVerify.Verify, false)
|
||||
&& verifier.VerifyField(tablePos, 8 /*ValueType*/, 1 /*union_value_collsion.Other*/, 1, false)
|
||||
&& verifier.VerifyUnion(tablePos, 8, 10 /*Value*/, union_value_collsion.OtherVerify.Verify, false)
|
||||
&& verifier.VerifyVectorOfTables(tablePos, 12 /*Collide*/, union_value_collsion.CollisionVerify.Verify, false)
|
||||
&& verifier.VerifyTableEnd(tablePos);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user