Skip to content

Conversation

@haiyuazhang
Copy link
Member

When an API operation returns an extensible enum type (a readonly struct wrapping a string), the generator incorrectly emitted TypeName.FromResponse(result) which doesn't exist on enum structs. This fix checks IsEnum on the response type and generates 'new TypeName(result.Content.ToString())' instead.

Contributing to the Azure SDK

Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.

For specific information about pull request etiquette and best practices, see this section.

When an API operation returns an extensible enum type (a readonly struct
wrapping a string), the generator incorrectly emitted TypeName.FromResponse(result)
which doesn't exist on enum structs. This fix checks IsEnum on the response
type and generates 'new TypeName(result.Content.ToString())' instead.
Copilot AI review requested due to automatic review settings February 8, 2026 10:00
@github-actions github-actions bot added CodeGen Issues that relate to code generation Mgmt This issue is related to a management package. labels Feb 8, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes management generator output for operations whose response type is an enum/extensible-enum (readonly struct over string), where the generator previously emitted a non-existent TypeName.FromResponse(result) call.

Changes:

  • Add an IsEnum check when generating Response.FromValue(...) for generic responses.
  • For enum/extensible-enum response types, generate a direct construction of the response value instead of calling FromResponse.
  • Keep existing T.FromResponse(result) generation for model response types.

@haiyuazhang haiyuazhang merged commit cdf1f42 into Azure:main Feb 9, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CodeGen Issues that relate to code generation Mgmt This issue is related to a management package.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants