This is an automated email from the ASF dual-hosted git repository. nightowl888 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/lucenenet.git
commit bfa4c6856df04f8d5881ab07ebb24c9ecff53d37 Author: Shad Storhaug <[email protected]> AuthorDate: Sun Oct 24 04:02:11 2021 +0700 BUG: Lucene.Net.Expressions.ScoreFunctionValues::DoubleVal(): Assigning float to double loses precision in x86 .NET Framework. Do an intermediate cast to decimal to fix Lucene.Net.Expressions.TestExpressionSorts::TestQueries(). See #269. --- src/Lucene.Net.Expressions/ScoreFunctionValues.cs | 6 ++++++ src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Lucene.Net.Expressions/ScoreFunctionValues.cs b/src/Lucene.Net.Expressions/ScoreFunctionValues.cs index c6eb9c1..942b550 100644 --- a/src/Lucene.Net.Expressions/ScoreFunctionValues.cs +++ b/src/Lucene.Net.Expressions/ScoreFunctionValues.cs @@ -44,7 +44,13 @@ namespace Lucene.Net.Expressions try { if (Debugging.AssertsEnabled) Debugging.Assert(document == scorer.DocID); + +#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER return scorer.GetScore(); +#else + // LUCENENET specific: The intermediate cast to decimal is required here to prevent us from losing precision on x86 .NET Framework with optimizations enabled + return (double)(decimal)scorer.GetScore(); +#endif } catch (Exception exception) when (exception.IsIOException()) { diff --git a/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs b/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs index 1a9e22b..6b64263 100644 --- a/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs +++ b/src/Lucene.Net.Tests.Expressions/TestExpressionSorts.cs @@ -86,9 +86,6 @@ namespace Lucene.Net.Expressions } [Test] -#if NETFRAMEWORK - [AwaitsFix(BugUrl = "https://github.com/apache/lucenenet/issues/269")] // LUCENENET TODO: this test fails on x86 on .NET Framework in Release mode only -#endif public virtual void TestQueries() { int n = AtLeast(4);
