FlatSharp icon indicating copy to clipboard operation
FlatSharp copied to clipboard

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

Open vvuk opened this issue 1 year ago • 1 comments

[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.

vvuk avatar Sep 15 '22 21:09 vvuk

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 avatar Sep 17 '22 23:09 jamescourtney

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

jamescourtney avatar Oct 06 '22 18:10 jamescourtney