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

AVRO-3953: Prefixing enum member identifiers instead of throwing #2783

Merged
merged 2 commits into from
Mar 5, 2024

Conversation

clemensv
Copy link
Contributor

@clemensv clemensv commented Mar 4, 2024

AVRO-3953

What is the purpose of the change

This eliminates a blocking issue where code-gen throws while generating code for this enum:

{
    "type": "enum",
    "symbols": [
        "string",
        "integer",
        "float",
        "boolean",
        "list",
        "dict",
        "regex"
    ],
    "name": "type",
    "namespace": "com.example"
}

Verifying this change

This change is a trivial rework without any test coverage. It eliminates an apparent misunderstanding of C# syntax. The above now correctly yields

public enum type
{
		@string,
		integer,
		@float,
		boolean,
		list,
		dict,
		regex,
}

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

Signed-off-by: Clemens Vasters <[email protected]>
@github-actions github-actions bot added the C# label Mar 4, 2024
@zcsizmadia
Copy link
Contributor

Thanks for the PR! Could you add unit tests as well plz?

@KalleOlaviNiemitalo
Copy link
Contributor

AFAICT, the C# CodeDom provider itself escapes CodeMemberField.Name if it conflicts with a keyword or starts with a double underscore. In the Microsoft.CSharp.CSharpCodeGenerator class, the GenerateField method calls OutputIdentifier, which calls CreateEscapedIdentifier.

@clemensv
Copy link
Contributor Author

clemensv commented Mar 4, 2024

@KalleOlaviNiemitalo You are correct. I removed the local check.

@zcsizmadia Overall coverage is fairly light, but I added the test.

@zcsizmadia zcsizmadia self-requested a review March 4, 2024 20:35
@zcsizmadia zcsizmadia merged commit 6f362d5 into apache:main Mar 5, 2024
9 checks passed
@martin-g
Copy link
Member

martin-g commented Mar 6, 2024

@zcsizmadia The Jira issue is still opened.

@zcsizmadia
Copy link
Contributor

zcsizmadia commented Mar 6, 2024

@zcsizmadia The Jira issue is still opened.

I dont seem to have the right to close that ticket. @clemensv Could you close the JIRA ticket plz?

RanbirK pushed a commit to RanbirK/avro that referenced this pull request May 13, 2024
…che#2783)

* AVRO-3953

Signed-off-by: Clemens Vasters <[email protected]>

* Unit test added. Removed local check for symbol.

---------

Signed-off-by: Clemens Vasters <[email protected]>
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.

4 participants