mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-28 14:30:01 +00:00
[Issue 252] Add type cast for default enum values in C#
When creating a CreateXxx(...) method for a simple table type, enum-type fields with a non-zero default must have an explicit cast for the respective argument default value, because in C#, there is an implicit cast from int to an enum only for 0. Also, added an example of such type into the example monster_test type, so that we test this feature.
This commit is contained in:
@@ -8,10 +8,14 @@ attribute "priority";
|
||||
|
||||
enum Color:byte (bit_flags) { Red = 0, Green, Blue = 3, }
|
||||
|
||||
union Any { Monster } // TODO: add more elements
|
||||
union Any { Monster, TestSimpleTableWithEnum } // TODO: add more elements
|
||||
|
||||
struct Test { a:short; b:byte; }
|
||||
|
||||
table TestSimpleTableWithEnum {
|
||||
color: Color = Green;
|
||||
}
|
||||
|
||||
struct Vec3 (force_align: 16) {
|
||||
x:float;
|
||||
y:float;
|
||||
|
||||
Reference in New Issue
Block a user