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

Convert invalid hyphens to underscores for Android #159

Merged
merged 1 commit into from
Jul 13, 2018

Conversation

morewry
Copy link

@morewry morewry commented Jul 4, 2018

Fixes #158.

According to the Android developers I work with, hyphens (-) are not valid in resource identifier names. I wasn't able to find an official, specific source verifying this, however, I noted that none of the resource examples https://developer.android.com/guide/topics/resources/providing-resources showed hyphens, while many showed underscores (_).

This answer on StackOverflow states that Android resource identifier names must conform to the rules for Java identifiers, which are restricted to letters, digits, underscore, and dollar sign:

The "Java letters" include uppercase and lowercase ASCII Latin letters A-Z (\u0041-\u005a), and a-z (\u0061-\u007a), and, for historical reasons, the ASCII dollar sign ($, or \u0024) and underscore (_, or \u005f). The dollar sign should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems. The underscore may be used in identifiers formed of two or more characters, but it cannot be used as a one-character identifier due to being a keyword.

The "Java digits" include the ASCII digits 0-9 (\u0030-\u0039).

My implementation approach is to specifically address hyphens as a common input and directly convert them to underscores in an attempt to preserve authorial intent. See #160

Normally, I would have added a test case for something like this, but see #161.

@salesforce-cla
Copy link

salesforce-cla bot commented Jul 4, 2018

Thanks for the contribution! Before we can merge this, we need @CH-RhyMoore to sign the Salesforce.com Contributor License Agreement.

@aputinski aputinski merged commit 0540d75 into salesforce-ux:master Jul 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants