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

CamelCase bug #146

Closed
jods4 opened this issue Nov 3, 2016 · 1 comment
Closed

CamelCase bug #146

jods4 opened this issue Nov 3, 2016 · 1 comment

Comments

@jods4
Copy link

jods4 commented Nov 3, 2016

CamelCase incorrectly transforms IsIG to isig. Expected result is isIG.

The bug seems to be this condition

if (i > 0 && hasNext && char.IsUpper(chars[i + 1]) == false)
{
  break;
}
chars[i] = char.ToLowerInvariant(chars[i]);

It fails when i == 0 and the next character is lower case.
I think a more correct logic would be to always lowercase i == 0, then continue if the current char and the next one both are uppercase.
Something like (untested):

if (i > 0 && !(char.IsUpper(chars[i]) && hasNext && char.IsUpper(chars[i + 1])))
  break;

Note: I am unsure what the correct behavior is for ABC. Code above results in abC.

@frhagn
Copy link
Owner

frhagn commented Nov 6, 2016

Good find @jods4, fixed in 1.8.2

@frhagn frhagn closed this as completed Nov 6, 2016
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

2 participants