-
Notifications
You must be signed in to change notification settings - Fork 245
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
feat(jsii): enforce enum names to be UPPER_CASE #541
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No..... enum member names, not type names :-(
packages/jsii/lib/validator.ts
Outdated
@@ -63,13 +64,26 @@ function _defaultValidations(): ValidationFunction[] { | |||
|
|||
function _typeNamesMustUsePascalCase(_: Validator, assembly: spec.Assembly, diagnostic: DiagnosticEmitter) { | |||
for (const type of _allTypes(assembly)) { | |||
if (spec.isEnumType(type)) { continue; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The enum /type/ should be pascal case, just members should be capital
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah i see, totally misread that - so enum values then?
i'll get on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enum members:
export enum MyEnum {
MEMBER_NUMBER_ONE,
MEMBER_FOO,
MEMBER_XOO
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
@@ -1,4 +1,4 @@ | |||
///!MATCH_ERROR: Type names must use PascalCase: My_Enum | |||
///!MATCH_ERROR: Enum names must use TRUMP_CASE: My_Enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope! Just the member names should be TRUMP_CASE
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my Java disposition's are showing - enum names vs enum values. I'll get it updated!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to make a decision about python and .NET. Not sure what's the idiomatic way to express enum members in those languages.
Assert.Equal(EnumFromScopedModule.Value1, obj.LoadFoo()); | ||
obj.SaveFoo(EnumFromScopedModule.Value2); | ||
Assert.Equal(EnumFromScopedModule.Value2, obj.Foo); | ||
Assert.Equal(EnumFromScopedModule.VALUE2, obj.Foo); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait... what's the convention for .NET? Do we want .NET to also use all-caps?
Same question for Python.... @garnaat is it idiomatic to use all caps for enum values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- .NET seems to prefer PascalCase.
- Python looks like ALL_CAPS are good.
So basically, the .NET code generator needs to covert the case for .NET.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a good question. I thought we wanted to avoid dropping into the language specific mangling... let me check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think Pascal casing for both names and values are the idiomatic thing for .NET
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. We wanted to normalize the typescript/jsii source to CAPITALS but then, jsii is all about language-specific idiomacy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. I'll make the changes to the generation of .NET so we can change enum values into PascalCase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we decided we would make the changes for .NET generation to use enum members in PascalCase
outside of this PR.
Should I create an issue for it before resolving this conversation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, "right click, create issue"
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.