From f448882d6069a42ba1c1c67099adc80eccb9022d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 06:01:46 +0000 Subject: [PATCH 1/5] Initial plan From 7b3a6c43cd0eb26d8c2d6f8a1588a85d2577322d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 06:06:56 +0000 Subject: [PATCH 2/5] Initial analysis and test project setup for stack overflow bug Co-authored-by: tiakun <1862558+tiakun@users.noreply.github.com> --- .../Distractive.Formatters.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj b/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj index 279a085..5aa2062 100644 --- a/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj +++ b/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable false From b98897ef7a3e41b2625fc31bc56b98170c391fd4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 06:10:13 +0000 Subject: [PATCH 3/5] Fix stack overflow in ToThaiWords(int, bool) method and add regression test Co-authored-by: tiakun <1862558+tiakun@users.noreply.github.com> --- .../FormatterExtensionsTests.cs | 17 +++++++++++++++++ Distractive.Formatters/FormatterExtensions.cs | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Distractive.Formatters.Tests/FormatterExtensionsTests.cs b/Distractive.Formatters.Tests/FormatterExtensionsTests.cs index 155de9e..a5d78c8 100644 --- a/Distractive.Formatters.Tests/FormatterExtensionsTests.cs +++ b/Distractive.Formatters.Tests/FormatterExtensionsTests.cs @@ -16,5 +16,22 @@ public void ExtensionTests() Assert.Equal("หนึ่ง", 1L.ToThaiWords()); Assert.Equal("หนึ่ง", 1.ToThaiWords()); } + + [Theory] + [InlineData(42, "สี่สิบสอง")] + [InlineData(101, "หนึ่งร้อยหนึ่ง")] + [InlineData(121, "หนึ่งร้อยยี่สิบเอ็ด")] + [InlineData(1001, "หนึ่งพันหนึ่ง")] + public void ToThaiWords_IntWithBoolParameter_ShouldNotCauseStackOverflow(int value, string expected) + { + // This test ensures that the ToThaiWords(int, bool) method + // doesn't cause stack overflow by calling itself recursively + string result = value.ToThaiWords(true); + Assert.Equal(expected, result); + + // Also verify it matches the long version behavior + string longResult = ((long)value).ToThaiWords(true); + Assert.Equal(longResult, result); + } } } diff --git a/Distractive.Formatters/FormatterExtensions.cs b/Distractive.Formatters/FormatterExtensions.cs index d00bb73..5809cdf 100644 --- a/Distractive.Formatters/FormatterExtensions.cs +++ b/Distractive.Formatters/FormatterExtensions.cs @@ -34,7 +34,7 @@ public static string ToBahtText(this decimal value, public static string ToThaiWords(this long value, bool useEtWithTensOnly) => _formatters[useEtWithTensOnly ? 1 : 0].Format(value); - public static string ToThaiWords(this int value, bool useEtWithTensOnly) => ToThaiWords(value, useEtWithTensOnly); + public static string ToThaiWords(this int value, bool useEtWithTensOnly) => ToThaiWords((long)value, useEtWithTensOnly); public static string ToBahtText(this decimal value, bool useEtWithTensOnly) => _formatters[useEtWithTensOnly ? 1 : 0].GetBahtText(value); From 655adab05635fabb4aa9a037cc587fd1747d3971 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 06:19:09 +0000 Subject: [PATCH 4/5] Revert test project target framework from net8.0 to net6.0 Co-authored-by: tiakun <1862558+tiakun@users.noreply.github.com> --- .../Distractive.Formatters.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj b/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj index 5aa2062..279a085 100644 --- a/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj +++ b/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj @@ -1,7 +1,7 @@  - net8.0 + net6.0 enable false From b79338450060f396877beaa1e87d939c061c79e9 Mon Sep 17 00:00:00 2001 From: Tia Date: Sat, 27 Sep 2025 00:28:25 +0700 Subject: [PATCH 5/5] add net8 as a target framework --- .../Distractive.Formatters.Tests.csproj | 2 +- Distractive.Formatters/Distractive.Formatters.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj b/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj index 279a085..5aa2062 100644 --- a/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj +++ b/Distractive.Formatters.Tests/Distractive.Formatters.Tests.csproj @@ -1,7 +1,7 @@  - net6.0 + net8.0 enable false diff --git a/Distractive.Formatters/Distractive.Formatters.csproj b/Distractive.Formatters/Distractive.Formatters.csproj index 317048a..c81d1d7 100644 --- a/Distractive.Formatters/Distractive.Formatters.csproj +++ b/Distractive.Formatters/Distractive.Formatters.csproj @@ -1,6 +1,6 @@  - net6.0;netstandard2.0;netstandard2.1 + net8.0;net6.0;netstandard2.0;netstandard2.1 enable 11 False