Skip to content

Conversation

@avodovnik
Copy link
Contributor

No description provided.

if (member.kind === 'method' || member.kind === 'property') {
// this should be easy to name... let's call it the same as the argument (eternal optimist)
let probableName = `${parent.name}${translateMemberName(``, name, null)}`;
if (specialNameResolutionMap.has(probableName))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I mentioned in the chat it'd be nice if the list had only exceptions and most of the names would be generated in accord with some common rule (like ParamName or ClassParamName etc). While SelectOption looks like an exception Position could probably be derived by a common rule. We'll need this mapping at least in one more place - playwright.dev generator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's a valid point.

I've gone and improved this so the names now being generated follow a logical rule. The only "special case" I had to add was for names that are too generic, like value, which gets translated to SelectOptionValue. But still, I'm much happier with this iteration.

@avodovnik avodovnik changed the title chore(dotnet): adds name maps to make generated names friendlier chore(dotnet): improve name generation for objects Mar 18, 2021
@avodovnik avodovnik requested a review from yury-s March 18, 2021 16:09
}
while (true) {
// crude attempt at removing plurality
if (attemptedName.endsWith('s'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is brittle, will fail on names like properties. Perhaps whitelist known names?

Copy link
Contributor Author

@avodovnik avodovnik Mar 18, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, to some extent... But also, we only have a few of these that are actually plural, so I can work around with something like

if (attemptedName.endsWith('s') && !attemptedName === 'properties')

:-)

When we add something that'll break this simple logic, I can always revisit this... It's the same if I have to add a map entry, or a check, right?

@avodovnik avodovnik merged commit 3a27bdd into microsoft:master Mar 23, 2021
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

Successfully merging this pull request may close these issues.

2 participants