Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Allow reserved C# keywords as enum values #22

@phojnacki

Description

@phojnacki

Hi , I have to use reserved C# keyword "in" as enum symbol (in for inch):

{
"name": "DimensionUnits",
"type": {
  "type": "enum",
  "name": "DimensionUnitOfMeasure",
  "symbols": [
    "mm",
    **"in"**
  ]
}

I can achieve that in avrogen.exe by adding @ before symbol name in CodeGen.cs: (line 309)

foreach (string symbol in enumschema.Symbols)
{
    var alwaysAllowedSymbol = symbol;
    if (CodeGenUtil.Instance.ReservedKeywords.Contains(symbol))
        alwaysAllowedSymbol = '@' + symbol;
    CodeMemberField field = new CodeMemberField(typeof(int), alwaysAllowedSymbol);
    ctd.Members.Add(field);
}

Can we add it to official source code? Thanks. If not, could you provide me with explanation (maybe I could figure it out).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions