jamescourtney / FlatSharp

Fast, idiomatic C# implementation of Flatbuffers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unions of 41 types cause a compilation error

shadowbane1000 opened this issue · comments

Again working with autogenerated fbs files. I'm going from a schema definition language that allows inheritance, so I flatten the inheritance down with unions. I used to only do one level of flattening, but that still leaves union entries with just the base type in them.
When I resolved this, and recursively resolve inheritance in to the unions, I end up with unions with more than the limit of 30 types in them. If I get time, I'll put together a pull request increasing the number of these.

Perhaps generating code on the fly for these would be a better approach?

Hmm.. changing one number in the code hardly seems worthy of a pull request, but I'll see about putting one together.

Approving the PR. Very surprised that someone found that limit of 30.

Perhaps generating code on the fly for these would be a better approach?

Technically if you're using FBS files, we do generate custom implementations of IFlatBufferUnion<T1, T2, ..., TX>. This is to expose named union members so you'd have Dog instead of Item3. Technically for this PR, we should only need to increase the number of interfaces and not the number of implementations, since you're using FBS files (I presume). However, I don't think it hurts anything beyond exploding the size of FlatSharp.Runtime to include the extra types.

Yes, I'm using FBS. Do you know when you might be able to release a version with this change in it?

I'm going to merge one more change and will push 6.3.3 after that.

6.3.3 is published with your changes and a new Visitor pattern for working with unions.