From ee3ad866d9727bcf583bfa18034783306523d6ce Mon Sep 17 00:00:00 2001 From: Mathias Beaulieu-Duncan Date: Mon, 20 Apr 2026 19:33:27 -0400 Subject: [PATCH] Use InvariantCulture for decimal.Parse in generated gRPC mappers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Generated code was using locale-dependent parsing for decimal values. On systems with comma decimal separator (e.g., French locale), parsing "0.95" would throw FormatException because the system expected "0,95". Switched all 4 decimal.Parse() call sites in the generated proto→domain mappers to pass System.Globalization.CultureInfo.InvariantCulture for consistent behavior across locales. Inspired by JP's commit 599204d on feat/grpc-generator-improvements (applied manually since cherry-pick had heavy context conflicts). Co-Authored-By: Claude Opus 4.7 (1M context) --- Svrnty.CQRS.Grpc.Generators/GrpcGenerator.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Svrnty.CQRS.Grpc.Generators/GrpcGenerator.cs b/Svrnty.CQRS.Grpc.Generators/GrpcGenerator.cs index c6356d2..d1fd41e 100644 --- a/Svrnty.CQRS.Grpc.Generators/GrpcGenerator.cs +++ b/Svrnty.CQRS.Grpc.Generators/GrpcGenerator.cs @@ -884,11 +884,11 @@ public class GrpcGenerator : IIncrementalGenerator { if (prop.IsNullable) { - return $"{indent}{prop.Name} = string.IsNullOrEmpty({source}) ? null : decimal.Parse({source}),"; + return $"{indent}{prop.Name} = string.IsNullOrEmpty({source}) ? null : decimal.Parse({source}, System.Globalization.CultureInfo.InvariantCulture),"; } else { - return $"{indent}{prop.Name} = decimal.Parse({source}),"; + return $"{indent}{prop.Name} = decimal.Parse({source}, System.Globalization.CultureInfo.InvariantCulture),"; } } @@ -1031,11 +1031,11 @@ public class GrpcGenerator : IIncrementalGenerator { if (prop.IsNullable) { - return $"{indent}{prop.Name} = string.IsNullOrEmpty({source}) ? null : decimal.Parse({source}),"; + return $"{indent}{prop.Name} = string.IsNullOrEmpty({source}) ? null : decimal.Parse({source}, System.Globalization.CultureInfo.InvariantCulture),"; } else { - return $"{indent}{prop.Name} = decimal.Parse({source}),"; + return $"{indent}{prop.Name} = decimal.Parse({source}, System.Globalization.CultureInfo.InvariantCulture),"; } }