This is an automated email from the ASF dual-hosted git repository.
ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new cd2ebd33dd5 IGNITE-24198 .NET: Fix locale-dependent Compute tests
failures (#5141)
cd2ebd33dd5 is described below
commit cd2ebd33dd55509d0a8c186b0c4c71d404047f44
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Mon Feb 10 09:13:00 2025 +0400
IGNITE-24198 .NET: Fix locale-dependent Compute tests failures (#5141)
---
.../dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs | 13 ++++++++-----
.../platforms/dotnet/Apache.Ignite.Tests/Sql/SqlTests.cs | 3 ++-
modules/platforms/dotnet/Apache.Ignite/BigDecimal.cs | 13 ++++++++++++-
3 files changed, 22 insertions(+), 7 deletions(-)
diff --git
a/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs
index ed797ef5d7b..a3e4b00cff1 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Compute/ComputeTests.cs
@@ -270,8 +270,11 @@ namespace Apache.Ignite.Tests.Compute
var strExec = await Client.Compute.SubmitAsync(nodes,
ToStringJob, val);
var str = await strExec.GetResultAsync();
- var expectedStr0 = expectedStr ??
val.ToString()!.Replace("E+", "E");
- Assert.AreEqual(expectedStr0, str);
+ expectedStr ??= val is IFormattable formattable
+ ? formattable.ToString(null,
CultureInfo.InvariantCulture).Replace("E+", "E")
+ : val.ToString();
+
+ Assert.AreEqual(expectedStr, str);
}
}
@@ -710,7 +713,7 @@ namespace Apache.Ignite.Tests.Compute
var res = await Client.Compute.SubmitAsync(await GetNodeAsync(1),
DecimalJob, $"{number},{scale}");
var resVal = await res.GetResultAsync();
- var expected = decimal.Parse(number, NumberStyles.Float);
+ var expected = decimal.Parse(number, NumberStyles.Float,
CultureInfo.InvariantCulture);
if (scale > 0)
{
@@ -935,7 +938,7 @@ namespace Apache.Ignite.Tests.Compute
{
public void Marshal(Nested obj, IBufferWriter<byte> writer)
{
- var str = obj.Id + ":" + obj.Price;
+ var str = obj.Id + ":" +
obj.Price.ToString(CultureInfo.InvariantCulture);
Encoding.ASCII.GetBytes(str, writer);
}
@@ -943,7 +946,7 @@ namespace Apache.Ignite.Tests.Compute
{
var str = Encoding.ASCII.GetString(bytes);
var parts = str.Split(':');
- return new(Guid.Parse(parts[0]), decimal.Parse(parts[1]));
+ return new(Guid.Parse(parts[0]), decimal.Parse(parts[1],
CultureInfo.InvariantCulture));
}
}
}
diff --git a/modules/platforms/dotnet/Apache.Ignite.Tests/Sql/SqlTests.cs
b/modules/platforms/dotnet/Apache.Ignite.Tests/Sql/SqlTests.cs
index 114374e8f7e..c4b0d8c823b 100644
--- a/modules/platforms/dotnet/Apache.Ignite.Tests/Sql/SqlTests.cs
+++ b/modules/platforms/dotnet/Apache.Ignite.Tests/Sql/SqlTests.cs
@@ -20,6 +20,7 @@ namespace Apache.Ignite.Tests.Sql
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+ using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
using Ignite.Sql;
@@ -535,7 +536,7 @@ namespace Apache.Ignite.Tests.Sql
Assert.AreEqual(32757, bigDecimal.Scale);
Assert.AreEqual(13603, bigDecimal.UnscaledValue.GetByteCount());
- StringAssert.StartsWith("3.3333333333", bigDecimal.ToString());
+ StringAssert.StartsWith("3.3333333333",
bigDecimal.ToString(CultureInfo.InvariantCulture));
}
[Test]
diff --git a/modules/platforms/dotnet/Apache.Ignite/BigDecimal.cs
b/modules/platforms/dotnet/Apache.Ignite/BigDecimal.cs
index 98913db6ee6..ba4a432d384 100644
--- a/modules/platforms/dotnet/Apache.Ignite/BigDecimal.cs
+++ b/modules/platforms/dotnet/Apache.Ignite/BigDecimal.cs
@@ -30,7 +30,7 @@ using Internal.Proto.BinaryTuple;
/// .NET <see cref="decimal"/> has 28-29 digit precision and can not represent
all values that Ignite supports.
/// This type fills the gap.
/// </summary>
-public readonly record struct BigDecimal : IComparable<BigDecimal>, IComparable
+public readonly record struct BigDecimal : IComparable<BigDecimal>,
IComparable, IFormattable
{
/// <summary>
/// Initializes a new instance of the <see cref="BigDecimal"/> struct.
@@ -135,6 +135,17 @@ public readonly record struct BigDecimal :
IComparable<BigDecimal>, IComparable
/// <inheritdoc />
public override string ToString() => ToString(null);
+ /// <inheritdoc />
+ public string ToString(string? format, IFormatProvider? formatProvider)
+ {
+ if (format != null)
+ {
+ throw new NotSupportedException("Format string is not supported.");
+ }
+
+ return ToString(formatProvider);
+ }
+
/// <summary>
/// Converts the numeric value of this object to its equivalent string
representation.
/// </summary>