Skip to content

Commit

Permalink
Misc cleanup from PR review
Browse files Browse the repository at this point in the history
- add LUCENENET to C#-specific comment
- add back unused using for Assert as safeguard with comment
- use invariant culture for number conversion in
  TestIndexWriterExceptions
  • Loading branch information
paulirwin committed Mar 13, 2024
1 parent d41501f commit 80673c3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
3 changes: 2 additions & 1 deletion Lucene.Net.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coord/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Coord/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=LUCENENET/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
2 changes: 1 addition & 1 deletion src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public virtual void TestSettersChaining()
// IndexWriterConfig return type and second with LiveIndexWriterConfig. The ones
// from LiveIndexWriterConfig are marked 'synthetic', so just collect them and
// assert in the end that we also received them from IWC.
// In C# we do not have them marked synthetic so we look at the declaring type instead.
// LUCENENET: In C# we do not have them marked synthetic so we look at the declaring type instead.
if (m.DeclaringType?.Name == "LiveIndexWriterConfig")
{
liveSetters.Add(m.Name);
Expand Down
2 changes: 2 additions & 0 deletions src/Lucene.Net.Tests/Index/TestIndexWriterDelete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using System.Threading;
using JCG = J2N.Collections.Generic;
using Console = Lucene.Net.Util.SystemConsole;
// ReSharper disable once RedundantUsingDirective - keep until we have an analyzer to look out for accidental NUnit asserts
using Assert = Lucene.Net.TestFramework.Assert;

namespace Lucene.Net.Index
{
Expand Down
25 changes: 13 additions & 12 deletions src/Lucene.Net.Tests/Index/TestIndexWriterExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using RandomizedTesting.Generators;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using Assert = Lucene.Net.TestFramework.Assert;
Expand Down Expand Up @@ -214,7 +215,7 @@ public override void Run()
Console.WriteLine(Thread.CurrentThread.Name + ": TEST: IndexerThread: cycle");
}
outerInstance.doFail.Value = this.Instance;
string id = "" + r.Next(50);
string id = r.Next(50).ToString(CultureInfo.InvariantCulture); // LUCENENET: using InvariantCulture ToString overload instead of implicit `"" + r.Next(50)`
idField.SetStringValue(id);
Term idTerm = new Term("id", id);
try
Expand Down Expand Up @@ -2134,7 +2135,7 @@ public virtual void TestNoLostDeletesOrUpdates()
for (int i = 0; i < numDocs; i++)
{
Document doc = new Document();
doc.Add(new StringField("id", (docBase + i).ToString(), Field.Store.NO));
doc.Add(new StringField("id", (docBase + i).ToString(CultureInfo.InvariantCulture), Field.Store.NO));
if (DefaultCodecSupportsDocValues)
{
doc.Add(new NumericDocValuesField("f", 1L));
Expand Down Expand Up @@ -2172,20 +2173,20 @@ public virtual void TestNoLostDeletesOrUpdates()
}
if (Random.NextBoolean()) // update only numeric field
{
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString()), "f", value);
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString()), "cf", value * 2);
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "f", value);
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "cf", value * 2);
}
else if (Random.NextBoolean())
{
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString()), "bf", TestBinaryDocValuesUpdates.ToBytes(value));
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString()), "bcf", TestBinaryDocValuesUpdates.ToBytes(value * 2));
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "bf", TestBinaryDocValuesUpdates.ToBytes(value));
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "bcf", TestBinaryDocValuesUpdates.ToBytes(value * 2));
}
else
{
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString()), "f", value);
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString()), "cf", value * 2);
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString()), "bf", TestBinaryDocValuesUpdates.ToBytes(value));
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString()), "bcf", TestBinaryDocValuesUpdates.ToBytes(value * 2));
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "f", value);
w.UpdateNumericDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "cf", value * 2);
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "bf", TestBinaryDocValuesUpdates.ToBytes(value));
w.UpdateBinaryDocValue(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture)), "bcf", TestBinaryDocValuesUpdates.ToBytes(value * 2));
}
}

Expand All @@ -2194,10 +2195,10 @@ public virtual void TestNoLostDeletesOrUpdates()
{
if (Verbose)
{
Console.WriteLine(" delete id=" + (docBase + i));
Console.WriteLine(" delete id=" + (docBase + i).ToString(CultureInfo.InvariantCulture));
}
deleteCount++;
w.DeleteDocuments(new Term("id", "" + (docBase + i)));
w.DeleteDocuments(new Term("id", (docBase + i).ToString(CultureInfo.InvariantCulture))); // LUCENENET: using InvariantCulture ToString overload instead of implicit `"" +` conversion
}
}
}
Expand Down

0 comments on commit 80673c3

Please sign in to comment.