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

Underscores are not handled correctly as attributes #66

Open
sahin52 opened this issue Feb 22, 2023 · 2 comments
Open

Underscores are not handled correctly as attributes #66

sahin52 opened this issue Feb 22, 2023 · 2 comments

Comments

@sahin52
Copy link

sahin52 commented Feb 22, 2023

public class Testing
{
        public int Success { get; set; }
        public int GU_ID { get; set; }
        public int GUID { get; set; }
        public int G_UID { get; set; }
        public int _GUID { get; set; }
        public int GUID_ { get; set; }
}
public enum TestEnum
{
        GU_ID,
        _GUID,
        GUID,
        GUID_
}

is converted to this:

export interface Testing {
        success: number;
        guid: number;
        guid: number;
        gUID: number;
        guid: number;
        guid: number;
    }
    export enum TestEnum {
        GU_ID = 0,
        _GUID = 1,
        guid = 2,
        GUID_ = 3,
    }

As you see, the underscore is not correctly handled in class attributes, it is removed, but it is correctly handled in enums.
my config is like this:

{
    "include": [
        ".\\BO\\**\\*.cs"
    ],
    "exclude": [
    ],
    "namespace": "\"ApiTypes\"",
    "output": "types.d.ts",
    "camelCase": true,
    "camelCaseEnums": false,
    "camelCaseOptions": {
        "pascalCase": false,
        "preserveConsecutiveUppercase": true,
        "locale": "en-US"
    },
    "numericEnums": true,
    "stringLiteralTypesInsteadOfEnums": false,
    "customTypeTranslations": {
        "char": "string",
        "Exception":"any"
    }
}

I'd love to try to solve this problem, if you would merge it to the project.

@sahin52
Copy link
Author

sahin52 commented Feb 22, 2023

Oops, after research, I saw that it is related to camelCase option. But there is no option to not remove underscore in camelCase. But if I don't use camelCase, the generated types will start with upper case.
I may close this issue, but I still want a way to make attributes start with lower case and preserve the underscore.

@sahin52
Copy link
Author

sahin52 commented Feb 22, 2023

Created this pull request: #67 which will solve this problem. If you have the same problem, you can add a config like this after using this pull request:

{
    "lowerFirstLetters": true,
    "include": [
        "C:\\X\\Y\\Z\\**\\*.cs"
    ],
    "exclude": [
    ],
    "namespace": "\"Api\"",
    "output": ".\\types.d.ts",
    "camelCase": false,
    "camelCaseEnums": true,
    "numericEnums": true,
    "stringLiteralTypesInsteadOfEnums": false,
    "customTypeTranslations": {
        "char": "string"
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant