Skip to content

Fix privatize-constants on typed constants - #161

Merged
TomasVotruba merged 1 commit into
mainfrom
fix-privatize-typed-constants
Oct 31, 2026
Merged

TomasVotruba merged 1 commit into
mainfrom
fix-privatize-typed-constants

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Fixes #160

The visibility regex matched const NAME directly, so a type between const and the name (public const string FOO) never matched. The constant was reported as "changed to private" but the file was left untouched.

Now the regex matches an optional type and keeps it in the replacement:

  • public const string FOO -> private const string FOO
  • public const BAR -> private const BAR

Added a command test covering both typed and untyped constants.

Regex didn't allow a type between 'const' and the name, so typed
constants like 'public const string FOO' were reported as changed
but left untouched. Match the optional type and keep it in the
replacement.
@TomasVotruba
TomasVotruba merged commit dda9b52 into main Oct 31, 2026
11 checks passed
@TomasVotruba
TomasVotruba deleted the fix-privatize-typed-constants branch October 31, 2026 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

privatize-constants doesn't work on typed constants

1 participant