Skip to content

Keep a possessive acronym in one piece in Pascal/Camel/Snake/Kebab/Macro [patch] - #93

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/possessive-acronym-split
Sep 28, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/possessive-acronym-split

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #88

What was wrong

Since the #83 fix, ReplaceNonAlphaNumericWithSpace drops an in-word apostrophe, so "CEO's" became "CEOs". The acronym-tail rule in IsWordBoundary (upper, upper, lower) then broke before the last capital, which gave "CE Os". As a result, "CEO's office".ToSnakeCase() returned ce_os_office and "API's".ToPascalCase() returned ApIs.

Change

This takes the second approach the issue suggests. When ReplaceNonAlphaNumericWithSpace drops an in-word apostrophe that follows a capital, and every letter after it is lowercase, it uppercases those letters. "CEO's" then becomes "CEOS", a single all-caps word, and every converter normalizes it the same way as "CEO".

These cases are unchanged:

  • The previous letter is lowercase (don't, o'neil, ceo's).
  • The suffix has a capital (DON'T, O'Neil).
  • The apostrophe is not in-word ('quoted', 80's).

ToTitleCase does not go through this path. The matching Title Case fix for possessive acronyms is #90, in #92.

Tests

New rows in ApostropheWithinWordShouldNotSplitIt, each covering Pascal, Camel, Snake, Kebab and Macro: API's, CEO's office, the CEO's office, NASA's mission, and CEO’s office (U+2019). There is also a DON'T stop guard row, which is unchanged.

With CaseConverter.cs reverted, all 5 possessive rows fail. With the change, all 71 tests pass on net10.0, and the solution builds for every target with 0 warnings.

🤖 Generated with Claude Code

https://claude.ai/code/session_01N3tMVtLPuNwsQF7rUEBTMQ


Generated by Claude Code

…cro [patch]

Dropping the in-word apostrophe from "CEO's" left "CEOs", which the
acronym-tail rule in IsWordBoundary split into "CE Os", so "CEO's office"
became ce_os_office and "API's" became ApIs. When the apostrophe follows a
capital and the letters after it are all lowercase, uppercase them, so the
word is the single all-caps word "CEOS".

Fixes #88

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01N3tMVtLPuNwsQF7rUEBTMQ
@sonarqubecloud

Copy link
Copy Markdown

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.

Possessive all-caps words are split mid-word: "CEO's office".ToSnakeCase() -> "ce_os_office", "API's".ToPascalCase() -> "ApIs"

2 participants