What's wrong
CaseConverter/CaseConverter.cs:35-56, ReplaceNonAlphaNumericWithSpace, turns an apostrophe into a space. It is used by the Pascal/Camel path (~line 327) and by the Snake/Kebab/Macro path (~line 399). The letters after an apostrophe therefore become a separate word:
| Input |
Method |
Actual |
Expected |
"don't stop" |
ToPascalCase |
"DonTStop" |
"DontStop" |
"don't stop" |
ToCamelCase |
"donTStop" |
"dontStop" |
"don't stop" |
ToSnakeCase |
"don_t_stop" |
"dont_stop" |
"don't stop" |
ToMacroCase |
"DON_T_STOP" |
"DONT_STOP" |
"o'neil" |
ToPascalCase / ToSnakeCase |
"ONeil" / "o_neil" |
"Oneil" / "oneil" |
Reproduced with MSTest asserts.
Why it matters
Generating identifiers, slugs or constant names from human text such as UI labels or titles is a primary use case, and contractions are common in that text. ToTitleCase was fixed in d8bdab2 to keep "Don't" as one word, so the sibling methods now disagree with it. Lodash and similar libraries strip in-word apostrophes (lodash's reApos step) for this reason.
Suggested fix
In ReplaceNonAlphaNumericWithSpace, drop ' and U+2019 (right single quotation mark) when they sit between two letters, instead of replacing them with a space. Apostrophes elsewhere (leading or trailing quotes) can keep acting as separators.
Acceptance: every row above produces the expected output, with tests for both the ASCII ' and U+2019.
What's wrong
CaseConverter/CaseConverter.cs:35-56,ReplaceNonAlphaNumericWithSpace, turns an apostrophe into a space. It is used by the Pascal/Camel path (~line 327) and by the Snake/Kebab/Macro path (~line 399). The letters after an apostrophe therefore become a separate word:"don't stop"ToPascalCase"DonTStop""DontStop""don't stop"ToCamelCase"donTStop""dontStop""don't stop"ToSnakeCase"don_t_stop""dont_stop""don't stop"ToMacroCase"DON_T_STOP""DONT_STOP""o'neil"ToPascalCase/ToSnakeCase"ONeil"/"o_neil""Oneil"/"oneil"Reproduced with MSTest asserts.
Why it matters
Generating identifiers, slugs or constant names from human text such as UI labels or titles is a primary use case, and contractions are common in that text.
ToTitleCasewas fixed in d8bdab2 to keep"Don't"as one word, so the sibling methods now disagree with it. Lodash and similar libraries strip in-word apostrophes (lodash'sreAposstep) for this reason.Suggested fix
In
ReplaceNonAlphaNumericWithSpace, drop'andU+2019(right single quotation mark) when they sit between two letters, instead of replacing them with a space. Apostrophes elsewhere (leading or trailing quotes) can keep acting as separators.Acceptance: every row above produces the expected output, with tests for both the ASCII
'andU+2019.