lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [lucenenet] 26/42: SWEEP: Changed string.IndexOf(string) to use either string.IndexOf(char) or string.IndexOf(string, StringComparison.Ordinal) to keep ambient culture from affecting the comparison.
Date Wed, 07 Aug 2019 22:26:23 GMT
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 4f810bac9c02de02e70658f1ead6566017dea17b
Author: Shad Storhaug <shad@shadstorhaug.com>
AuthorDate: Mon Aug 5 01:56:36 2019 +0700

    SWEEP: Changed string.IndexOf(string) to use either string.IndexOf(char) or string.IndexOf(string,
StringComparison.Ordinal) to keep ambient culture from affecting the comparison.
---
 .../Icu/Segmentation/ICUTokenizerFactory.cs        |  2 +-
 src/Lucene.Net.Analysis.Kuromoji/Util/CSVUtil.cs   |  5 +++--
 .../Language/Bm/Lang.cs                            |  2 +-
 .../Language/Bm/Rule.cs                            |  4 ++--
 .../Language/DaitchMokotoffSoundex.cs              |  2 +-
 .../Language/DoubleMetaphone.cs                    |  2 +-
 .../ByTask/Feeds/TrecLATimesParser.cs              |  2 +-
 .../ByTask/Tasks/SetPropTask.cs                    |  2 +-
 .../ByTask/Tasks/TaskSequence.cs                   |  2 +-
 src/Lucene.Net.Benchmark/ByTask/Utils/Config.cs    | 26 +++++++++++-----------
 src/Lucene.Net.Benchmark/Utils/ExtractReuters.cs   |  2 +-
 .../Index/BaseDocValuesFormatTestCase.cs           |  4 ++--
 src/Lucene.Net.TestFramework/Search/CheckHits.cs   |  4 ++--
 .../TestLimitTokenCountFilterFactory.cs            |  2 +-
 .../TestLimitTokenPositionFilterFactory.cs         |  2 +-
 .../TestJapaneseTokenizer.cs                       |  2 +-
 .../ByTask/Feeds/TrecContentSourceTest.cs          |  2 +-
 .../ByTask/TestPerfTasksParse.cs                   |  4 ++--
 .../BreakIteratorBoundaryScannerTest.cs            | 18 +++++++--------
 .../VectorHighlight/IndexTimeSynonymTest.cs        |  4 ++--
 .../VectorHighlight/SimpleBoundaryScannerTest.cs   | 12 +++++-----
 .../Util/QueryParserTestBase.cs                    |  2 +-
 .../Analysis/TestGraphTokenizers.cs                |  2 +-
 .../Index/TestBackwardsCompatibility.cs            |  2 +-
 .../Index/TestBackwardsCompatibility3x.cs          |  2 +-
 .../Index/TestIndexWriterConfig.cs                 |  2 +-
 src/Lucene.Net.Tests/Index/TestSegmentMerger.cs    |  3 ++-
 src/Lucene.Net.Tests/Index/TestSegmentReader.cs    |  4 ++--
 .../Search/Payloads/TestPayloadNearQuery.cs        |  6 ++---
 src/Lucene.Net.Tests/Search/TestBooleanQuery.cs    |  2 +-
 src/Lucene.Net.Tests/Search/TestFieldCache.cs      |  2 +-
 src/Lucene.Net.Tests/Store/TestLockFactory.cs      |  2 +-
 src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs  |  9 ++++----
 src/Lucene.Net.Tests/Support/TestOldPatches.cs     |  2 +-
 src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs          |  6 ++---
 src/Lucene.Net/Support/Util/NamedServiceFactory.cs |  2 +-
 36 files changed, 78 insertions(+), 75 deletions(-)

diff --git a/src/Lucene.Net.Analysis.ICU/Analysis/Icu/Segmentation/ICUTokenizerFactory.cs
b/src/Lucene.Net.Analysis.ICU/Analysis/Icu/Segmentation/ICUTokenizerFactory.cs
index ac2dce0..ea93354 100644
--- a/src/Lucene.Net.Analysis.ICU/Analysis/Icu/Segmentation/ICUTokenizerFactory.cs
+++ b/src/Lucene.Net.Analysis.ICU/Analysis/Icu/Segmentation/ICUTokenizerFactory.cs
@@ -85,7 +85,7 @@ namespace Lucene.Net.Analysis.Icu.Segmentation
                 IList<string> scriptAndResourcePaths = SplitFileNames(rulefilesArg);
                 foreach (string scriptAndResourcePath in scriptAndResourcePaths)
                 {
-                    int colonPos = scriptAndResourcePath.IndexOf(":");
+                    int colonPos = scriptAndResourcePath.IndexOf(':');
                     string scriptCode = scriptAndResourcePath.Substring(0, colonPos - 0).Trim();
                     string resourcePath = scriptAndResourcePath.Substring(colonPos + 1).Trim();
                     tailored[UChar.GetPropertyValueEnum(UProperty.Script, scriptCode)] =
resourcePath;
diff --git a/src/Lucene.Net.Analysis.Kuromoji/Util/CSVUtil.cs b/src/Lucene.Net.Analysis.Kuromoji/Util/CSVUtil.cs
index 9d86aed..05858f4 100644
--- a/src/Lucene.Net.Analysis.Kuromoji/Util/CSVUtil.cs
+++ b/src/Lucene.Net.Analysis.Kuromoji/Util/CSVUtil.cs
@@ -1,4 +1,5 @@
-´╗┐using System.Collections.Generic;
+´╗┐using System;
+using System.Collections.Generic;
 using System.Text;
 using System.Text.RegularExpressions;
 
@@ -94,7 +95,7 @@ namespace Lucene.Net.Analysis.Ja.Util
                 }
 
                 // Unescape
-                if (result.IndexOf(ESCAPED_QUOTE) >= 0)
+                if (result.IndexOf(ESCAPED_QUOTE, StringComparison.Ordinal) >= 0)
                 {
                     result = result.Replace(ESCAPED_QUOTE, "\"");
                 }
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs
index 63faf7c..4e3dcd4 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Lang.cs
@@ -175,7 +175,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                         else
                         {
                             // discard comments
-                            int cmtI = line.IndexOf(ResourceConstants.CMT);
+                            int cmtI = line.IndexOf(ResourceConstants.CMT, StringComparison.Ordinal);
                             if (cmtI >= 0)
                             {
                                 line = line.Substring(0, cmtI - 0);
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
index 55e2d17..9e6e637 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/Bm/Rule.cs
@@ -346,7 +346,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
 
         private static Phoneme ParsePhoneme(string ph)
         {
-            int open = ph.IndexOf("[");
+            int open = ph.IndexOf('[');
             if (open >= 0)
             {
                 if (!ph.EndsWith("]", StringComparison.Ordinal))
@@ -446,7 +446,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language.Bm
                         else
                         {
                             // discard comments
-                            int cmtI = line.IndexOf(ResourceConstants.CMT);
+                            int cmtI = line.IndexOf(ResourceConstants.CMT, StringComparison.Ordinal);
                             if (cmtI >= 0)
                             {
                                 line = line.Substring(0, cmtI);
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs
index d6bdfcb..cf26e19 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/DaitchMokotoffSoundex.cs
@@ -299,7 +299,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
                 else
                 {
                     // discard comments
-                    int cmtI = line.IndexOf(COMMENT);
+                    int cmtI = line.IndexOf(COMMENT, StringComparison.Ordinal);
                     if (cmtI >= 0)
                     {
                         line = line.Substring(0, cmtI - 0);
diff --git a/src/Lucene.Net.Analysis.Phonetic/Language/DoubleMetaphone.cs b/src/Lucene.Net.Analysis.Phonetic/Language/DoubleMetaphone.cs
index d54968d..2d239be 100644
--- a/src/Lucene.Net.Analysis.Phonetic/Language/DoubleMetaphone.cs
+++ b/src/Lucene.Net.Analysis.Phonetic/Language/DoubleMetaphone.cs
@@ -1088,7 +1088,7 @@ namespace Lucene.Net.Analysis.Phonetic.Language
         private bool IsSlavoGermanic(string value)
         {
             return value.IndexOf('W') > -1 || value.IndexOf('K') > -1 ||
-                value.IndexOf("CZ") > -1 || value.IndexOf("WITZ") > -1;
+                value.IndexOf("CZ", StringComparison.Ordinal) > -1 || value.IndexOf("WITZ",
StringComparison.Ordinal) > -1;
         }
 
         /// <summary>
diff --git a/src/Lucene.Net.Benchmark/ByTask/Feeds/TrecLATimesParser.cs b/src/Lucene.Net.Benchmark/ByTask/Feeds/TrecLATimesParser.cs
index e54f635..c5611e2 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Feeds/TrecLATimesParser.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Feeds/TrecLATimesParser.cs
@@ -44,7 +44,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
             string dateStr = Extract(docBuf, DATE, DATE_END, -1, null);
             if (dateStr != null)
             {
-                int d2a = dateStr.IndexOf(DATE_NOISE);
+                int d2a = dateStr.IndexOf(DATE_NOISE, StringComparison.Ordinal);
                 if (d2a > 0)
                 {
                     dateStr = dateStr.Substring(0, (d2a + 3) - 0); // we need the "day" part
diff --git a/src/Lucene.Net.Benchmark/ByTask/Tasks/SetPropTask.cs b/src/Lucene.Net.Benchmark/ByTask/Tasks/SetPropTask.cs
index abb66d2..a0ce0ec 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Tasks/SetPropTask.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Tasks/SetPropTask.cs
@@ -57,7 +57,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Tasks
         public override void SetParams(string @params)
         {
             base.SetParams(@params);
-            int k = @params.IndexOf(",");
+            int k = @params.IndexOf(',');
             name = @params.Substring(0, k - 0).Trim();
             value = @params.Substring(k + 1).Trim();
         }
diff --git a/src/Lucene.Net.Benchmark/ByTask/Tasks/TaskSequence.cs b/src/Lucene.Net.Benchmark/ByTask/Tasks/TaskSequence.cs
index b28a530..7bbadfd 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Tasks/TaskSequence.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Tasks/TaskSequence.cs
@@ -622,7 +622,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Tasks
             {
                 seqName += "_" + rate + (perMin ? "/min" : "/sec");
             }
-            if (parallel && seqName.ToLowerInvariant().IndexOf("par") < 0)
+            if (parallel && seqName.ToLowerInvariant().IndexOf("par", StringComparison.Ordinal)
< 0)
             {
                 seqName += "_Par";
             }
diff --git a/src/Lucene.Net.Benchmark/ByTask/Utils/Config.cs b/src/Lucene.Net.Benchmark/ByTask/Utils/Config.cs
index 4f11292..9f5839c 100644
--- a/src/Lucene.Net.Benchmark/ByTask/Utils/Config.cs
+++ b/src/Lucene.Net.Benchmark/ByTask/Utils/Config.cs
@@ -173,18 +173,18 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
             {
                 return null;
             }
-            if (sval.IndexOf(":") < 0)
+            if (sval.IndexOf(':') < 0)
             {
                 return sval;
             }
-            else if (sval.IndexOf(":\\") >= 0 || sval.IndexOf(":/") >= 0)
+            else if (sval.IndexOf(":\\", StringComparison.Ordinal) >= 0 || sval.IndexOf(":/",
StringComparison.Ordinal) >= 0)
             {
                 // this previously messed up absolute path names on Windows. Assuming
                 // there is no real value that starts with \ or /
                 return sval;
             }
             // first time this prop is extracted by round
-            int k = sval.IndexOf(":");
+            int k = sval.IndexOf(':');
             string colName = sval.Substring(0, k - 0);
             sval = sval.Substring(k + 1);
             colForValByRound[name] = colName;
@@ -236,12 +236,12 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
             {
                 sval = dflt.ToString(CultureInfo.InvariantCulture);
             }
-            if (sval.IndexOf(":") < 0)
+            if (sval.IndexOf(':') < 0)
             {
                 return int.Parse(sval, CultureInfo.InvariantCulture);
             }
             // first time this prop is extracted by round
-            int k = sval.IndexOf(":");
+            int k = sval.IndexOf(':');
             string colName = sval.Substring(0, k - 0);
             sval = sval.Substring(k + 1);
             colForValByRound[name] = colName;
@@ -276,12 +276,12 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
             {
                 sval = dflt.ToString(CultureInfo.InvariantCulture);
             }
-            if (sval.IndexOf(":") < 0)
+            if (sval.IndexOf(':') < 0)
             {
                 return double.Parse(sval, CultureInfo.InvariantCulture);
             }
             // first time this prop is extracted by round
-            int k = sval.IndexOf(":");
+            int k = sval.IndexOf(':');
             string colName = sval.Substring(0, k - 0);
             sval = sval.Substring(k + 1);
             colForValByRound[name] = colName;
@@ -315,12 +315,12 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
             {
                 sval = dflt.ToString(); // LUCENENET NOTE: bool ignores the IFormatProvider
argument, it returns the values of constants
             }
-            if (sval.IndexOf(":") < 0)
+            if (sval.IndexOf(':') < 0)
             {
                 return bool.Parse(sval);
             }
             // first time this prop is extracted by round 
-            int k = sval.IndexOf(":");
+            int k = sval.IndexOf(':');
             string colName = sval.Substring(0, k - 0);
             sval = sval.Substring(k + 1);
             colForValByRound[name] = colName;
@@ -386,7 +386,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
 
         private string[] PropToStringArray(string s)
         {
-            if (s.IndexOf(":") < 0)
+            if (s.IndexOf(':') < 0)
             {
                 return new string[] { s };
             }
@@ -404,7 +404,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
         // extract properties to array, e.g. for "10:100:5" return int[]{10,100,5}. 
         private int[] PropToInt32Array(string s)
         {
-            if (s.IndexOf(":") < 0)
+            if (s.IndexOf(':') < 0)
             {
                 return new int[] { int.Parse(s, CultureInfo.InvariantCulture) };
             }
@@ -427,7 +427,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
         // extract properties to array, e.g. for "10.7:100.4:-2.3" return int[]{10.7,100.4,-2.3}.

         private double[] PropToDoubleArray(string s)
         {
-            if (s.IndexOf(":") < 0)
+            if (s.IndexOf(':') < 0)
             {
                 return new double[] { double.Parse(s, CultureInfo.InvariantCulture) };
             }
@@ -450,7 +450,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Utils
         // extract properties to array, e.g. for "true:true:false" return boolean[]{true,false,false}.

         private bool[] PropToBooleanArray(string s)
         {
-            if (s.IndexOf(":") < 0)
+            if (s.IndexOf(':') < 0)
             {
                 return new bool[] { bool.Parse(s) };
             }
diff --git a/src/Lucene.Net.Benchmark/Utils/ExtractReuters.cs b/src/Lucene.Net.Benchmark/Utils/ExtractReuters.cs
index 83b2cb4..a9e06b9 100644
--- a/src/Lucene.Net.Benchmark/Utils/ExtractReuters.cs
+++ b/src/Lucene.Net.Benchmark/Utils/ExtractReuters.cs
@@ -84,7 +84,7 @@ namespace Lucene.Net.Benchmarks.Utils
                     {
                         // when we see a closing reuters tag, flush the file
 
-                        if (line.IndexOf("</REUTERS") == -1)
+                        if (line.IndexOf("</REUTERS", StringComparison.Ordinal) == -1)
                         {
                             // Replace the SGM escape sequences
 
diff --git a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
index ecb2119..804acd7 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
@@ -3017,7 +3017,7 @@ namespace Lucene.Net.Index
                 }
                 catch (System.ArgumentException iae)
                 {
-                    if (iae.Message.IndexOf("is too large") == -1)
+                    if (iae.Message.IndexOf("is too large", StringComparison.Ordinal) ==
-1)
                     {
                         throw iae;
                     }
@@ -3039,7 +3039,7 @@ namespace Lucene.Net.Index
             }
             catch (System.ArgumentException iae)
             {
-                if (iae.Message.IndexOf("is too large") == -1)
+                if (iae.Message.IndexOf("is too large", StringComparison.Ordinal) == -1)
                 {
                     throw iae;
                 }
diff --git a/src/Lucene.Net.TestFramework/Search/CheckHits.cs b/src/Lucene.Net.TestFramework/Search/CheckHits.cs
index ab9ee60..e7fbf69 100644
--- a/src/Lucene.Net.TestFramework/Search/CheckHits.cs
+++ b/src/Lucene.Net.TestFramework/Search/CheckHits.cs
@@ -386,11 +386,11 @@ namespace Lucene.Net.Search
                     if (!(productOf || sumOf || maxOf))
                     {
                         // maybe 'max plus x times others'
-                        int k1 = descr.IndexOf("max plus ");
+                        int k1 = descr.IndexOf("max plus ", StringComparison.Ordinal);
                         if (k1 >= 0)
                         {
                             k1 += "max plus ".Length;
-                            int k2 = descr.IndexOf(" ", k1);
+                            int k2 = descr.IndexOf(" ", k1, StringComparison.Ordinal);
                             try
                             {
                                 // LUCENENET NOTE: Using current culture here is intentional
because
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs
index ba7f6ee..c5785ca 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenCountFilterFactory.cs
@@ -50,7 +50,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
             }
             catch (System.ArgumentException e)
             {
-                assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.IndexOf(LimitTokenCountFilterFactory.MAX_TOKEN_COUNT_KEY));
+                assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.IndexOf(LimitTokenCountFilterFactory.MAX_TOKEN_COUNT_KEY,
StringComparison.Ordinal));
             }
         }
 
diff --git a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs
b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs
index 0cef7e6..56bbf5b 100644
--- a/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs
+++ b/src/Lucene.Net.Tests.Analysis.Common/Analysis/Miscellaneous/TestLimitTokenPositionFilterFactory.cs
@@ -50,7 +50,7 @@ namespace Lucene.Net.Analysis.Miscellaneous
             }
             catch (System.ArgumentException e)
             {
-                assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.IndexOf(LimitTokenPositionFilterFactory.MAX_TOKEN_POSITION_KEY));
+                assertTrue("exception doesn't mention param: " + e.Message, 0 < e.Message.IndexOf(LimitTokenPositionFilterFactory.MAX_TOKEN_POSITION_KEY,
StringComparison.Ordinal));
             }
         }
 
diff --git a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs
index 7f832c7..41d9f28 100644
--- a/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs
+++ b/src/Lucene.Net.Tests.Analysis.Kuromoji/TestJapaneseTokenizer.cs
@@ -439,7 +439,7 @@ namespace Lucene.Net.Analysis.Ja
                              surfaceForms);
 
 
-            assertTrue(gv2.Finish().IndexOf("22.0") != -1);
+            assertTrue(gv2.Finish().IndexOf("22.0", StringComparison.Ordinal) != -1);
         }
 
         private void assertReadings(String input, params String[] readings)
diff --git a/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs b/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs
index 2ae8d68..da676c0 100644
--- a/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs
+++ b/src/Lucene.Net.Tests.Benchmark/ByTask/Feeds/TrecContentSourceTest.cs
@@ -69,7 +69,7 @@ namespace Lucene.Net.Benchmarks.ByTask.Feeds
             assertNotNull(dd);
             assertEquals(expName, dd.Name);
             assertEquals(expTitle, dd.Title);
-            assertTrue(dd.Body.IndexOf(expBody) != -1);
+            assertTrue(dd.Body.IndexOf(expBody, StringComparison.Ordinal) != -1);
             DateTime? date = dd.Date != null ? DateTools.StringToDate(dd.Date) : (DateTime?)null;
             assertEquals(expDate, date);
         }
diff --git a/src/Lucene.Net.Tests.Benchmark/ByTask/TestPerfTasksParse.cs b/src/Lucene.Net.Tests.Benchmark/ByTask/TestPerfTasksParse.cs
index e604cef..3d3afae 100644
--- a/src/Lucene.Net.Tests.Benchmark/ByTask/TestPerfTasksParse.cs
+++ b/src/Lucene.Net.Tests.Benchmark/ByTask/TestPerfTasksParse.cs
@@ -55,7 +55,7 @@ namespace Lucene.Net.Benchmarks.ByTask
             bool foundAdd = false;
             foreach (PerfTask task in algTasks)
             {
-                if (task.toString().IndexOf(taskStr) >= 0)
+                if (task.toString().IndexOf(taskStr, StringComparison.Ordinal) >= 0)
                 {
                     foundAdd = true;
                 }
@@ -80,7 +80,7 @@ namespace Lucene.Net.Benchmarks.ByTask
             bool foundAdd = false;
             foreach (PerfTask task in algTasks)
             {
-                if (task.toString().IndexOf(taskStr) >= 0)
+                if (task.toString().IndexOf(taskStr, StringComparison.Ordinal) >= 0)
                 {
                     foundAdd = true;
                 }
diff --git a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/BreakIteratorBoundaryScannerTest.cs
b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/BreakIteratorBoundaryScannerTest.cs
index f16898d..6210fa8 100644
--- a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/BreakIteratorBoundaryScannerTest.cs
+++ b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/BreakIteratorBoundaryScannerTest.cs
@@ -57,11 +57,11 @@ namespace Lucene.Net.Search.VectorHighlight
             BreakIterator bi = JdkBreakIterator.GetWordInstance(CultureInfo.InvariantCulture);
             IBoundaryScanner scanner = new BreakIteratorBoundaryScanner(bi);
 
-            int start = TEXT.IndexOf("formance");
-            int expected = TEXT.IndexOf("high-performance");
+            int start = TEXT.IndexOf("formance", StringComparison.Ordinal);
+            int expected = TEXT.IndexOf("high-performance", StringComparison.Ordinal);
             TestFindStartOffset(text, start, expected, scanner);
 
-            expected = TEXT.IndexOf(", full");
+            expected = TEXT.IndexOf(", full", StringComparison.Ordinal);
             TestFindEndOffset(text, start, expected, scanner);
         }
 
@@ -73,11 +73,11 @@ namespace Lucene.Net.Search.VectorHighlight
             BreakIterator bi = JdkBreakIterator.GetSentenceInstance(CultureInfo.CurrentCulture);
             IBoundaryScanner scanner = new BreakIteratorBoundaryScanner(bi);
 
-            int start = TEXT.IndexOf("any application");
-            int expected = TEXT.IndexOf("It is a");
+            int start = TEXT.IndexOf("any application", StringComparison.Ordinal);
+            int expected = TEXT.IndexOf("It is a", StringComparison.Ordinal);
             TestFindStartOffset(text, start, expected, scanner);
 
-            expected = TEXT.IndexOf("Apache Lucene is an open source");
+            expected = TEXT.IndexOf("Apache Lucene is an open source", StringComparison.Ordinal);
             TestFindEndOffset(text, start, expected, scanner);
         }
 
@@ -89,11 +89,11 @@ namespace Lucene.Net.Search.VectorHighlight
             BreakIterator bi = BreakIterator.GetLineInstance(CultureInfo.CurrentCulture);
             IBoundaryScanner scanner = new BreakIteratorBoundaryScanner(bi);
 
-            int start = TEXT.IndexOf("any application");
-            int expected = TEXT.IndexOf("nearly");
+            int start = TEXT.IndexOf("any application", StringComparison.Ordinal);
+            int expected = TEXT.IndexOf("nearly", StringComparison.Ordinal);
             TestFindStartOffset(text, start, expected, scanner);
 
-            expected = TEXT.IndexOf("application that requires");
+            expected = TEXT.IndexOf("application that requires", StringComparison.Ordinal);
             TestFindEndOffset(text, start, expected, scanner);
         }
 
diff --git a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/IndexTimeSynonymTest.cs b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/IndexTimeSynonymTest.cs
index 029fd3d..7620a60 100644
--- a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/IndexTimeSynonymTest.cs
+++ b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/IndexTimeSynonymTest.cs
@@ -204,7 +204,7 @@ namespace Lucene.Net.Search.VectorHighlight
             FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
             FieldPhraseList fpl = new FieldPhraseList(stack, fq);
             assertEquals(1, fpl.PhraseList.size());
-            assertTrue(fpl.PhraseList[0].toString().IndexOf("(1.0)((3,5))") > 0);
+            assertTrue(fpl.PhraseList[0].toString().IndexOf("(1.0)((3,5))", StringComparison.Ordinal)
> 0);
             assertEquals(3, fpl.PhraseList[0].StartOffset);
             assertEquals(5, fpl.PhraseList[0].EndOffset);
         }
@@ -263,7 +263,7 @@ namespace Lucene.Net.Search.VectorHighlight
             FieldTermStack stack = new FieldTermStack(reader, 0, F, fq);
             FieldPhraseList fpl = new FieldPhraseList(stack, fq);
             assertEquals(1, fpl.PhraseList.size());
-            assertTrue(fpl.PhraseList[0].toString().IndexOf("(1.0)((3,20))") > 0);
+            assertTrue(fpl.PhraseList[0].toString().IndexOf("(1.0)((3,20))", StringComparison.Ordinal)
> 0);
             assertEquals(3, fpl.PhraseList[0].StartOffset);
             assertEquals(20, fpl.PhraseList[0].EndOffset);
         }
diff --git a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleBoundaryScannerTest.cs
b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleBoundaryScannerTest.cs
index 74314ef..39ca4c1 100644
--- a/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleBoundaryScannerTest.cs
+++ b/src/Lucene.Net.Tests.Highlighter/VectorHighlight/SimpleBoundaryScannerTest.cs
@@ -39,12 +39,12 @@ namespace Lucene.Net.Search.VectorHighlight
             start = 0;
             assertEquals(start, scanner.FindStartOffset(text, start));
 
-            start = TEXT.IndexOf("formance");
-            int expected = TEXT.IndexOf("high-performance");
+            start = TEXT.IndexOf("formance", StringComparison.Ordinal);
+            int expected = TEXT.IndexOf("high-performance", StringComparison.Ordinal);
             assertEquals(expected, scanner.FindStartOffset(text, start));
 
-            start = TEXT.IndexOf("che");
-            expected = TEXT.IndexOf("Apache");
+            start = TEXT.IndexOf("che", StringComparison.Ordinal);
+            expected = TEXT.IndexOf("Apache", StringComparison.Ordinal);
             assertEquals(expected, scanner.FindStartOffset(text, start));
         }
 
@@ -60,8 +60,8 @@ namespace Lucene.Net.Search.VectorHighlight
             start = -1;
             assertEquals(start, scanner.FindEndOffset(text, start));
 
-            start = TEXT.IndexOf("full-");
-            int expected = TEXT.IndexOf("\ntext");
+            start = TEXT.IndexOf("full-", StringComparison.Ordinal);
+            int expected = TEXT.IndexOf("\ntext", StringComparison.Ordinal);
             assertEquals(expected, scanner.FindEndOffset(text, start));
         }
     }
diff --git a/src/Lucene.Net.Tests.QueryParser/Util/QueryParserTestBase.cs b/src/Lucene.Net.Tests.QueryParser/Util/QueryParserTestBase.cs
index 0064166..dee6193 100644
--- a/src/Lucene.Net.Tests.QueryParser/Util/QueryParserTestBase.cs
+++ b/src/Lucene.Net.Tests.QueryParser/Util/QueryParserTestBase.cs
@@ -656,7 +656,7 @@ namespace Lucene.Net.QueryParsers.Util
 
         private string EscapeDateString(string s)
         {
-            if (s.IndexOf(" ") > -1)
+            if (s.IndexOf(' ') > -1)
             {
                 return "\"" + s + "\"";
             }
diff --git a/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs b/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs
index ff98a11..de3a32e 100644
--- a/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs
+++ b/src/Lucene.Net.Tests/Analysis/TestGraphTokenizers.cs
@@ -702,7 +702,7 @@ namespace Lucene.Net.Analysis
             TokenStream ts = new CannedTokenStream(new Token[] { Token("abc", 1, 1, 0, 4)
});
             StringWriter w = new StringWriter();
             (new TokenStreamToDot("abcd", ts, (TextWriter)(w))).ToDot();
-            Assert.IsTrue(w.ToString().IndexOf("abc / abcd") != -1);
+            Assert.IsTrue(w.ToString().IndexOf("abc / abcd", StringComparison.Ordinal) !=
-1);
         }
 
         [Test]
diff --git a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs
index eb4c0d1..cbe0126 100644
--- a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs
+++ b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility.cs
@@ -287,7 +287,7 @@ namespace Lucene.Net.Index
                         Console.WriteLine(e.StackTrace);
                     }
                     // Make sure exc message includes a path=
-                    Assert.IsTrue(e.Message.IndexOf("path=\"") != -1, "got exc message: "
+ e.Message);
+                    Assert.IsTrue(e.Message.IndexOf("path=\"", StringComparison.Ordinal)
!= -1, "got exc message: " + e.Message);
                 }
                 finally
                 {
diff --git a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs
index e0160ef..1c7c3f7 100644
--- a/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs
+++ b/src/Lucene.Net.Tests/Index/TestBackwardsCompatibility3x.cs
@@ -218,7 +218,7 @@ namespace Lucene.Net.Index
                         Console.WriteLine(e.StackTrace);
                     }
                     // Make sure exc message includes a path=
-                    Assert.IsTrue(e.Message.IndexOf("path=\"") != -1, "got exc message: "
+ e.Message);
+                    Assert.IsTrue(e.Message.IndexOf("path=\"", StringComparison.Ordinal)
!= -1, "got exc message: " + e.Message);
                 }
                 finally
                 {
diff --git a/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs b/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs
index bd92c66..c7ddaed 100644
--- a/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs
+++ b/src/Lucene.Net.Tests/Index/TestIndexWriterConfig.cs
@@ -264,7 +264,7 @@ namespace Lucene.Net.Index
                 {
                     continue;
                 }
-                Assert.IsTrue(str.IndexOf(f.Name) != -1, f.Name + " not found in toString");
+                Assert.IsTrue(str.IndexOf(f.Name, StringComparison.Ordinal) != -1, f.Name
+ " not found in toString");
             }
         }
 
diff --git a/src/Lucene.Net.Tests/Index/TestSegmentMerger.cs b/src/Lucene.Net.Tests/Index/TestSegmentMerger.cs
index 30786b5..1bfe964 100644
--- a/src/Lucene.Net.Tests/Index/TestSegmentMerger.cs
+++ b/src/Lucene.Net.Tests/Index/TestSegmentMerger.cs
@@ -3,6 +3,7 @@ using Lucene.Net.Support;
 namespace Lucene.Net.Index
 {
     using NUnit.Framework;
+    using System;
     using BytesRef = Lucene.Net.Util.BytesRef;
 
     /*
@@ -139,7 +140,7 @@ namespace Lucene.Net.Index
                 string term = termsEnum.Term.Utf8ToString();
                 int freq = (int)termsEnum.TotalTermFreq;
                 //System.out.println("Term: " + term + " Freq: " + freq);
-                Assert.IsTrue(DocHelper.FIELD_2_TEXT.IndexOf(term) != -1);
+                Assert.IsTrue(DocHelper.FIELD_2_TEXT.IndexOf(term, StringComparison.Ordinal)
!= -1);
                 Assert.IsTrue(DocHelper.FIELD_2_FREQS[i] == freq);
                 i++;
             }
diff --git a/src/Lucene.Net.Tests/Index/TestSegmentReader.cs b/src/Lucene.Net.Tests/Index/TestSegmentReader.cs
index d96376a..95da6b6 100644
--- a/src/Lucene.Net.Tests/Index/TestSegmentReader.cs
+++ b/src/Lucene.Net.Tests/Index/TestSegmentReader.cs
@@ -148,7 +148,7 @@ namespace Lucene.Net.Index
                     BytesRef term = termsEnum.Term;
                     Assert.IsTrue(term != null);
                     string fieldValue = (string)DocHelper.NameValues[field];
-                    Assert.IsTrue(fieldValue.IndexOf(term.Utf8ToString()) != -1);
+                    Assert.IsTrue(fieldValue.IndexOf(term.Utf8ToString(), StringComparison.Ordinal)
!= -1);
                 }
             }
 
@@ -216,7 +216,7 @@ namespace Lucene.Net.Index
             {
                 string term = termsEnum.Term.Utf8ToString();
                 int freq = (int)termsEnum.TotalTermFreq;
-                Assert.IsTrue(DocHelper.FIELD_2_TEXT.IndexOf(term) != -1);
+                Assert.IsTrue(DocHelper.FIELD_2_TEXT.IndexOf(term, StringComparison.Ordinal)
!= -1);
                 Assert.IsTrue(freq > 0);
             }
 
diff --git a/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs b/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs
index 261ac15..02ff70c 100644
--- a/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs
+++ b/src/Lucene.Net.Tests/Search/Payloads/TestPayloadNearQuery.cs
@@ -234,7 +234,7 @@ namespace Lucene.Net.Search.Payloads
                 Assert.AreEqual(3, doc.Score, doc.Score + " does not equal: " + 3);
                 Explanation explain = Searcher.Explain(query, hits.ScoreDocs[j].Doc);
                 string exp = explain.ToString();
-                Assert.IsTrue(exp.IndexOf("AveragePayloadFunction") > -1, exp);
+                Assert.IsTrue(exp.IndexOf("AveragePayloadFunction", StringComparison.Ordinal)
> -1, exp);
                 Assert.AreEqual(3f, explain.Value, hits.ScoreDocs[j].Score + " explain value
does not equal: " + 3);
             }
         }
@@ -257,7 +257,7 @@ namespace Lucene.Net.Search.Payloads
                 Assert.AreEqual(4, doc.Score, doc.Score + " does not equal: " + 4);
                 Explanation explain = Searcher.Explain(query, hits.ScoreDocs[j].Doc);
                 string exp = explain.ToString();
-                Assert.IsTrue(exp.IndexOf("MaxPayloadFunction") > -1, exp);
+                Assert.IsTrue(exp.IndexOf("MaxPayloadFunction", StringComparison.Ordinal)
> -1, exp);
                 Assert.AreEqual(4f, explain.Value, hits.ScoreDocs[j].Score + " explain value
does not equal: " + 4);
             }
         }
@@ -280,7 +280,7 @@ namespace Lucene.Net.Search.Payloads
                 Assert.AreEqual(2, doc.Score, doc.Score + " does not equal: " + 2);
                 Explanation explain = Searcher.Explain(query, hits.ScoreDocs[j].Doc);
                 string exp = explain.ToString();
-                Assert.IsTrue(exp.IndexOf("MinPayloadFunction") > -1, exp);
+                Assert.IsTrue(exp.IndexOf("MinPayloadFunction", StringComparison.Ordinal)
> -1, exp);
                 Assert.AreEqual(2f, explain.Value, hits.ScoreDocs[j].Score + " explain value
does not equal: " + 2);
             }
         }
diff --git a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs
index 096ff51..6b07118 100644
--- a/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs
+++ b/src/Lucene.Net.Tests/Search/TestBooleanQuery.cs
@@ -404,7 +404,7 @@ namespace Lucene.Net.Search
 
             protected override void Search(IList<AtomicReaderContext> leaves, Weight
weight, ICollector collector)
             {
-                Assert.AreEqual(-1, collector.GetType().Name.IndexOf("OutOfOrder"));
+                Assert.AreEqual(-1, collector.GetType().Name.IndexOf("OutOfOrder", StringComparison.Ordinal));
                 base.Search(leaves, weight, collector);
             }
         }
diff --git a/src/Lucene.Net.Tests/Search/TestFieldCache.cs b/src/Lucene.Net.Tests/Search/TestFieldCache.cs
index 926f426..e36c6a6 100644
--- a/src/Lucene.Net.Tests/Search/TestFieldCache.cs
+++ b/src/Lucene.Net.Tests/Search/TestFieldCache.cs
@@ -194,7 +194,7 @@ namespace Lucene.Net.Search
                     cache.GetDoubles(Reader, "theDouble", false);
                     cache.GetSingles(Reader, "theDouble", false);
                 }
-                Assert.IsTrue(sb.ToString(/*IOUtils.UTF_8*/).IndexOf("WARNING") != -1);
+                Assert.IsTrue(sb.ToString(/*IOUtils.UTF_8*/).IndexOf("WARNING", StringComparison.Ordinal)
!= -1);
             }
             finally
             {
diff --git a/src/Lucene.Net.Tests/Store/TestLockFactory.cs b/src/Lucene.Net.Tests/Store/TestLockFactory.cs
index 4b7ec9b..46e6655 100644
--- a/src/Lucene.Net.Tests/Store/TestLockFactory.cs
+++ b/src/Lucene.Net.Tests/Store/TestLockFactory.cs
@@ -315,7 +315,7 @@ namespace Lucene.Net.Store
                     }
                     catch (IOException e)
                     {
-                        if (e.ToString().IndexOf(" timed out:") == -1)
+                        if (e.ToString().IndexOf(" timed out:", StringComparison.Ordinal)
== -1)
                         {
                             HitException = true;
                             Console.WriteLine("Stress Test Index Writer: creation hit unexpected
IOException: " + e.ToString());
diff --git a/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs b/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs
index b08b343..9a8467b 100644
--- a/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs
+++ b/src/Lucene.Net.Tests/Support/IO/TestByteBuffer.cs
@@ -4,6 +4,7 @@
 using Lucene.Net.Attributes;
 using NUnit.Framework;
 using System;
+using System.Globalization;
 
 namespace Lucene.Net.Support.IO
 {
@@ -1087,10 +1088,10 @@ namespace Lucene.Net.Support.IO
         public virtual void TestToString()
         {
             String str = buf.toString();
-            assertTrue(str.IndexOf("Byte") >= 0 || str.IndexOf("byte") >= 0);
-            assertTrue(str.IndexOf("" + buf.Position) >= 0);
-            assertTrue(str.IndexOf("" + buf.Limit) >= 0);
-            assertTrue(str.IndexOf("" + buf.Capacity) >= 0);
+            assertTrue(str.IndexOf("Byte", StringComparison.Ordinal) >= 0 || str.IndexOf("byte",
StringComparison.Ordinal) >= 0);
+            assertTrue(str.IndexOf("" + buf.Position.ToString(CultureInfo.InvariantCulture),
StringComparison.Ordinal) >= 0);
+            assertTrue(str.IndexOf("" + buf.Limit.ToString(CultureInfo.InvariantCulture),
StringComparison.Ordinal) >= 0);
+            assertTrue(str.IndexOf("" + buf.Capacity.ToString(CultureInfo.InvariantCulture),
StringComparison.Ordinal) >= 0);
         }
 
         // LUCENENET NOTE: Not supported
diff --git a/src/Lucene.Net.Tests/Support/TestOldPatches.cs b/src/Lucene.Net.Tests/Support/TestOldPatches.cs
index d4f36c5..bc781cd 100644
--- a/src/Lucene.Net.Tests/Support/TestOldPatches.cs
+++ b/src/Lucene.Net.Tests/Support/TestOldPatches.cs
@@ -53,7 +53,7 @@ namespace Lucene.Net.Support
         //    Lucene.Net.Index.IndexReader reader = writer.GetReader();
         //    Lucene.Net.Index.TermPositionVector tpv = reader.GetTermFreqVector(0, "contents")
as Lucene.Net.Index.TermPositionVector;
         //    //Console.WriteLine("tpv: " + tpv);
-        //    int index = tpv.IndexOf("a_");
+        //    int index = tpv.IndexOf("a_", StringComparison.Ordinal);
         //    Assert.AreEqual(index, 1, "See the issue: LUCENENET-183");
         //}
 
diff --git a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
index 2ffa46c..842297e 100644
--- a/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
+++ b/src/Lucene.Net.Tests/Util/Fst/TestFSTs.cs
@@ -1354,7 +1354,7 @@ namespace Lucene.Net.Util.Fst
             Util.ToDot(fst, w, false, false);
             w.Dispose();
             //System.out.println(w.toString());
-            Assert.IsTrue(w.ToString().IndexOf("label=\"t/[7]\"") != -1);
+            Assert.IsTrue(w.ToString().IndexOf("label=\"t/[7]\"", StringComparison.Ordinal)
!= -1);
         }
 
         [Test]
@@ -1373,9 +1373,9 @@ namespace Lucene.Net.Util.Fst
             //System.out.println(w.toString());
 
             // check for accept state at label t
-            Assert.IsTrue(w.ToString().IndexOf("[label=\"t\" style=\"bold\"") != -1);
+            Assert.IsTrue(w.ToString().IndexOf("[label=\"t\" style=\"bold\"", StringComparison.Ordinal)
!= -1);
             // check for accept state at label n
-            Assert.IsTrue(w.ToString().IndexOf("[label=\"n\" style=\"bold\"") != -1);
+            Assert.IsTrue(w.ToString().IndexOf("[label=\"n\" style=\"bold\"", StringComparison.Ordinal)
!= -1);
         }
 
         // Make sure raw FST can differentiate between final vs
diff --git a/src/Lucene.Net/Support/Util/NamedServiceFactory.cs b/src/Lucene.Net/Support/Util/NamedServiceFactory.cs
index 03ac82c..4756206 100644
--- a/src/Lucene.Net/Support/Util/NamedServiceFactory.cs
+++ b/src/Lucene.Net/Support/Util/NamedServiceFactory.cs
@@ -125,7 +125,7 @@ namespace Lucene.Net.Util
         {
             string name = type.Name;
             string genericSuffix = string.Empty;
-            int genericIndex = name.IndexOf("`");
+            int genericIndex = name.IndexOf('`');
             if (genericIndex > -1)
             {
                 genericSuffix = "Generic" + name.Substring(genericIndex + 1);


Mime
View raw message