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

GenAPI formatting of enums #44999

Open
PranavSenthilnathan opened this issue Nov 21, 2024 · 0 comments
Open

GenAPI formatting of enums #44999

PranavSenthilnathan opened this issue Nov 21, 2024 · 0 comments
Labels
Area-GenAPI untriaged Request triage from a team member

Comments

@PranavSenthilnathan
Copy link
Member

GenAPI can emit enum member values in hex or left-shift formats if the enum has FlagsAttribute. For example, see CompareOptions. While the generated file isn't designed for readability, it does make it easier to review.

Actual:

[System.FlagsAttribute]
public enum CompareOptions
{
    None = 0,
    IgnoreCase = 1,
    IgnoreNonSpace = 2,
    IgnoreSymbols = 4,
    IgnoreKanaType = 8,
    IgnoreWidth = 16,
    OrdinalIgnoreCase = 268435456,
    StringSort = 536870912,
    Ordinal = 1073741824,
}

Expected:

[System.FlagsAttribute]
public enum CompareOptions
{
    None = 0,
    IgnoreCase = 1 << 0,
    IgnoreNonSpace = 1 << 1,
    IgnoreSymbols = 1 << 2,
    IgnoreKanaType = 1 << 3,
    IgnoreWidth = 1 << 4,
    OrdinalIgnoreCase = 1 << 28,
    StringSort = 1 << 29,
    Ordinal = 1 << 30,
}

or

[System.FlagsAttribute]
public enum CompareOptions
{
    None = 0x00000000,
    IgnoreCase = 0x00000001,
    IgnoreNonSpace = 0x00000002,
    IgnoreSymbols = 0x00000004,
    IgnoreKanaType = 0x00000008,
    IgnoreWidth = 0x00000010,
    OrdinalIgnoreCase = 0x10000000,
    StringSort = 0x20000000,
    Ordinal = 0x40000000,
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-GenAPI untriaged Request triage from a team member
Projects
None yet
Development

No branches or pull requests

1 participant