From 572907a37d4bf56658813641972d494ab4b18ced Mon Sep 17 00:00:00 2001 From: menes97 <38889017+menes97@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:52:59 +0300 Subject: [PATCH 1/2] Fix GenerateRandomWord producing non-ASCII letters in the Turkish culture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../ParameterExpressionHelper.cs | 2 +- .../Parser/ParameterExpressionHelperTests.cs | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/System.Linq.Dynamic.Core/ParameterExpressionHelper.cs b/src/System.Linq.Dynamic.Core/ParameterExpressionHelper.cs index 974a0c78..2c060f7b 100644 --- a/src/System.Linq.Dynamic.Core/ParameterExpressionHelper.cs +++ b/src/System.Linq.Dynamic.Core/ParameterExpressionHelper.cs @@ -22,6 +22,6 @@ internal static string GenerateRandomWord() { const int wordLength = 16; const int diff = 'A' - '0'; - return string.Concat(Guid.NewGuid().ToString(@"N").Select(c => (char)(c + diff)).Take(wordLength)).ToLower(); + return string.Concat(Guid.NewGuid().ToString(@"N").Select(c => (char)(c + diff)).Take(wordLength)).ToLowerInvariant(); } } \ No newline at end of file diff --git a/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs b/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs index 4f90a753..d2384ce6 100644 --- a/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs +++ b/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs @@ -150,5 +150,27 @@ public void ParameterExpressionHelper_GenerateRandom16CharWord() // Assert Check.That(result).Matches(@"[a-z]{16}"); } + + [Fact] + public void ParameterExpressionHelper_GenerateRandomWord_ShouldOnlyContainAsciiLettersInTurkishCulture() + { + // Arrange + var originalCulture = System.Globalization.CultureInfo.CurrentCulture; + System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("tr-TR"); + + try + { + // Act and Assert + // About 64% of the generated words contain the letter 'I', which becomes 'ı' when lowercased with the Turkish culture. + for (int i = 0; i < 1000; i++) + { + Check.That(ParameterExpressionHelper.GenerateRandomWord()).Matches("^[a-z]{16}$"); + } + } + finally + { + System.Globalization.CultureInfo.CurrentCulture = originalCulture; + } + } } } From 06bb3b899d666f30a24bdb6cea171c97654ca0f4 Mon Sep 17 00:00:00 2001 From: menes97 <38889017+menes97@users.noreply.github.com> Date: Wed, 18 Nov 2026 14:49:25 +0300 Subject: [PATCH 2/2] Remove the extra GenerateRandomWord test Co-Authored-By: Claude Opus 5.5 --- .../Parser/ParameterExpressionHelperTests.cs | 22 ------------------- 1 file changed, 22 deletions(-) diff --git a/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs b/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs index d2384ce6..4f90a753 100644 --- a/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs +++ b/test/System.Linq.Dynamic.Core.Tests/Parser/ParameterExpressionHelperTests.cs @@ -150,27 +150,5 @@ public void ParameterExpressionHelper_GenerateRandom16CharWord() // Assert Check.That(result).Matches(@"[a-z]{16}"); } - - [Fact] - public void ParameterExpressionHelper_GenerateRandomWord_ShouldOnlyContainAsciiLettersInTurkishCulture() - { - // Arrange - var originalCulture = System.Globalization.CultureInfo.CurrentCulture; - System.Globalization.CultureInfo.CurrentCulture = new System.Globalization.CultureInfo("tr-TR"); - - try - { - // Act and Assert - // About 64% of the generated words contain the letter 'I', which becomes 'ı' when lowercased with the Turkish culture. - for (int i = 0; i < 1000; i++) - { - Check.That(ParameterExpressionHelper.GenerateRandomWord()).Matches("^[a-z]{16}$"); - } - } - finally - { - System.Globalization.CultureInfo.CurrentCulture = originalCulture; - } - } } }