Skip to content

Conversation

@codemageddon
Copy link
Contributor

Preserving the original type for the generated enum value

@codemageddon codemageddon requested a review from umputun as a code owner March 31, 2025 21:42
@umputun umputun requested a review from Copilot April 1, 2025 02:58
Copy link

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

This PR updates the generator to preserve the original underlying type for enum values.

  • Updates tests to check for the presence of a type definition (status uint8) in various scenarios
  • Enhances the Generator struct and parsing logic to capture and validate the original type
  • Updates example enum definitions to use uint8 instead of int

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

File Description
internal/generator/generator_test.go Adds test cases to ensure that the type definition is correctly detected
internal/generator/generator.go Introduces an originalType field and updates parsing logic to capture type details
_examples/status/status_enum.go Changes the enum field type from int to uint8
_examples/status/job_status_enum.go Changes the enum field type from int to uint8
Files not reviewed (1)
  • internal/generator/enum.go.tmpl: Language not supported

@codemageddon codemageddon force-pushed the preserve-original-value-type branch from ceda3b9 to d101189 Compare April 1, 2025 04:18
@umputun
Copy link
Member

umputun commented Aug 11, 2025

This feature has been implemented and merged as part of PR #15 (commit 1834756). The generator now preserves the underlying type information (uint8, int32, etc.) in the generated code.

The implementation includes:

  • Extraction of underlying type from AST during parsing
  • Preservation of type in generated code
  • Support for all numeric types (int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, byte, rune)
  • Comprehensive tests for various type preservation

This PR can now be closed as the feature has been delivered in v0.4.0.

@umputun umputun closed this Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants