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

fix the float based enum issue #4725

Merged
merged 6 commits into from
May 20, 2024

Conversation

ArcturusZhang
Copy link
Member

@ArcturusZhang ArcturusZhang commented May 17, 2024

Fixes #4724

Description

Our float based enums are generated as based on int if all existing values are ints. For code examples please check the above issue.

This is incorrect and fixing it could be a breaking change - because the ctor changes for that enum:

public FloatExtensibleEnum(float value) // <- this is `int value` before fixing

but we could get breaking changes if we do not fix it, and users cannot put float values into this enum which is just wrong.

Checklist

To ensure a quick review and merge, please ensure:

  • The PR has a understandable title and description explaining the why and what.
  • The PR is opened in draft if not ready for review yet.
    • If opened in draft, please allocate sufficient time (24 hours) after moving out of draft for review
  • The branch is recent enough to not have merge conflicts upon creation.

Ready to Land?

  • Build is completely green
    • Submissions with test failures require tracking issue and approval of a CODEOWNER
  • At least one +1 review by a CODEOWNER
  • All -1 reviews are confirmed resolved by the reviewer
    • Override/Marking reviews stale must be discussed with CODEOWNERS first

@ArcturusZhang ArcturusZhang merged commit c1cacc8 into Azure:feature/v3 May 20, 2024
8 checks passed
@ArcturusZhang ArcturusZhang deleted the fix-float-based-enums branch May 20, 2024 04:02
@@ -76,32 +76,7 @@ public static InputEnumType CreateEnumType(ref Utf8JsonReader reader, string? id
throw new JsonException("Enum must have at least one value");
}

InputPrimitiveType? currentType = null;
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the value type creation and validation? we may still need check the enum value types consistence.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will introduce a fix for this in a new PR to make it throws a proper exception

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

Successfully merging this pull request may close these issues.

float based enums are generated as int
3 participants