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

Avoid reserved names in codegen #1324

Open
thomas11 opened this issue Feb 23, 2024 · 0 comments
Open

Avoid reserved names in codegen #1324

thomas11 opened this issue Feb 23, 2024 · 0 comments
Labels
area/codegen kind/enhancement Improvements or new features

Comments

@thomas11
Copy link
Contributor

Prompted by pulumi/pulumi-azure-native#3106: an addition to the Azure spec introduced an enum with the unfortunate name "string" (for which I'll file an upstream issue as well). In the schema, this translated to

        "azure-native:databasewatcher/v20230901preview:String": {
            "description": "The target collection status.",
            "type": "string",
            "enum": [
                {
                    "name": "Enabled",
                    "description": "Denotes a target that is enabled.",
                    "value": "Enabled"
                },
                {
                    "name": "Disabled",
                    "description": "Denotes a target that is disabled.",
                    "value": "Disabled"
                }
            ]
        },

and in the generated Java, to public enum String.

That doesn't compile:

/home/runner/work/pulumi-azure-native/pulumi-azure-native/sdk/java/src/main/java/com/pulumi/azurenative/databasewatcher/enums/String.java:39: error: toString() in com.pulumi.azurenative.databasewatcher.enums.String cannot override toString() in Enum
        public String toString() {
                      ^
  return type com.pulumi.azurenative.databasewatcher.enums.String is not compatible with java.lang.String
/home/runner/work/pulumi-azure-native/pulumi-azure-native/sdk/java/src/main/java/com/pulumi/azurenative/databasewatcher/enums/String.java:38: error: method does not override or implement a method from a supertype
        @Override
        ^
/home/runner/work/pulumi-azure-native/pulumi-azure-native/sdk/java/src/main/java/com/pulumi/azurenative/databasewatcher/enums/String.java:42: error: incompatible types: java.lang.String cannot be converted to com.pulumi.azurenative.databasewatcher.enums.String
                .toString();

It would be great if the Java codegen could automatically detect the use of reserved names and work around it by modifying the name.

@thomas11 thomas11 added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team area/codegen and removed needs-triage Needs attention from the triage team labels Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/codegen kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

1 participant