Skip to content

Remove create_enum and create_extensible_enum macros #1846

@heaths

Description

@heaths

LSP refactoring tools and LLMs have problems with the create_enum and create_extensible_enum macros because they aren't defined as enums e.g., Copilot will grep for "enum EnumName" and won't find it.

While the macros are handy, proc macros are just code generators. And we already will generate most of our code via Azure/typespect-rust. Thus, we should just expand the enums we have now in core and other hand-written files.

The emitter already has an issue to remove use of them: Azure/typespec-rust#611

And rather than create a proc macro as the original description here describes, as the discussion below points out: with all the "wrapping" of serde attributes we could do but probably shouldn't, we end up having to type 90% or more of the enum anyway e.g., the type declaration, the variants, serde attributes, other derives e.g., SafeDebug, etc. We could even mark the non-unknown variants as #[safe(true)] because they are defined values, but leave the whole type as unsafe so that the UnknownValue isn't traced by default.

And given the complexity of writing, debugging, and maintaining a proc macro, it's just not worth it for the last 10% or less when we already use a code emitter for more code.

Metadata

Metadata

Assignees

Labels

Azure.CoreThe azure_core crateClientThis issue points to a problem in the data-plane of the library.blocking-releaseBlocks releasehelp wantedThis issue is tracking work for which community contributions would be welcomed and appreciated

Type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions