Keep a capitalised apostrophe name like "O'Neil" in one word [patch] - #103
Merged
Merged
Conversation
Dropping an in-word apostrophe left "O'Neil" as "ONeil", which the case-change split then broke into "O Neil", so it converted to o_neil while "o'neil" and "O'NEIL" both gave oneil. Lowercase a capital straight after the apostrophe when the letters around it are lowercase: the letter after it when there is one, otherwise the letter before the apostrophe. "O'NEIL" and "DON'T" keep their capitals. Fixes #96 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AtF6Ynq3K6Km6HSRHaKuX8
… complexity in bounds Sonar S3776 flagged ReplaceNonAlphaNumericWithSpace at 17 against the allowed 15 after the nested if was added. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AtF6Ynq3K6Km6HSRHaKuX8
A ternary nested in the loop still costs Sonar's nesting increment, so the method stayed at 17 against the allowed 15. Moving it into LowercaseIf brings it back under the limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AtF6Ynq3K6Km6HSRHaKuX8
…ostrophe-names # Conflicts: # CaseConverter/CaseConverter.cs
|
This was referenced Sep 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #96
What changed
When
ReplaceNonAlphaNumericWithSpacedrops an in-word apostrophe,"O'Neil"becomes"ONeil".SplitOnCaseChangethen breaks that into"O Neil", so the word converted too_neil, while"o'neil"and"O'NEIL"both gaveoneil.The fix takes the issue's first suggestion. A capital straight after the apostrophe is now lowercased when the letters around it are lowercase:
O'Neillowers theN.O'NEILkeeps it, so the word is still one all-caps word.Don'Tlowers theT.DON'Tkeeps it, which leaves the existingDON'T stoprow unchanged.API's,CEO's) runs first and is unchanged.O'NeilOneiloneilo_neilD'AngeloDangelodangelod_angeloDon'T stopDontStopdont_stopdon_t_stopO'NEILOneiloneiloneil(unchanged)I didn't take the issue's second suggestion, splitting while the apostrophe is still present, because it would also change how
ReplaceNonAlphaNumericWithSpacetreats every other separator. That is a much wider change for the same result.Testing
"o'neil"row inApostropheWithinWordShouldNotSplitIt:O'Neil,O’Neil,O'NEIL,D'Angelo,d'angeloandDon'T stopO'Neil's carMcDonald's menu, which pins that a lowercase letter before the apostrophe is left aloneACapitalisedApostropheNameShouldConvertLikeItsLowercaseSpellingtest checks that each name converts like its lowercase spelling, and thatx.ToTitleCase().ToSnakeCase() == x.ToSnakeCase().dotnet build CaseConverter.slnbuilds every target (net10.0/9.0/8.0, netstandard2.0/2.1) with 0 warnings.This touches the same loop as #101 (the
İ/ıfix), right next to the line that PR changes. Whichever of the two merges second may need a trivial merge.🤖 Generated with Claude Code
https://claude.ai/code/session_01AtF6Ynq3K6Km6HSRHaKuX8
Generated by Claude Code