Flatc schema style conversion

98 views
Skip to first unread message

Kevin K

unread,
Sep 16, 2020, 7:04:59 PM9/16/20
to FlatBuffers
Hey all,

I've noticed that flatc does some automatic style conversion when generating the serializer/deserializer class.

For example let's say I have a JSON file and a fbs schema for that JSON.
The field names in the JSON are all written in snake_case, like so:
   {
      "id": "some id",
      "name_of_this_thing": "name",
      "a_numerical_field": 3
   }

The .fbs schema file is written to accommodate that, like so:
   namespace "Data";
   table SomeDataTable {
      id:string;
      name_of_this_thing:string;
      a_numerical_field:int;
   }

However, when I run flatc on the schema file to generate the C# classes with the --gen-object-api option, it will apply a style conversion on all the field names and the auto-generated code will be in UpperCamelCase, like so:
   public string Id { get; set; }
   public string NameOfThisThing { get; set; }
   public int ANumericalField { get; set; }

I realize this is a weird ask, but is it possible to NOT have that automatic style conversion happen? Basically I'm writing a GUI tool for designers to use for data editing/creation (as opposed to having designers try to hand-edit json). To support that tool, I've been adding C# attributes to certain data classes to surface those flatbuffer fields as editable fields in the tool, but since the JSON is currently expected to be in snake_case instead of UpperCamelCase, there is a breakage there.
That may be kind of a bad explanation of my use case but basically I'm wondering if there's an undocumented optional flag or something I can use to tell flatc not to apply the style conversion.

Thanks in advance,
Kevin

Wouter van Oortmerssen

unread,
Sep 17, 2020, 12:29:32 PM9/17/20
to Kevin K, FlatBuffers
Yes, we convert to each language's desired style guide automatically.
There could potentially be a way to disable this, if anyone wants to make a PR for it.

--
You received this message because you are subscribed to the Google Groups "FlatBuffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flatbuffers...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flatbuffers/0889a2fa-4787-450a-8844-4e3454100c72n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages