Skip to content

fix: write decimal and integer constants with the invariant culture - #1035

Merged
DocSvartz merged 1 commit into
MapsterMapper:developmentfrom
menes97:fix/translator-invariant-decimal
Nov 18, 2026
Merged

DocSvartz merged 1 commit into
MapsterMapper:developmentfrom
menes97:fix/translator-invariant-decimal

Conversation

@menes97

@menes97 menes97 commented Nov 18, 2026

Copy link
Copy Markdown

ExpressionTranslator.WriteValue writes decimal, long, uint and ulong constants with value.ToString(), which uses the current culture. Under tr-TR (or any culture with , as the decimal separator), Expression.Constant(1.5m).ToScript() emits 1,5m, which isn't valid C#. The double and float cases right above already use CultureInfo.InvariantCulture; these four now do too (Convert.ToString(value, CultureInfo.InvariantCulture)).

Test. DebugInfoInjectorTest.TestDecimalConstantDoesNotDependOnCurrentCulture sets the culture to tr-TR, translates Expression.Constant(1.5m) and checks the script contains 1.5m. It fails without the change (the script has 1,5m) and passes with it.

Ran: ExpressionDebugger.Tests 41/41 on net48. The net6.0/net7.0 targets weren't run here (runtimes not installed), and I didn't rerun Mapster.Tests after this one-line change.

This change was written with Claude Code.

🤖 Generated with Claude Code

ExpressionTranslator wrote decimal, long, uint and ulong constants with
the current culture, so under a culture such as tr-TR 1.5m was emitted as
"1,5m", which is not valid C#.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DocSvartz
DocSvartz merged commit 0719725 into MapsterMapper:development Nov 18, 2026
2 checks passed
@DocSvartz

Copy link
Copy Markdown
Contributor

@menes97 Thanks!
Added in v10.0.15-pre02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants