jamescourtney / FlatSharp

Fast, idiomatic C# implementation of Flatbuffers
Apache License 2.0
497 stars 50 forks source link

Don't use Nullable properties for GreedyMutable only serializers #401

Closed duckdoom4 closed 1 year ago

duckdoom4 commented 1 year ago

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

duckdoom4 commented 1 year ago

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

jamescourtney commented 1 year ago

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.

duckdoom4 commented 1 year ago

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

duckdoom4 commented 1 year ago

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