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 1f24d317b1c3cefbe76af15763653dd3237549aa
Author: Shad Storhaug <[email protected]>
AuthorDate: Sun Jun 28 17:45:29 2020 +0700

    
Lucene.Net.TestFramework.Randomized.Generators.RandomInts::RandomInt32Between():
 Debug.Assert needs to be compiled out of the build in this case to avoid 
performance issues with its string formatting (#295, #261)
---
 .../Support/Randomized/Generators/RandomInts.cs                  | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/src/Lucene.Net.TestFramework/Support/Randomized/Generators/RandomInts.cs 
b/src/Lucene.Net.TestFramework/Support/Randomized/Generators/RandomInts.cs
index 91acfb1..0fbe38b 100644
--- a/src/Lucene.Net.TestFramework/Support/Randomized/Generators/RandomInts.cs
+++ b/src/Lucene.Net.TestFramework/Support/Randomized/Generators/RandomInts.cs
@@ -1,6 +1,9 @@
 using Lucene.Net.Support;
 using System;
-using Debug = Lucene.Net.Diagnostics.Debug; // LUCENENET NOTE: We cannot use 
System.Diagnostics.Debug because those calls will be optimized out of the 
release!
+using System.Diagnostics;
+using System.Globalization;
+// LUCENENET NOTE: The asserts here need to be from System.Diagnostics, since 
they are not meant for end users.
+//using Debug = Lucene.Net.Diagnostics.Debug;
 
 namespace Lucene.Net.Randomized.Generators
 {
@@ -33,9 +36,9 @@ namespace Lucene.Net.Randomized.Generators
         public static int RandomInt32Between(Random random, int min, int max)
         {
             Debug.Assert(min <= max,
-                $"Min must be less than or equal max int. min: 
{min.ToString()}, max: {max.ToString()}");
+                $"Min must be less than or equal max int. min: 
{min.ToString(CultureInfo.InvariantCulture)}, max: 
{max.ToString(CultureInfo.InvariantCulture)}");
             var range = max - min;
-            if (range < Int32.MaxValue)
+            if (range < int.MaxValue)
                 return min + random.Next(1 + range);
 
             return min + (int)Math.Round(random.NextDouble() * range);

Reply via email to