jamescourtney / FlatSharp

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

Generated C# from fbs file compiler issues with namespaces #277

Closed joejo-unity closed 2 years ago

joejo-unity commented 2 years ago

All binaries are latest from NuGet.

The generated C# errors out on FlatSharp.Compiler and FlatSharp.FlatBufferDeserializationOption generated code. Slapping global:: in front of them to pick up the context previously generated in the file seems to resolve that. Example:

public FlatSharp.FlatBufferDeserializationOption DeserializationOption => FlatSharp.FlatBufferDeserializationOption.GreedyMutable;

changed to --->

public global::FlatSharp.FlatBufferDeserializationOption DeserializationOption => global::FlatSharp.FlatBufferDeserializationOption.GreedyMutable;

jamescourtney commented 2 years ago

Can you share some more details?

Thanks!

joejo-unity commented 2 years ago

On Mon, Feb 7, 2022 at 7:55 PM James Courtney @.***> wrote:

Can you share some more details?

  • Are you compiling in Unity? Does Unity support global:: for fully-qualified namespaces?

Yes

-

  • What version of FlatSharp worked well? What version is now broken (6.1.x, I assume?)

6.1.1, is the only version I’ve ever used since this is the first time I’m looking at flatsharp.

-

  • Anything else you think is relevant for me to reproduce.

Here’s the fbs file I used.

[image: File] adbook.flatsharp.fbs https://drive.google.com/file/d/1-LpZeZG6QwtdkdjuMFRgoBjyBcyrveQa/view?usp=drivesdk

-

Thanks!

— Reply to this email directly, view it on GitHub https://github.com/jamescourtney/FlatSharp/issues/277#issuecomment-1032187577, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQI6O4BTU4USOIISF6GF3LU2CHZLANCNFSM5NY6JY7A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

-- Joseph Jones Senior Software Engineer Unity3D

jamescourtney commented 2 years ago

Thanks for posting that FBS file; I've requested access that you'll probably need to approve before I can actually see it.

joejo-unity commented 2 years ago

Done

On Tue, Feb 8, 2022 at 8:37 PM James Courtney @.***> wrote:

Thanks for posting that FBS file; I've requested access that you'll probably need to approve before I can actually see it.

— Reply to this email directly, view it on GitHub https://github.com/jamescourtney/FlatSharp/issues/277#issuecomment-1033339771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQI6O2LSBNSAZOWKGMXQW3U2HVQNANCNFSM5NY6JY7A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

-- Joseph Jones Senior Software Engineer Unity3D

jamescourtney commented 2 years ago

That helps a ton, thank you. So the word FlatSharp is part of your namespace, so the resolution gets confused. I've been gradually trying to shift to using global:: in more places, though I'm clearly not done yet :) There are just a lot of places in the generated code where FlatSharp needs to emit a type name.

I'm going to mark this as a bug though I'm not sure about the timeline for addressing it. In the meantime, you should be able to work around this by using anything besides FlatSharp in your namespaces.

joejo-unity commented 2 years ago

Cool, thanks!

On Tue, Feb 8, 2022 at 8:49 PM James Courtney @.***> wrote:

That helps a ton, thank you. So the word FlatSharp is part of your namespace, so the resolution gets confused. I've been gradually trying to shift to using global:: in more places, though I'm clearly not done yet :) There are just a lot of places in the generated code where FlatSharp needs to emit a type name.

I'm going to mark this as a bug though I'm not sure about the timeline for addressing it. In the meantime, you should be able to work around this by using anything besides FlatSharp in your namespaces.

— Reply to this email directly, view it on GitHub https://github.com/jamescourtney/FlatSharp/issues/277#issuecomment-1033346195, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFQI6O62KPSCV3E7K54YBT3U2HW5TANCNFSM5NY6JY7A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

-- Joseph Jones Senior Software Engineer Unity3D