Skip to content

Fix GenerateRandomWord producing non-ASCII letters in the Turkish culture - #997

Merged
StefH merged 2 commits into
zzzprojects:masterfrom
menes97:fix/random-word-turkish-culture
Nov 18, 2026
Merged

StefH merged 2 commits into
zzzprojects:masterfrom
menes97:fix/random-word-turkish-culture

Conversation

@menes97

@menes97 menes97 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

ParameterExpressionHelper.GenerateRandomWord() lowercases the generated word with ToLower(), which uses the current culture. Under tr-TR, I lowercases to the dotless ı (U+0131), so the word is no longer a-z only (e.g. vjcjjheccrwıeddd). These words are used as parameter names when RenameEmptyParameterExpressionNames is enabled; most generated words contain an I, so this happens on most calls.

The fix is ToLowerInvariant().

Tests. On a tr-TR machine the existing suite already showed it: 15 tests failed on master (ParameterExpressionHelper_GenerateRandom16CharWord, DynamicExpressionParser_ParseLambda_RenameEmptyParameterExpressionNames, and the ParameterExpressionHelper_CreateParameterExpression cases with renameEmpty: true). I also added ParameterExpressionHelper_GenerateRandomWord_ShouldOnlyContainAsciiLettersInTurkishCulture, which sets tr-TR itself and checks 1000 words against ^[a-z]{16}$, so it fails on any machine without the fix.

System.Linq.Dynamic.Core.Tests on net10.0: before the change 19 failed / 1267 passed; after it 0 failed / 1286 passed (17 skipped both times). I ran only the net10.0 test project (with IsRunningOnGitHubActions=true to skip the uap10.0 target locally).

This change was written with Claude Code.

🤖 Generated with Claude Code

…ture

ParameterExpressionHelper.GenerateRandomWord lowercased the generated word with
the current culture. With tr-TR the letter 'I' becomes the dotless 'ı', so the
generated parameter name was no longer made of a-z only. Use ToLowerInvariant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@StefH StefH added the bug label Nov 18, 2026
// Assert
Check.That(result).Matches(@"[a-z]{16}");
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need test this ; remove the test

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@menes97

menes97 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Removed the test in 06bb3b8; the PR is now just the ToLowerInvariant() change. The existing ParameterExpressionHelper_GenerateRandom16CharWord and renameEmpty: true tests already cover it on a tr-TR machine.

@StefH
StefH merged commit 0cac656 into zzzprojects:master Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants