Union accessors in C# should use generic type for the table
authorMormegil <mormegil@centrum.cz>
Wed, 15 Apr 2015 15:51:20 +0000 (17:51 +0200)
committerWouter van Oortmerssen <wvo@google.com>
Fri, 8 May 2015 23:21:54 +0000 (16:21 -0700)
commit221193eaa2a92d6c8f1e8c149c418b0add55b2a5
tree1f86272b149291cc30537101e33224278985aa1b
parentf7d24f60a20e628523d2c24b3dd2fd3fbfcfeea2
Union accessors in C# should use generic type for the table

When accessing a union field, we should return the same object type
as was given to the method, i.e. the parameter should have a generic
type for any Table-derived type. This way, we do not need to make
superfluous casts (which also reduce type safety) like

var myUnionType = (MyUnionType)buff.GetUnionField(new MyUnionType());

when we can do just
var myUnionType = buff.GetUnionField(new MyUnionType());

Change-Id: Idac1b638e46cc50b1f2dc19f10741481202b1515
net/FlatBuffers/Table.cs
src/idl_gen_general.cpp
tests/MyGame/Example/Monster.cs