lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nightowl...@apache.org
Subject [19/33] lucenenet git commit: SWEEP: In all codecs, ensured that Convert.ToXXX() and .ToString() are always done in the invariant culture. Things like Debug.Assert and logging are converted in the current culture.
Date Fri, 17 Mar 2017 22:28:49 GMT
SWEEP: In all codecs, ensured that Convert.ToXXX() and .ToString() are always done in the invariant culture. Things like Debug.Assert and logging are converted in the current culture.


Project: http://git-wip-us.apache.org/repos/asf/lucenenet/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucenenet/commit/6f5b4046
Tree: http://git-wip-us.apache.org/repos/asf/lucenenet/tree/6f5b4046
Diff: http://git-wip-us.apache.org/repos/asf/lucenenet/diff/6f5b4046

Branch: refs/heads/api-work
Commit: 6f5b40463f92a278f40a08c44ba5b32b305bcbfb
Parents: 9e779f7
Author: Shad Storhaug <shad@shadstorhaug.com>
Authored: Fri Mar 17 18:10:10 2017 +0700
Committer: Shad Storhaug <shad@shadstorhaug.com>
Committed: Sat Mar 18 03:21:43 2017 +0700

----------------------------------------------------------------------
 .../SimpleText/SimpleTextDocValuesReader.cs     | 10 ++--
 .../SimpleText/SimpleTextFieldInfosReader.cs    | 20 +++----
 .../SimpleText/SimpleTextFieldInfosWriter.cs    |  6 +--
 .../Codecs/Lucene3x/Lucene3xNormsProducer.cs    |  5 +-
 .../Lucene3x/Lucene3xSegmentInfoFormat.cs       |  5 +-
 .../Lucene3x/Lucene3xSegmentInfoReader.cs       | 10 ++--
 .../Codecs/Lucene40/Lucene40DocValuesReader.cs  | 21 ++++----
 .../Codecs/Lucene40/Lucene40FieldInfosReader.cs |  5 +-
 .../Analysis/BaseTokenStreamTestCase.cs         |  2 +-
 .../Codecs/Lucene40/Lucene40DocValuesWriter.cs  | 37 ++++++-------
 .../Index/BaseDocValuesFormatTestCase.cs        | 55 ++++++++++----------
 .../Index/BaseStoredFieldsFormatTestCase.cs     | 15 +++---
 src/Lucene.Net.TestFramework/Index/DocHelper.cs |  3 +-
 .../ThreadedIndexingAndSearchingTestCase.cs     |  3 +-
 .../Lucene.Net.TestFramework.csproj             |  2 +-
 .../Search/CheckHits.cs                         | 14 ++---
 .../Search/SearchEquivalenceTestBase.cs         |  5 +-
 .../Util/LineFileDocs.cs                        |  3 +-
 .../Util/VirtualMethod.cs                       |  6 +--
 19 files changed, 119 insertions(+), 108 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
index 39fe395..5908d73 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextDocValuesReader.cs
@@ -91,7 +91,7 @@ namespace Lucene.Net.Codecs.SimpleText
                     ReadLine();
                     Debug.Assert(StartsWith(SimpleTextDocValuesWriter.MINVALUE),
                         "got " + scratch.Utf8ToString() + " field=" + fieldName + " ext=" + ext);
-                    field.MinValue = Convert.ToInt64(StripPrefix(SimpleTextDocValuesWriter.MINVALUE));
+                    field.MinValue = Convert.ToInt64(StripPrefix(SimpleTextDocValuesWriter.MINVALUE), CultureInfo.InvariantCulture);
                     ReadLine();
                     Debug.Assert(StartsWith(SimpleTextDocValuesWriter.PATTERN));
                     field.Pattern = StripPrefix(SimpleTextDocValuesWriter.PATTERN);
@@ -102,7 +102,7 @@ namespace Lucene.Net.Codecs.SimpleText
                 {
                     ReadLine();
                     Debug.Assert(StartsWith(SimpleTextDocValuesWriter.MAXLENGTH));
-                    field.MaxLength = Convert.ToInt32(StripPrefix(SimpleTextDocValuesWriter.MAXLENGTH));
+                    field.MaxLength = Convert.ToInt32(StripPrefix(SimpleTextDocValuesWriter.MAXLENGTH), CultureInfo.InvariantCulture);
                     ReadLine();
                     Debug.Assert(StartsWith(SimpleTextDocValuesWriter.PATTERN));
                     field.Pattern = StripPrefix(SimpleTextDocValuesWriter.PATTERN);
@@ -113,10 +113,10 @@ namespace Lucene.Net.Codecs.SimpleText
                 {
                     ReadLine();
                     Debug.Assert(StartsWith(SimpleTextDocValuesWriter.NUMVALUES));
-                    field.NumValues = Convert.ToInt64(StripPrefix(SimpleTextDocValuesWriter.NUMVALUES));
+                    field.NumValues = Convert.ToInt64(StripPrefix(SimpleTextDocValuesWriter.NUMVALUES), CultureInfo.InvariantCulture);
                     ReadLine();
                     Debug.Assert(StartsWith(SimpleTextDocValuesWriter.MAXLENGTH));
-                    field.MaxLength = Convert.ToInt32(StripPrefix(SimpleTextDocValuesWriter.MAXLENGTH));
+                    field.MaxLength = Convert.ToInt32(StripPrefix(SimpleTextDocValuesWriter.MAXLENGTH), CultureInfo.InvariantCulture);
                     ReadLine();
                     Debug.Assert(StartsWith(SimpleTextDocValuesWriter.PATTERN));
                     field.Pattern = StripPrefix(SimpleTextDocValuesWriter.PATTERN);
@@ -520,7 +520,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
             public override long NextOrd()
             {
-                return _currentIndex == _currentOrds.Length ? NO_MORE_ORDS : Convert.ToInt64(_currentOrds[_currentIndex++]);
+                return _currentIndex == _currentOrds.Length ? NO_MORE_ORDS : Convert.ToInt64(_currentOrds[_currentIndex++], CultureInfo.InvariantCulture);
             }
 
             public override void SetDocument(int docID)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
index 4842751..0d8d059 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosReader.cs
@@ -1,8 +1,8 @@
-´╗┐using Lucene.Net.Support;
-using System;
+´╗┐using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Diagnostics;
+using System.Globalization;
 using System.Text;
 
 namespace Lucene.Net.Codecs.SimpleText
@@ -57,7 +57,7 @@ namespace Lucene.Net.Codecs.SimpleText
 
                 SimpleTextUtil.ReadLine(input, scratch);
                 Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.NUMFIELDS));
-                var size = Convert.ToInt32(ReadString(SimpleTextFieldInfosWriter.NUMFIELDS.Length, scratch));
+                var size = Convert.ToInt32(ReadString(SimpleTextFieldInfosWriter.NUMFIELDS.Length, scratch), CultureInfo.InvariantCulture);
                 var infos = new FieldInfo[size];
 
                 for (var i = 0; i < size; i++)
@@ -68,11 +68,11 @@ namespace Lucene.Net.Codecs.SimpleText
 
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.NUMBER));
-                    int fieldNumber = Convert.ToInt32(ReadString(SimpleTextFieldInfosWriter.NUMBER.Length, scratch));
+                    int fieldNumber = Convert.ToInt32(ReadString(SimpleTextFieldInfosWriter.NUMBER.Length, scratch), CultureInfo.InvariantCulture);
 
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.ISINDEXED));
-                    bool isIndexed = Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.ISINDEXED.Length, scratch));
+                    bool isIndexed = Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.ISINDEXED.Length, scratch), CultureInfo.InvariantCulture);
 
                     IndexOptions indexOptions;
                     if (isIndexed)
@@ -90,16 +90,16 @@ namespace Lucene.Net.Codecs.SimpleText
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.STORETV));
                     bool storeTermVector =
-                        Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.STORETV.Length, scratch));
+                        Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.STORETV.Length, scratch), CultureInfo.InvariantCulture);
 
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.PAYLOADS));
                     bool storePayloads =
-                        Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.PAYLOADS.Length, scratch));
+                        Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.PAYLOADS.Length, scratch), CultureInfo.InvariantCulture);
 
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.NORMS));
-                    bool omitNorms = !Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.NORMS.Length, scratch));
+                    bool omitNorms = !Convert.ToBoolean(ReadString(SimpleTextFieldInfosWriter.NORMS.Length, scratch), CultureInfo.InvariantCulture);
 
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.NORMS_TYPE));
@@ -113,11 +113,11 @@ namespace Lucene.Net.Codecs.SimpleText
 
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.DOCVALUES_GEN));
-                    long dvGen = Convert.ToInt64(ReadString(SimpleTextFieldInfosWriter.DOCVALUES_GEN.Length, scratch));
+                    long dvGen = Convert.ToInt64(ReadString(SimpleTextFieldInfosWriter.DOCVALUES_GEN.Length, scratch), CultureInfo.InvariantCulture);
 
                     SimpleTextUtil.ReadLine(input, scratch);
                     Debug.Assert(StringHelper.StartsWith(scratch, SimpleTextFieldInfosWriter.NUM_ATTS));
-                    int numAtts = Convert.ToInt32(ReadString(SimpleTextFieldInfosWriter.NUM_ATTS.Length, scratch));
+                    int numAtts = Convert.ToInt32(ReadString(SimpleTextFieldInfosWriter.NUM_ATTS.Length, scratch), CultureInfo.InvariantCulture);
                     IDictionary<string, string> atts = new Dictionary<string, string>();
 
                     for (int j = 0; j < numAtts; j++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
index 75979c8..7b8f6ee 100644
--- a/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
+++ b/src/Lucene.Net.Codecs/SimpleText/SimpleTextFieldInfosWriter.cs
@@ -100,15 +100,15 @@ namespace Lucene.Net.Codecs.SimpleText
                     }
 
                     SimpleTextUtil.Write(output, STORETV);
-                    SimpleTextUtil.Write(output, CultureInfo.InvariantCulture.TextInfo.ToLower(fi.HasVectors.ToString()), scratch);
+                    SimpleTextUtil.Write(output, CultureInfo.InvariantCulture.TextInfo.ToLower(fi.HasVectors.ToString(CultureInfo.InvariantCulture)), scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, PAYLOADS);
-                    SimpleTextUtil.Write(output, CultureInfo.InvariantCulture.TextInfo.ToLower(fi.HasPayloads.ToString()), scratch);
+                    SimpleTextUtil.Write(output, CultureInfo.InvariantCulture.TextInfo.ToLower(fi.HasPayloads.ToString(CultureInfo.InvariantCulture)), scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, NORMS);
-                    SimpleTextUtil.Write(output, CultureInfo.InvariantCulture.TextInfo.ToLower((!fi.OmitsNorms).ToString()), scratch);
+                    SimpleTextUtil.Write(output, CultureInfo.InvariantCulture.TextInfo.ToLower((!fi.OmitsNorms).ToString(CultureInfo.InvariantCulture)), scratch);
                     SimpleTextUtil.WriteNewline(output);
 
                     SimpleTextUtil.Write(output, NORMS_TYPE);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
index 68abb4d..00faced 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xNormsProducer.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Globalization;
 using System.Linq;
 using Lucene.Net.Support;
 
@@ -165,7 +166,7 @@ namespace Lucene.Net.Codecs.Lucene3x
         {
             if (HasSeparateNorms(info, number))
             {
-                long gen = Convert.ToInt64(info.GetAttribute(Lucene3xSegmentInfoFormat.NORMGEN_PREFIX + number));
+                long gen = Convert.ToInt64(info.GetAttribute(Lucene3xSegmentInfoFormat.NORMGEN_PREFIX + number), CultureInfo.InvariantCulture);
                 return IndexFileNames.FileNameFromGeneration(info.Name, SEPARATE_NORMS_EXTENSION + number, gen);
             }
             else
@@ -184,7 +185,7 @@ namespace Lucene.Net.Codecs.Lucene3x
             }
             else
             {
-                Debug.Assert(Convert.ToInt64(v) != SegmentInfo.NO);
+                Debug.Assert(Convert.ToInt64(v, CultureInfo.InvariantCulture) != SegmentInfo.NO);
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoFormat.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoFormat.cs
index 8110acb..86c55de 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoFormat.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoFormat.cs
@@ -1,4 +1,5 @@
 using System;
+using System.Globalization;
 
 namespace Lucene.Net.Codecs.Lucene3x
 {
@@ -84,7 +85,7 @@ namespace Lucene.Net.Codecs.Lucene3x
         public static int GetDocStoreOffset(SegmentInfo si)
         {
             string v = si.GetAttribute(DS_OFFSET_KEY);
-            return v == null ? -1 : Convert.ToInt32(v);
+            return v == null ? -1 : Convert.ToInt32(v, CultureInfo.InvariantCulture);
         }
 
         /// <returns> name used to derive fields/vectors file we share with other segments </returns>
@@ -98,7 +99,7 @@ namespace Lucene.Net.Codecs.Lucene3x
         public static bool GetDocStoreIsCompoundFile(SegmentInfo si)
         {
             string v = si.GetAttribute(DS_COMPOUND_KEY);
-            return v == null ? false : Convert.ToBoolean(v);
+            return v == null ? false : Convert.ToBoolean(v, CultureInfo.InvariantCulture);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoReader.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoReader.cs
index 7af8784..9bf4ddc 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xSegmentInfoReader.cs
@@ -1,7 +1,7 @@
-using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Globalization;
 using CompoundFileDirectory = Lucene.Net.Store.CompoundFileDirectory;
 using Directory = Lucene.Net.Store.Directory;
 
@@ -174,9 +174,9 @@ namespace Lucene.Net.Codecs.Lucene3x
             {
                 docStoreSegment = input.ReadString();
                 docStoreIsCompoundFile = input.ReadByte() == SegmentInfo.YES;
-                attributes[Lucene3xSegmentInfoFormat.DS_OFFSET_KEY] = Convert.ToString(docStoreOffset);
+                attributes[Lucene3xSegmentInfoFormat.DS_OFFSET_KEY] = Convert.ToString(docStoreOffset, CultureInfo.InvariantCulture);
                 attributes[Lucene3xSegmentInfoFormat.DS_NAME_KEY] = docStoreSegment;
-                attributes[Lucene3xSegmentInfoFormat.DS_COMPOUND_KEY] = Convert.ToString(docStoreIsCompoundFile);
+                attributes[Lucene3xSegmentInfoFormat.DS_COMPOUND_KEY] = Convert.ToString(docStoreIsCompoundFile, CultureInfo.InvariantCulture);
             }
             else
             {
@@ -262,7 +262,7 @@ namespace Lucene.Net.Codecs.Lucene3x
             // parse the normgen stuff and shove it into attributes
             if (normGen != null)
             {
-                attributes[Lucene3xSegmentInfoFormat.NORMGEN_KEY] = Convert.ToString(numNormGen);
+                attributes[Lucene3xSegmentInfoFormat.NORMGEN_KEY] = Convert.ToString(numNormGen, CultureInfo.InvariantCulture);
                 foreach (KeyValuePair<int, long> ent in normGen)
                 {
                     long gen = ent.Value;
@@ -270,7 +270,7 @@ namespace Lucene.Net.Codecs.Lucene3x
                     {
                         // Definitely a separate norm file, with generation:
                         files.Add(IndexFileNames.FileNameFromGeneration(name, "s" + ent.Key, gen));
-                        attributes[Lucene3xSegmentInfoFormat.NORMGEN_PREFIX + ent.Key] = Convert.ToString(gen);
+                        attributes[Lucene3xSegmentInfoFormat.NORMGEN_PREFIX + ent.Key] = Convert.ToString(gen, CultureInfo.InvariantCulture);
                     }
                     else if (gen == SegmentInfo.NO)
                     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
index b1cee7c..54d3511 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
@@ -1,6 +1,7 @@
 using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 
 namespace Lucene.Net.Codecs.Lucene40
 {
@@ -75,7 +76,7 @@ namespace Lucene.Net.Codecs.Lucene40
                 NumericDocValues instance;
                 if (!numericInstances.TryGetValue(field.Number, out instance))
                 {
-                    string fileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "dat");
+                    string fileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "dat");
                     IndexInput input = dir.OpenInput(fileName, state.Context);
                     bool success = false;
                     try
@@ -455,7 +456,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private BinaryDocValues LoadBytesFixedStraight(FieldInfo field)
         {
-            string fileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "dat");
+            string fileName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "dat");
             IndexInput input = dir.OpenInput(fileName, state.Context);
             bool success = false;
             try
@@ -502,8 +503,8 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private BinaryDocValues LoadBytesVarStraight(FieldInfo field)
         {
-            string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "dat");
-            string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "idx");
+            string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "dat");
+            string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "idx");
             IndexInput data = null;
             IndexInput index = null;
             bool success = false;
@@ -558,8 +559,8 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private BinaryDocValues LoadBytesFixedDeref(FieldInfo field)
         {
-            string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "dat");
-            string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "idx");
+            string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "dat");
+            string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "idx");
             IndexInput data = null;
             IndexInput index = null;
             bool success = false;
@@ -617,8 +618,8 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private BinaryDocValues LoadBytesVarDeref(FieldInfo field)
         {
-            string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "dat");
-            string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "idx");
+            string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "dat");
+            string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "idx");
             IndexInput data = null;
             IndexInput index = null;
             bool success = false;
@@ -691,8 +692,8 @@ namespace Lucene.Net.Codecs.Lucene40
                 SortedDocValues instance;
                 if (!sortedInstances.TryGetValue(field.Number, out instance))
                 {
-                    string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "dat");
-                    string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number), segmentSuffix, "idx");
+                    string dataName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "dat");
+                    string indexName = IndexFileNames.SegmentFileName(state.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), segmentSuffix, "idx");
                     IndexInput data = null;
                     IndexInput index = null;
                     bool success = false;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
index a0955aa..75070bb 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40FieldInfosReader.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 
 namespace Lucene.Net.Codecs.Lucene40
 {
@@ -104,7 +105,7 @@ namespace Lucene.Net.Codecs.Lucene40
                     IDictionary<string, string> attributes = input.ReadStringStringMap();
                     if (oldValuesType.GetMapping() != DocValuesType.NONE)
                     {
-                        attributes[LEGACY_DV_TYPE_KEY] = oldValuesType.ToString();
+                        attributes[LEGACY_DV_TYPE_KEY] = oldValuesType.ToString(CultureInfo.InvariantCulture);
                     }
                     if (oldNormsType.GetMapping() != DocValuesType.NONE)
                     {
@@ -112,7 +113,7 @@ namespace Lucene.Net.Codecs.Lucene40
                         {
                             throw new CorruptIndexException("invalid norm type: " + oldNormsType + " (resource=" + input + ")");
                         }
-                        attributes[LEGACY_NORM_TYPE_KEY] = oldNormsType.ToString();
+                        attributes[LEGACY_NORM_TYPE_KEY] = oldNormsType.ToString(CultureInfo.InvariantCulture);
                     }
                     infos[i] = new FieldInfo(name, isIndexed, fieldNumber, storeTermVector, omitNorms, storePayloads, indexOptions, oldValuesType.GetMapping(), oldNormsType.GetMapping(), attributes);
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
index 3efb1ac..ca2d21d 100644
--- a/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/BaseTokenStreamTestCase.cs
@@ -97,7 +97,7 @@ namespace Lucene.Net.Analysis
 
             public override int GetHashCode()
             {
-                return 76137213 ^ Convert.ToBoolean(ClearCalled).GetHashCode();
+                return 76137213 ^ ClearCalled.GetHashCode();
             }
 
             public override void CopyTo(IAttribute target)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40DocValuesWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40DocValuesWriter.cs b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40DocValuesWriter.cs
index 3747a6a..324103c 100644
--- a/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40DocValuesWriter.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/Lucene40/Lucene40DocValuesWriter.cs
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Globalization;
 using System.Linq;
 
 namespace Lucene.Net.Codecs.Lucene40
@@ -62,7 +63,7 @@ namespace Lucene.Net.Codecs.Lucene40
                 maxValue = Math.Max(maxValue, v);
             }
 
-            string fileName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "dat");
+            string fileName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "dat");
             IndexOutput data = Dir.CreateOutput(fileName, State.Context);
             bool success = false;
             try
@@ -103,7 +104,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddBytesField(FieldInfo field, IndexOutput output, IEnumerable<long?> values)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.FIXED_INTS_8.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.FIXED_INTS_8.ToString(CultureInfo.InvariantCulture));
             CodecUtil.WriteHeader(output, Lucene40DocValuesFormat.INTS_CODEC_NAME, Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
             output.WriteInt32(1); // size
             foreach (long? n in values)
@@ -114,7 +115,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddShortsField(FieldInfo field, IndexOutput output, IEnumerable<long?> values)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.FIXED_INTS_16.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.FIXED_INTS_16.ToString(CultureInfo.InvariantCulture));
             CodecUtil.WriteHeader(output, Lucene40DocValuesFormat.INTS_CODEC_NAME, Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
             output.WriteInt32(2); // size
             foreach (long? n in values)
@@ -125,7 +126,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddIntsField(FieldInfo field, IndexOutput output, IEnumerable<long?> values)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.FIXED_INTS_32.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.FIXED_INTS_32.ToString(CultureInfo.InvariantCulture));
             CodecUtil.WriteHeader(output, Lucene40DocValuesFormat.INTS_CODEC_NAME, Lucene40DocValuesFormat.INTS_VERSION_CURRENT);
             output.WriteInt32(4); // size
             foreach (long? n in values)
@@ -136,7 +137,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddVarIntsField(FieldInfo field, IndexOutput output, IEnumerable<long?> values, long minValue, long maxValue)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.VAR_INTS.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.VAR_INTS.ToString(CultureInfo.InvariantCulture));
 
             CodecUtil.WriteHeader(output, Lucene40DocValuesFormat.VAR_INTS_CODEC_NAME, Lucene40DocValuesFormat.VAR_INTS_VERSION_CURRENT);
 
@@ -211,8 +212,8 @@ namespace Lucene.Net.Codecs.Lucene40
                 bool success = false;
                 IndexOutput data = null;
                 IndexOutput index = null;
-                string dataName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "dat");
-                string indexName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "idx");
+                string dataName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "dat");
+                string indexName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "idx");
                 try
                 {
                     data = Dir.CreateOutput(dataName, State.Context);
@@ -245,7 +246,7 @@ namespace Lucene.Net.Codecs.Lucene40
                 if (@fixed)
                 {
                     // fixed byte[]
-                    string fileName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "dat");
+                    string fileName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "dat");
                     IndexOutput data = Dir.CreateOutput(fileName, State.Context);
                     bool success = false;
                     try
@@ -271,8 +272,8 @@ namespace Lucene.Net.Codecs.Lucene40
                     bool success = false;
                     IndexOutput data = null;
                     IndexOutput index = null;
-                    string dataName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "dat");
-                    string indexName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "idx");
+                    string dataName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "dat");
+                    string indexName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "idx");
                     try
                     {
                         data = Dir.CreateOutput(dataName, State.Context);
@@ -297,7 +298,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddFixedStraightBytesField(FieldInfo field, IndexOutput output, IEnumerable<BytesRef> values, int length)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_FIXED_STRAIGHT.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_FIXED_STRAIGHT.ToString(CultureInfo.InvariantCulture));
 
             CodecUtil.WriteHeader(output, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_CODEC_NAME, Lucene40DocValuesFormat.BYTES_FIXED_STRAIGHT_VERSION_CURRENT);
 
@@ -314,7 +315,7 @@ namespace Lucene.Net.Codecs.Lucene40
         // NOTE: 4.0 file format docs are crazy/wrong here...
         private void AddVarStraightBytesField(FieldInfo field, IndexOutput data, IndexOutput index, IEnumerable<BytesRef> values)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_VAR_STRAIGHT.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_VAR_STRAIGHT.ToString(CultureInfo.InvariantCulture));
 
             CodecUtil.WriteHeader(data, Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_CODEC_NAME_DAT, Lucene40DocValuesFormat.BYTES_VAR_STRAIGHT_VERSION_CURRENT);
 
@@ -358,7 +359,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddFixedDerefBytesField(FieldInfo field, IndexOutput data, IndexOutput index, IEnumerable<BytesRef> values, int length)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_FIXED_DEREF.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_FIXED_DEREF.ToString(CultureInfo.InvariantCulture));
 
             CodecUtil.WriteHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_DEREF_CODEC_NAME_DAT, Lucene40DocValuesFormat.BYTES_FIXED_DEREF_VERSION_CURRENT);
 
@@ -403,7 +404,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddVarDerefBytesField(FieldInfo field, IndexOutput data, IndexOutput index, IEnumerable<BytesRef> values)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_VAR_DEREF.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_VAR_DEREF.ToString(CultureInfo.InvariantCulture));
 
             CodecUtil.WriteHeader(data, Lucene40DocValuesFormat.BYTES_VAR_DEREF_CODEC_NAME_DAT, Lucene40DocValuesFormat.BYTES_VAR_DEREF_VERSION_CURRENT);
 
@@ -481,8 +482,8 @@ namespace Lucene.Net.Codecs.Lucene40
             bool success = false;
             IndexOutput data = null;
             IndexOutput index = null;
-            string dataName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "dat");
-            string indexName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number), SegmentSuffix, "idx");
+            string dataName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "dat");
+            string indexName = IndexFileNames.SegmentFileName(State.SegmentInfo.Name + "_" + Convert.ToString(field.Number, CultureInfo.InvariantCulture), SegmentSuffix, "idx");
 
             try
             {
@@ -530,7 +531,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddFixedSortedBytesField(FieldInfo field, IndexOutput data, IndexOutput index, IEnumerable<BytesRef> values, IEnumerable<long?> docToOrd, int length)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_FIXED_SORTED.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_FIXED_SORTED.ToString(CultureInfo.InvariantCulture));
 
             CodecUtil.WriteHeader(data, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_CODEC_NAME_DAT, Lucene40DocValuesFormat.BYTES_FIXED_SORTED_VERSION_CURRENT);
 
@@ -561,7 +562,7 @@ namespace Lucene.Net.Codecs.Lucene40
 
         private void AddVarSortedBytesField(FieldInfo field, IndexOutput data, IndexOutput index, IEnumerable<BytesRef> values, IEnumerable<long?> docToOrd)
         {
-            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_VAR_SORTED.ToString());
+            field.PutAttribute(LegacyKey, LegacyDocValuesType.BYTES_VAR_SORTED.ToString(CultureInfo.InvariantCulture));
 
             CodecUtil.WriteHeader(data, Lucene40DocValuesFormat.BYTES_VAR_SORTED_CODEC_NAME_DAT, Lucene40DocValuesFormat.BYTES_VAR_SORTED_VERSION_CURRENT);
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
index 9c29f39..d755e63 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
@@ -3,6 +3,7 @@ using Lucene.Net.Randomized.Generators;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Globalization;
 using System.Threading;
 using Lucene.Net.Search;
 
@@ -1359,9 +1360,9 @@ namespace Lucene.Net.Index
             Debug.Assert(numDocs > 256);
             for (int i = 0; i < numDocs; i++)
             {
-                idField.SetStringValue(Convert.ToString(i));
+                idField.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 long value = longs.Next();
-                storedField.SetStringValue(Convert.ToString(value));
+                storedField.SetStringValue(Convert.ToString(value, CultureInfo.InvariantCulture));
                 dvField.SetInt64Value(value);
                 writer.AddDocument(doc);
                 if (Random().Next(31) == 0)
@@ -1375,7 +1376,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
 
             // merge some segments and ensure that at least one of them has more than
@@ -1392,7 +1393,7 @@ namespace Lucene.Net.Index
                 NumericDocValues docValues = r.GetNumericDocValues("dv");
                 for (int i = 0; i < r.MaxDoc; i++)
                 {
-                    long storedValue = Convert.ToInt64(r.Document(i).Get("stored"));
+                    long storedValue = Convert.ToInt64(r.Document(i).Get("stored"), CultureInfo.InvariantCulture);
                     Assert.AreEqual(storedValue, docValues.Get(i));
                 }
             }
@@ -1442,9 +1443,9 @@ namespace Lucene.Net.Index
             Debug.Assert(numDocs > 256);
             for (int i = 0; i < numDocs; i++)
             {
-                idField.SetStringValue(Convert.ToString(i));
+                idField.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 long value = longs.Next();
-                indexedField.SetStringValue(Convert.ToString(value));
+                indexedField.SetStringValue(Convert.ToString(value, CultureInfo.InvariantCulture));
                 dvField.SetInt64Value(value);
                 Document doc = new Document();
                 doc.Add(idField);
@@ -1466,7 +1467,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
 
             // merge some segments and ensure that at least one of them has more than
@@ -1595,7 +1596,7 @@ namespace Lucene.Net.Index
             int numDocs = AtLeast(300);
             for (int i = 0; i < numDocs; i++)
             {
-                idField.SetStringValue(Convert.ToString(i));
+                idField.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 int length;
                 if (minLength == maxLength)
                 {
@@ -1621,7 +1622,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
             writer.Dispose();
 
@@ -1681,7 +1682,7 @@ namespace Lucene.Net.Index
             int numDocs = AtLeast(300);
             for (int i = 0; i < numDocs; i++)
             {
-                idField.SetStringValue(Convert.ToString(i));
+                idField.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 int length;
                 if (minLength == maxLength)
                 {
@@ -1707,7 +1708,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
             writer.Dispose();
 
@@ -1746,7 +1747,7 @@ namespace Lucene.Net.Index
             int numDocs = AtLeast(300);
             for (int i = 0; i < numDocs; i++)
             {
-                idField.SetStringValue(Convert.ToString(i));
+                idField.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 int length;
                 if (minLength == maxLength)
                 {
@@ -1771,7 +1772,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
             writer.Dispose();
 
@@ -2313,7 +2314,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDocs; i++)
             {
                 Document doc = new Document();
-                Field idField = new StringField("id", Convert.ToString(i), Field.Store.NO);
+                Field idField = new StringField("id", Convert.ToString(i, CultureInfo.InvariantCulture), Field.Store.NO);
                 doc.Add(idField);
                 int length;
                 if (minLength == maxLength)
@@ -2360,7 +2361,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
             writer.Dispose();
 
@@ -2575,7 +2576,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDocs; i++)
             {
                 Document doc = new Document();
-                Field idField = new StringField("id", Convert.ToString(i), Field.Store.NO);
+                Field idField = new StringField("id", Convert.ToString(i, CultureInfo.InvariantCulture), Field.Store.NO);
                 doc.Add(idField);
                 int length;
                 if (minLength == maxLength)
@@ -2622,7 +2623,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
 
             // compare per-segment
@@ -3062,7 +3063,7 @@ namespace Lucene.Net.Index
                 Document doc = ar.Document(docID);
                 BytesRef bytes = new BytesRef();
                 s.Get(docID, bytes);
-                var expected = docBytes[Convert.ToInt32(doc.Get("id"))];
+                var expected = docBytes[Convert.ToInt32(doc.Get("id"), CultureInfo.InvariantCulture)];
                 Assert.AreEqual(expected.Length, bytes.Length);
                 Assert.AreEqual(new BytesRef(expected), bytes);
             }
@@ -3147,7 +3148,7 @@ namespace Lucene.Net.Index
                 Document doc = ar.Document(docID);
                 BytesRef bytes = new BytesRef();
                 s.Get(docID, bytes);
-                var expected = docBytes[Convert.ToInt32(doc.Get("id"))];
+                var expected = docBytes[Convert.ToInt32(doc.Get("id"), CultureInfo.InvariantCulture)];
                 Assert.AreEqual(expected.Length, bytes.Length);
                 Assert.AreEqual(new BytesRef(expected), bytes);
             }
@@ -3183,7 +3184,7 @@ namespace Lucene.Net.Index
             int numDocs = AtLeast(300);
             for (int i = 0; i < numDocs; i++)
             {
-                idField.SetStringValue(Convert.ToString(i));
+                idField.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 int length = TestUtil.NextInt(Random(), 0, 8);
                 var buffer = new byte[length];
                 Random().NextBytes(buffer);
@@ -3191,7 +3192,7 @@ namespace Lucene.Net.Index
                 dvBinField.SetBytesValue(buffer);
                 dvSortedField.SetBytesValue(buffer);
                 long numericValue = Random().NextLong();
-                storedNumericField.SetStringValue(Convert.ToString(numericValue));
+                storedNumericField.SetStringValue(Convert.ToString(numericValue, CultureInfo.InvariantCulture));
                 dvNumericField.SetInt64Value(numericValue);
                 writer.AddDocument(doc);
                 if (Random().Next(31) == 0)
@@ -3205,7 +3206,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
             writer.Dispose();
 
@@ -3263,7 +3264,7 @@ namespace Lucene.Net.Index
                             sorted.Get(j, scratch);
                             Assert.AreEqual(binaryValue, scratch);
                             string expected = r.Document(j).Get("storedNum");
-                            Assert.AreEqual(Convert.ToInt64(expected), numerics.Get(j));
+                            Assert.AreEqual(Convert.ToInt64(expected, CultureInfo.InvariantCulture), numerics.Get(j));
                         }
                     }
                     TestUtil.CheckReader(Ir);
@@ -3297,7 +3298,7 @@ namespace Lucene.Net.Index
             int numDocs = AtLeast(300);
             for (int i = 0; i < numDocs; i++)
             {
-                idField.SetStringValue(Convert.ToString(i));
+                idField.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 int length = TestUtil.NextInt(Random(), 0, 8);
                 var buffer = new byte[length];
                 Random().NextBytes(buffer);
@@ -3305,7 +3306,7 @@ namespace Lucene.Net.Index
                 dvBinField.SetBytesValue(buffer);
                 dvSortedField.SetBytesValue(buffer);
                 long numericValue = Random().NextLong();
-                storedNumericField.SetStringValue(Convert.ToString(numericValue));
+                storedNumericField.SetStringValue(Convert.ToString(numericValue, CultureInfo.InvariantCulture));
                 dvNumericField.SetInt64Value(numericValue);
                 Document doc = new Document();
                 doc.Add(idField);
@@ -3345,7 +3346,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDeletions; i++)
             {
                 int id = Random().Next(numDocs);
-                writer.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                writer.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
             writer.Dispose();
 
@@ -3427,7 +3428,7 @@ namespace Lucene.Net.Index
                             {
                                 if (numerics != null)
                                 {
-                                    Assert.AreEqual(Convert.ToInt64(number), numerics.Get(j));
+                                    Assert.AreEqual(Convert.ToInt64(number, CultureInfo.InvariantCulture), numerics.Get(j));
                                 }
                             }
                             else if (numerics != null)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
index 7e8912b..0fd043d 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
@@ -9,6 +9,7 @@ using Lucene.Net.Util;
 using NUnit.Framework;
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.Linq;
 using System.Text;
 using System.Threading;
@@ -284,7 +285,7 @@ namespace Lucene.Net.Index
                     if (Random().NextBoolean())
                     {
                         float f = Random().NextFloat();
-                        answer = Convert.ToSingle(f);
+                        answer = Convert.ToSingle(f, CultureInfo.InvariantCulture);
                         nf = new SingleField("nf", f, Field.Store.NO);
                         sf = new StoredField("nf", f);
                         typeAnswer = NumericType.SINGLE;
@@ -292,7 +293,7 @@ namespace Lucene.Net.Index
                     else
                     {
                         double d = Random().NextDouble();
-                        answer = Convert.ToDouble(d);
+                        answer = Convert.ToDouble(d, CultureInfo.InvariantCulture);
                         nf = new DoubleField("nf", d, Field.Store.NO);
                         sf = new StoredField("nf", d);
                         typeAnswer = NumericType.DOUBLE;
@@ -304,7 +305,7 @@ namespace Lucene.Net.Index
                     if (Random().NextBoolean())
                     {
                         int i = Random().Next();
-                        answer = Convert.ToInt32(i);
+                        answer = Convert.ToInt32(i, CultureInfo.InvariantCulture);
                         nf = new Int32Field("nf", i, Field.Store.NO);
                         sf = new StoredField("nf", i);
                         typeAnswer = NumericType.INT32;
@@ -312,7 +313,7 @@ namespace Lucene.Net.Index
                     else
                     {
                         long l = Random().NextLong();
-                        answer = Convert.ToInt64(l);
+                        answer = Convert.ToInt64(l, CultureInfo.InvariantCulture);
                         nf = new Int64Field("nf", l, Field.Store.NO);
                         sf = new StoredField("nf", l);
                         typeAnswer = NumericType.INT64;
@@ -543,7 +544,7 @@ namespace Lucene.Net.Index
                         {
                             throw new InvalidOperationException("Could not find document " + q);
                         }
-                        if (!Convert.ToString(q).Equals(sdoc.Get("fld"), StringComparison.Ordinal))
+                        if (!Convert.ToString(q, CultureInfo.InvariantCulture).Equals(sdoc.Get("fld"), StringComparison.Ordinal))
                         {
                             throw new InvalidOperationException("Expected " + q + ", but got " + sdoc.Get("fld"));
                         }
@@ -758,7 +759,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < numDocs; ++i)
             {
                 Document doc = new Document();
-                doc.Add(new StringField("id", Convert.ToString(i), Field.Store.YES));
+                doc.Add(new StringField("id", Convert.ToString(i, CultureInfo.InvariantCulture), Field.Store.YES));
                 doc.Add(new StoredField("f", TestUtil.RandomSimpleString(Random())));
                 w.AddDocument(doc);
             }
@@ -766,7 +767,7 @@ namespace Lucene.Net.Index
             for (int i = 0; i < deleteCount; ++i)
             {
                 int id = Random().Next(numDocs);
-                w.DeleteDocuments(new Term("id", Convert.ToString(id)));
+                w.DeleteDocuments(new Term("id", Convert.ToString(id, CultureInfo.InvariantCulture)));
             }
             w.Commit();
             w.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Index/DocHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/DocHelper.cs b/src/Lucene.Net.TestFramework/Index/DocHelper.cs
index 4f2ad89..afdbb3b 100644
--- a/src/Lucene.Net.TestFramework/Index/DocHelper.cs
+++ b/src/Lucene.Net.TestFramework/Index/DocHelper.cs
@@ -3,6 +3,7 @@ using Lucene.Net.Support;
 using Lucene.Net.Util;
 using System;
 using System.Collections.Generic;
+using System.Globalization;
 using System.Text;
 
 namespace Lucene.Net.Index
@@ -190,7 +191,7 @@ namespace Lucene.Net.Index
             customType1.StoreTermVectorOffsets = true;
 
             Document doc = new Document();
-            doc.Add(new Field("id", Convert.ToString(n), customType1));
+            doc.Add(new Field("id", Convert.ToString(n, CultureInfo.InvariantCulture), customType1));
             doc.Add(new Field("indexname", indexName, customType1));
             sb.Append("a");
             sb.Append(n);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs b/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
index e23318c..44f4015 100644
--- a/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/ThreadedIndexingAndSearchingTestCase.cs
@@ -2,6 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Collections.Concurrent;
 using System.Diagnostics;
+using System.Globalization;
 using System.Linq;
 using System.Threading;
 using System.Threading.Tasks;
@@ -726,7 +727,7 @@ namespace Lucene.Net.Index
 
             // Verify: make sure all not-deleted docs are in fact
             // not deleted:
-            int endID = Convert.ToInt32(docs.NextDoc().Get("docid"));
+            int endID = Convert.ToInt32(docs.NextDoc().Get("docid"), CultureInfo.InvariantCulture);
             docs.Dispose();
 
             for (int id = 0; id < endID; id++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
index 1cea358..6d46436 100644
--- a/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/src/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -21,7 +21,7 @@
     <DebugType>full</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>bin\Debug\</OutputPath>
-    <DefineConstants>TRACE;DEBUG</DefineConstants>
+    <DefineConstants>TRACE;FEATURE_SERIALIZABLE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <Prefer32Bit>false</Prefer32Bit>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Search/CheckHits.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Search/CheckHits.cs b/src/Lucene.Net.TestFramework/Search/CheckHits.cs
index 4608e23..2e0a46e 100644
--- a/src/Lucene.Net.TestFramework/Search/CheckHits.cs
+++ b/src/Lucene.Net.TestFramework/Search/CheckHits.cs
@@ -62,13 +62,13 @@ namespace Lucene.Net.Search
             SortedSet<int?> ignore = new SortedSet<int?>();
             for (int i = 0; i < results.Length; i++)
             {
-                ignore.Add(Convert.ToInt32(results[i]));
+                ignore.Add(Convert.ToInt32(results[i], CultureInfo.InvariantCulture));
             }
 
             int maxDoc = searcher.IndexReader.MaxDoc;
             for (int doc = 0; doc < maxDoc; doc++)
             {
-                if (ignore.Contains(Convert.ToInt32(doc)))
+                if (ignore.Contains(Convert.ToInt32(doc, CultureInfo.InvariantCulture)))
                 {
                     continue;
                 }
@@ -105,7 +105,7 @@ namespace Lucene.Net.Search
             SortedSet<int?> correct = new SortedSet<int?>();
             for (int i = 0; i < results.Length; i++)
             {
-                correct.Add(Convert.ToInt32(results[i]));
+                correct.Add(Convert.ToInt32(results[i], CultureInfo.InvariantCulture));
             }
             SortedSet<int?> actual = new SortedSet<int?>();
             ICollector c = new SetCollector(actual);
@@ -143,7 +143,7 @@ namespace Lucene.Net.Search
 
             public virtual void Collect(int doc)
             {
-                Bag.Add(Convert.ToInt32(doc + @base));
+                Bag.Add(Convert.ToInt32(doc + @base, CultureInfo.InvariantCulture));
             }
 
             public virtual void SetNextReader(AtomicReaderContext context)
@@ -180,13 +180,13 @@ namespace Lucene.Net.Search
             SortedSet<int?> correct = new SortedSet<int?>();
             for (int i = 0; i < results.Length; i++)
             {
-                correct.Add(Convert.ToInt32(results[i]));
+                correct.Add(Convert.ToInt32(results[i], CultureInfo.InvariantCulture));
             }
 
             SortedSet<int?> actual = new SortedSet<int?>();
             for (int i = 0; i < hits.Length; i++)
             {
-                actual.Add(Convert.ToInt32(hits[i].Doc));
+                actual.Add(Convert.ToInt32(hits[i].Doc, CultureInfo.InvariantCulture));
             }
 
             Assert.AreEqual(correct, actual, query.ToString(defaultFieldName));
@@ -393,7 +393,7 @@ namespace Lucene.Net.Search
                             int k2 = descr.IndexOf(" ", k1);
                             try
                             {
-                                x = Convert.ToSingle(descr.Substring(k1, k2 - k1).Trim());
+                                x = Convert.ToSingle(descr.Substring(k1, k2 - k1).Trim(), CultureInfo.InvariantCulture);
                                 if (descr.Substring(k2).Trim().Equals("times others of:", StringComparison.Ordinal))
                                 {
                                     maxTimesOthers = true;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Search/SearchEquivalenceTestBase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Search/SearchEquivalenceTestBase.cs b/src/Lucene.Net.TestFramework/Search/SearchEquivalenceTestBase.cs
index 5b8dec1..c086c12 100644
--- a/src/Lucene.Net.TestFramework/Search/SearchEquivalenceTestBase.cs
+++ b/src/Lucene.Net.TestFramework/Search/SearchEquivalenceTestBase.cs
@@ -1,5 +1,6 @@
 using System;
 using System.Collections;
+using System.Globalization;
 using System.Text;
 using Lucene.Net.Documents;
 using Lucene.Net.Support;
@@ -82,7 +83,7 @@ namespace Lucene.Net.Search
             int numDocs = AtLeast(1000);
             for (int i = 0; i < numDocs; i++)
             {
-                id.SetStringValue(Convert.ToString(i));
+                id.SetStringValue(Convert.ToString(i, CultureInfo.InvariantCulture));
                 field.SetStringValue(RandomFieldContents());
                 iw.AddDocument(doc);
             }
@@ -91,7 +92,7 @@ namespace Lucene.Net.Search
             int numDeletes = numDocs / 20;
             for (int i = 0; i < numDeletes; i++)
             {
-                Term toDelete = new Term("id", Convert.ToString(random.Next(numDocs)));
+                Term toDelete = new Term("id", Convert.ToString(random.Next(numDocs), CultureInfo.InvariantCulture));
                 if (random.NextBoolean())
                 {
                     iw.DeleteDocuments(toDelete);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Util/LineFileDocs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/LineFileDocs.cs b/src/Lucene.Net.TestFramework/Util/LineFileDocs.cs
index 5020fe0..60b13c6 100644
--- a/src/Lucene.Net.TestFramework/Util/LineFileDocs.cs
+++ b/src/Lucene.Net.TestFramework/Util/LineFileDocs.cs
@@ -1,6 +1,7 @@
 using Lucene.Net.Documents;
 using Lucene.Net.Support;
 using System;
+using System.Globalization;
 using System.IO;
 using System.IO.Compression;
 using System.Text;
@@ -294,7 +295,7 @@ namespace Lucene.Net.Util
             }
             docState.TitleTokenized.SetStringValue(title);
             docState.Date.SetStringValue(line.Substring(1 + spot, spot2 - (1 + spot)));
-            docState.Id.SetStringValue(Convert.ToString(Id.GetAndIncrement()));
+            docState.Id.SetStringValue(Convert.ToString(Id.GetAndIncrement(), CultureInfo.InvariantCulture));
             return docState.Doc;
         }
     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/6f5b4046/src/Lucene.Net.TestFramework/Util/VirtualMethod.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/VirtualMethod.cs b/src/Lucene.Net.TestFramework/Util/VirtualMethod.cs
index 3cd0c04..1a3095b 100644
--- a/src/Lucene.Net.TestFramework/Util/VirtualMethod.cs
+++ b/src/Lucene.Net.TestFramework/Util/VirtualMethod.cs
@@ -1,7 +1,7 @@
 using Lucene.Net.Support;
 using System;
 using System.Collections.Generic;
-using System.Linq;
+using System.Globalization;
 using System.Reflection;
 
 namespace Lucene.Net.Util
@@ -106,7 +106,7 @@ namespace Lucene.Net.Util
             if (distance == default(int))
             {
                 // we have the slight chance that another thread may do the same, but who cares?
-                Cache.Put(subclazz, distance = Convert.ToInt32(ReflectImplementationDistance(subclazz)));
+                Cache.Put(subclazz, distance = Convert.ToInt32(ReflectImplementationDistance(subclazz), CultureInfo.InvariantCulture));
             }
             return (int)distance;
         }
@@ -161,7 +161,7 @@ namespace Lucene.Net.Util
         /// </ul> </returns>
         public static int CompareImplementationDistance(Type clazz, VirtualMethod m1, VirtualMethod m2)
         {
-            return Convert.ToInt32(m1.GetImplementationDistance(clazz)).CompareTo(m2.GetImplementationDistance(clazz));
+            return m1.GetImplementationDistance(clazz).CompareTo(m2.GetImplementationDistance(clazz));
         }
 
         private MethodInfo GetMethod(Type clazz, string methodName, BindingFlags bindingFlags, Type[] methodParameters)


Mime
View raw message