Open iikuzmychov opened 1 year ago
I have an issue using Camelize() method. It works not exactly as I expected.
Camelize()
The next code
"IOModule".Camelize()
will return
"iOModule"
while I'm expecting
"ioModule"
I think it's a bug, we do need respect acronyms on camelizing strings.
I took the original code of Camelize() method and reworked it a bit:
public static string CamelizeRespectingAcronyms(this string input) { var pascalized = input.Pascalize(); if (pascalized.Length == 0) { return pascalized; } var firstUpperSymbolsCount = pascalized.TakeWhile(char.IsUpper).Count(); if (firstUpperSymbolsCount > 2) { var acronymLength = firstUpperSymbolsCount - 1; return pascalized[..acronymLength].ToLower() + pascalized[acronymLength..]; } return pascalized[..1].ToLower() + pascalized[1..]; }
The update method is returning
for
"IOModule".Capitilize()
IMO there should also be an option to choose if we want to camelize acronyms such as “some_JSON_data” to > “someJsonData” or “SomeJSONData”. I can prepare some PR later, I am new here and want to look around
Issue
I have an issue using
Camelize()
method. It works not exactly as I expected.Example
The next code
will return
while I'm expecting
I think it's a bug, we do need respect acronyms on camelizing strings.
Proposed solution
I took the original code of
Camelize()
method and reworked it a bit:The update method is returning
for