jamescourtney / FlatSharp

Fast, idiomatic C# implementation of Flatbuffers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Don't use Nullable properties for GreedyMutable only serializers

duckdoom4 opened this issue · comments

I do have one more question though. If we have GreedyMutable as the only deserializer option, doesn't that automatically mean that non of the properties should be marked as nullable?

I'd rather not have to mark every single property as (required)
image

As a workaround I can just set <FlatSharpNullable>false</FlatSharpNullable> on all projects I guess

So, even with GreedyyMutable, FlatBuffers supports the concept of null, which is why FlatSharp emits the annotation. If you want to encode this assertion, consider marking properties as required. This will cause FlatSharp to throw when parsing if it encounters a null property that should be there.

It's been a while since I've read the file format's documentation and it might also be that the specific implementation that is used in our case might handle this differently so correct me if i'm wrong; but doesn't it just assign it as 'default' if it's 'null' meaning most things can't actually be null

Oh but that's actually already happening here, you only assign nullable to objects and lists. I see.

Right I guess not much else we can do then to add required where I know for sure our data will never be default/null