jamescourtney / FlatSharp

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

Some questions #358

Closed ZensYue closed 1 year ago

ZensYue commented 1 year ago

There are some problems here. The generated code is too long。The code generated according to FlatBufferDeserializationOption supports four cases, but we usually only need to use one of them for a module. Whether there is a plan to support the export of specified FlatBufferDeserializationOption. I tried to modify the code of several files, and finally it was generated successfully. image CompilerOptions.cs: image FlatSharpCompiler.cs: image

and so on...

I haven't seen the code specification document. I hope you can implement it. Hopes FlatSharp will get better and better.

There are two other questions:

  1. The FlatSharp.generated.cs file already exists, and the code will not be regenerated.
  2. Customizing the name of the​ FlatSharp.generated.cs file is not supported now. Is there a plan to support it?
jamescourtney commented 1 year ago

Hello -- thanks for your comment. I have a few questions for you:

The generated code is too long

I understand that FlatSharp v7 is more aggressive about generating code. This was an intentional choice and I know the code can be longer. However, it is my understanding that...

If you could explain your scenario and why this is a problem that would be very helpful. Your suggestion of adding a compiler switch to export deserialization modes is interesting and is something I can consider once I understand your scenarios more thoroughly.

I haven't seen the code specification document.

Can you elaborate on what you are looking for here? All of the available docs for FlatSharp are in the wiki.

The FlatSharp.generated.cs file already exists, and the code will not be regenerated.

In the header of the generated file is a SHA256 hash of the input FBS files and FlatSharp compiler version. If the FBS files have not changed, then the code won't regenerate. This is because the FlatSharp compiler can be slow for a full invocation.

Customizing the name of the​ FlatSharp.generated.cs file is not supported now. Is there a plan to support it?

There's no reason in principle this couldn't be supported. However, FlatSharp expects you to pass in all your .FBS files in one invocation: dotnet FlatSharp.Compiler.dll -i "file1.fbs;file2.fbs;file3.fbs", so my expectation was that there wasn't a need for more granular names.

ZensYue commented 1 year ago

Thank You~ I'm a Unity developer.

The generated code is too long

The files generated by unity through Il2cpp will be longer.

I haven't seen the code specification document.

I hope to submit a pull request according to the code specification to share a share of strength with the flatsharp community.

In the header of the generated file is a SHA256 hash of the input FBS files and FlatSharp compiler version. If the FBS files have not changed, then the code won't regenerate. This is because the FlatSharp compiler can be slow for a full invocation.

I got it.

Customizing the name of the​ FlatSharp.generated.cs file is not supported now. Is there a plan to support it?

The places where flatsharp is used are game configuration and network protocol. These two modules will be maintained and modified by two groups of people.