You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "clemensv (via GitHub)" <gi...@apache.org> on 2024/03/04 10:27:23 UTC
[PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
clemensv opened a new pull request, #2783:
URL: https://github.com/apache/avro/pull/2783
## What is the purpose of the change
This eliminates a blocking issue where code-gen throws while generating code for this enum:
```json
{
"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
```csharp
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
Posted by "zcsizmadia (via GitHub)" <gi...@apache.org>.
zcsizmadia commented on PR #2783:
URL: https://github.com/apache/avro/pull/2783#issuecomment-1981138387
> @zcsizmadia The Jira issue is still opened.
I dont seem to have teh right to close that ticket. @clemensv Could you close the JIRA ticket plz?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
Posted by "KalleOlaviNiemitalo (via GitHub)" <gi...@apache.org>.
KalleOlaviNiemitalo commented on PR #2783:
URL: https://github.com/apache/avro/pull/2783#issuecomment-1976733236
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
Posted by "zcsizmadia (via GitHub)" <gi...@apache.org>.
zcsizmadia commented on code in PR #2783:
URL: https://github.com/apache/avro/pull/2783#discussion_r1511268112
##########
lang/csharp/src/apache/main/CodeGen/CodeGen.cs:
##########
@@ -498,12 +496,13 @@ protected virtual void processEnum(Schema schema)
foreach (string symbol in enumschema.Symbols)
{
+ var effectiveSymbol = symbol;
if (CodeGenUtil.Instance.ReservedKeywords.Contains(symbol))
{
- throw new CodeGenException("Enum symbol " + symbol + " is a C# reserved keyword");
+ effectiveSymbol = "@" + symbol;
Review Comment:
Could we utilize the `CodeGenUtil.Instance.Mangle(...)` here. Something like `symbol = CodeGenUtil.Instance.Mangle(symbol)`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on PR #2783:
URL: https://github.com/apache/avro/pull/2783#issuecomment-1980326625
@zcsizmadia The Jira issue is still opened.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
Posted by "zcsizmadia (via GitHub)" <gi...@apache.org>.
zcsizmadia commented on PR #2783:
URL: https://github.com/apache/avro/pull/2783#issuecomment-1976731819
Thanks for the PR! Could you add unit tests as well plz?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
Posted by "clemensv (via GitHub)" <gi...@apache.org>.
clemensv commented on PR #2783:
URL: https://github.com/apache/avro/pull/2783#issuecomment-1977280091
@KalleOlaviNiemitalo You are correct. I removed the local check.
@zcsizmadia Overall coverage is fairly light, but I added the test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3953: Prefixing enum member identifiers instead of throwing [avro]
Posted by "zcsizmadia (via GitHub)" <gi...@apache.org>.
zcsizmadia merged PR #2783:
URL: https://github.com/apache/avro/pull/2783
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org