Skip to content

[Repo Assist] Extract isFirstCharUppercase helper in CodePrinter (v2)#3292

Merged
nojaf merged 2 commits intomainfrom
repo-assist/improve-isfirstcharuppercase-v2-1983fee3bf674e3f
Mar 16, 2026
Merged

[Repo Assist] Extract isFirstCharUppercase helper in CodePrinter (v2)#3292
nojaf merged 2 commits intomainfrom
repo-assist/improve-isfirstcharuppercase-v2-1983fee3bf674e3f

Conversation

@github-actions
Copy link
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant. All changes were reviewed and tested before submission.

This is a revised version of #3282, incorporating maintainer feedback.

Changes

Both (|UppercaseType|LowercaseType|) and (|UppercaseExpr|LowercaseExpr|) in CodePrinter.fs contained identical inline logic to check whether a string's first character is uppercase. This PR extracts the shared predicate into a single module-level helper:

let isFirstCharUppercase (v: string) =
    match Seq.tryHead v with
    | Some c -> Char.IsUpper c
    | None -> false

As requested, the implementation uses a match expression rather than a pipeline chain. Both active patterns now delegate to this helper.

Trade-offs

  • Positive: single definition for the "first char uppercase?" check, easier to update if the logic changes.
  • No behaviour change: the logic is identical; only the location and style of the definition has changed.

Closes #3282 (supersedes the previous attempt)

Test Status

Build: ✅ succeeded
Tests: ✅ all 2738 passed, 7 skipped

Generated by Repo Assist ·

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@346204513ecfa08b81566450d7d599556807389f

Use a match expression for the shared 'first char uppercase?' predicate,
as preferred by the maintainer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nojaf nojaf closed this Mar 16, 2026
@nojaf nojaf reopened this Mar 16, 2026
@nojaf nojaf marked this pull request as ready for review March 16, 2026 08:28
@nojaf
Copy link
Contributor

nojaf commented Mar 16, 2026

/repo-assist format code

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

Commit pushed: 1a75e77

Generated by Repo Assist

@nojaf nojaf closed this Mar 16, 2026
@nojaf nojaf reopened this Mar 16, 2026
@nojaf nojaf merged commit 12638f2 into main Mar 16, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant