jamescourtney / FlatSharp

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

Add fs_preserveCase attribute for members, to allow preserving identical case as in fbs #305

Closed vvuk closed 1 year ago

vvuk commented 2 years ago

[Apologies for large number of issues -- I am happy to tackle all/most of these, just want to get a sense of whether they would be accepted or other thoughts!]

given

struct Vec3 {
   x: float;
..

with --normalize-field-names, this would end up with a field named X. This is sometimes not what you want, especially with single-letter fields. Would be nice to be able to say x: float (fs_preserveCase); and have the field be generated exactly as declared in the fbs file.

jamescourtney commented 2 years ago

I think this is a good idea. I'm always open to pull requests if you want to contribute this. Between work and baby, I don't have tons of time to invest in FlatSharp right now; however, I'm very happy to look at PRs!

I don't think the fix will be terribly profound. Usually with attributes like this, I try to make them apply on both the table/struct level, as well as the field level. So this layout would result in this result:

table fooTable (fs_preserveCase)
{
   x : int (fs_perserveCase:"false");
   y : int;
}
public class fooTable
{
    public int X { get; set }
    public int y { get; set; }
}

The NonVirtual documentation should apply for this as well I'd think.

jamescourtney commented 1 year ago

This has been merged. I'll get it published in 6.3.4.