Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Enum-typed attributes #383

Open
kennethloeffler opened this issue Jan 24, 2024 · 2 comments
Open

Add support for Enum-typed attributes #383

kennethloeffler opened this issue Jan 24, 2024 · 2 comments

Comments

@kennethloeffler
Copy link
Member

Roblox added support for Enum attributes in 570. rbx-dom currently lacks support for them, but they're probably uncommon since they're not yet available in Roblox Studio's attribute type picker UI.

@Dekkonot
Copy link
Member

Dekkonot commented Feb 1, 2024

It turns out that Enum attributes require us to store the name of the Enum that the EnumItem we're referring to is a part of. This makes sense, in hindsight, but it means that supporting these is going to be potentially complex since we have to start tagging enums with their names in some capacity.

My thoughts are that we modify the Enum type in rbx_types to also hold an Option<String> (or something akin to that) and then rbx_binary and rbx_xml (and other consumers) can fill that in if necessary. Then when serializing enums, we would raise an error if it didn't a name. It feels appropriately simple and doesn't require us to pull reflection info into anywhere new.

@Dekkonot
Copy link
Member

Dekkonot commented May 6, 2024

Okay I have bad news: Serde's derive macro is not powerful enough to accomplish what I was hoping to above. This means we'll have to implement a potentially complex serializer and deserializer for Enums if we use the existing struct.

My main concern is that Rojo users rely upon the serde format for enums to be stable, so the easy solutions are out the window: if we represent Enum as a struct instead of a newtype, it breaks the serde format.

It's also possible I have massively overcomplicated things so I'm interested to hear others thoughts on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants