Skip to content

Trim boundary separators in macro/snake/kebab case conversions - #60

Merged
matt-edmondson merged 2 commits into
mainfrom
copilot/fix-leading-trailing-separator-characters
Sep 13, 2026
Merged

matt-edmondson merged 2 commits into
mainfrom
copilot/fix-leading-trailing-separator-characters

Conversation

Copilot AI commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

ToMacroCase() only trimmed whitespace before non-alphanumeric normalization, so leading/trailing separators (e.g. _, -, .) were converted into boundary spaces and then emitted as leading/trailing _/-. This leaked into ToSnakeCase() and ToKebabCase() because both are derived from ToMacroCase().

  • Conversion pipeline fix (ToMacroCase)

    • Normalize case-boundary splits as before, then collapse/trim the intermediate space-delimited form before converting spaces to _.
    • This removes separator artifacts at string boundaries while preserving internal word separation behavior.
  • Regression coverage for boundary-separator inputs

    • Added focused tests for "_privateField-":
      • ToSnakeCase()private_field
      • ToKebabCase()private-field
      • ToMacroCase()PRIVATE_FIELD
string output = input.Trim();
output = NonAlphaNumericRegex().Replace(output, " ");
output = SplitOnCaseChangeRegex().Replace(output, " ").ToUpperInvariant();
output = CollapseSpaces(output).Trim(); // new: strip boundary artifacts before "_" conversion

Co-authored-by: matt-edmondson <19528727+matt-edmondson@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix leading/trailing separator characters in case conversion Trim boundary separators in macro/snake/kebab case conversions Sep 13, 2026
@matt-edmondson
matt-edmondson marked this pull request as ready for review September 13, 2026 12:04
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 42aab9a into main Sep 13, 2026
12 checks passed
@matt-edmondson
matt-edmondson deleted the copilot/fix-leading-trailing-separator-characters branch September 13, 2026 12:15
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.

Leading/trailing separator characters leak into snake_case, kebab-case, and MACRO_CASE output (e.g. _privateField-private-field)

2 participants