Skip to content

Keep uppercasing a contraction's suffixes past its second apostrophe [patch] - #163

Merged
matt-edmondson merged 3 commits into
mainfrom
fix/multi-apostrophe-contractions-109
Nov 11, 2026
Merged

matt-edmondson merged 3 commits into
mainfrom
fix/multi-apostrophe-contractions-109

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #109

What was wrong

"I'd've".ToSnakeCase() gave i_dve and "Y'all'd" gave yal_ld. Their lowercase spellings give idve and yalld.

ReplaceNonAlphaNumericWithSpace uppercases a lowercase suffix that follows a capital (CEO's → CEOS), so the word reads as one all-caps run. That decision was made again at each apostrophe, from the letter just before it. At the second apostrophe of I'd've, the lowercase d turned it off. The result was IDve, which SplitOnCaseChange then split into an acronym and a word.

Change

Once a word's suffix is being uppercased, its later lowercase suffixes are uppercased too, until the word ends. The flag is still reset at a real separator, as before. This is the first bullet of the issue's suggested fix.

The other two bullets from the issue were not needed. The rock'N'roll and a'B'c rows already gave Rocknroll / Abc on current main, because the lowercaseSuffix / lowercaseNextLetter work landed after the issue was filed. a'B'c still disagreed between Title→snake and snake, though, and this change fixes that.

Input snake before snake after Pascal before Pascal after
I'd've i_dve idve IDve Idve
Y'all'd yal_ld yalld YalLd Yalld

Tests

  • New: AContractionWithSeveralApostrophesShouldConvertLikeItsLowercaseForm. It covers every row in the issue table, plus U+2019, Y'all'd've and CEO's's. Each input must convert like its all-lowercase form in Pascal, camel, snake, kebab and MACRO, and Title→snake must match snake.
  • New: AContractionWithSeveralApostrophesShouldStayOneWord. It checks the expected outputs from the issue directly.
  • With the fix reverted, 7 of the new cases fail.
  • Full suite on Linux / .NET 10: 282/282 passed. dotnet build CaseConverter.sln builds every target with no warnings.

Not covered: a mixed-case later suffix such as I'd'VE still gives i_dve, which is outside this issue's table.

Merge note: #162 (fixes #161) edits the same uppercaseSuffix statement. Whichever PR lands second needs a one-line rebase that keeps both conditions.


Generated by Claude Code

…[patch]

"I'd've".ToSnakeCase() gave "i_dve" and "Y'all'd" gave "yal_ld", where the
lowercase spellings give "idve" and "yalld".

ReplaceNonAlphaNumericWithSpace uppercases a lowercase suffix after a capital
("CEO's" -> "CEOS") so the word reads as one all-caps run. The decision was
made afresh at each apostrophe from the letter before it, so at the second
apostrophe of "I'd've" the lowercase "d" switched it off, giving "IDve", which
SplitOnCaseChange split as an acronym plus a word. Once a word's suffix is
being uppercased, its later lowercase suffixes now are too, until the word
ends.

Fixes #109

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW4bh3rDc6opLckXQGb
The #109 condition took ReplaceNonAlphaNumericWithSpace's cognitive
complexity from 15 to 16, over Sonar's S3776 limit. The decision now lives
in its own method, with the comment that explained it. Behaviour is
unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW4bh3rDc6opLckXQGb
…contractions-109

# Conflicts:
#	CaseConverter.Test/CaseConverterTests.cs
#	CaseConverter/CaseConverter.cs
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 91ceb04 into main Nov 11, 2026
15 checks passed
@matt-edmondson
matt-edmondson deleted the fix/multi-apostrophe-contractions-109 branch November 11, 2026 01:43
matt-edmondson pushed a commit that referenced this pull request Nov 11, 2026
#163 already moved the apostrophe-suffix condition into UppercasesSuffix, which
resolves the same S3776 complexity finding, so take main's line and drop the
now-unused IsSuffixUppercasedOntoCapital helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW2QxLJ6PwV5nQrv4Us
matt-edmondson pushed a commit that referenced this pull request Nov 11, 2026
Resolve the conflict with #163 in ReplaceNonAlphaNumericWithSpace:
CaseSuffixAfterApostrophe keeps the plural-acronym branch and now takes
its uppercase decision from main's UppercasesSuffix, so a later lowercase
suffix of an uppercased word stays uppercased (#109).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW4bDHFRUmCXATBKDFr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants