[C#] Fix nested structs and arrays in Object API (#5765)

* [C#] Fix nested structs and arrays in Object API

The adds support for nested structs and fixed size arrays in the C#
Object API codegen which previously generated invalid code that wouldn't
compile.

- Nested structs would originally generate syntax errors due to adding an
  additional `.` to separate fields.
- Fixed size arrays of nested structs would originally generate code for
  the first field in the top most struct, and would lead to a compiler
  error due to referencing undefined variables.

* [C#] fix nested structs and arrays of structs.

* fix nested structs + arrays

* add table support

* Cleanup code

Co-authored-by: mugisoba <mugisoba+github@icloud.com>
This commit is contained in:
Anass Al
2020-04-06 09:27:13 -07:00
committed by GitHub
parent 408f11fbdd
commit fb96fadc20
2 changed files with 96 additions and 78 deletions

View File

@@ -59,6 +59,8 @@ public struct Vec3 : IFlatbufferObject
}
public static Offset<MyGame.Example.Vec3> Pack(FlatBufferBuilder builder, Vec3T _o) {
if (_o == null) return default(Offset<MyGame.Example.Vec3>);
var _test3_a = _o.Test3.A;
var _test3_b = _o.Test3.B;
return CreateVec3(
builder,
_o.X,
@@ -66,8 +68,8 @@ public struct Vec3 : IFlatbufferObject
_o.Z,
_o.Test1,
_o.Test2,
_o.Test3.A,
_o.Test3.B);
_test3_a,
_test3_b);
}
};