lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhers...@apache.org
Subject [1/5] lucenenet git commit: Getting rid of most sbyte usage in public API
Date Mon, 10 Nov 2014 15:25:23 GMT
Repository: lucenenet
Updated Branches:
  refs/heads/master a15933529 -> ee575336c


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/Test2BBinaryDocValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/Test2BBinaryDocValues.cs b/src/Lucene.Net.Tests/core/Index/Test2BBinaryDocValues.cs
index c634e78..a4267dc 100644
--- a/src/Lucene.Net.Tests/core/Index/Test2BBinaryDocValues.cs
+++ b/src/Lucene.Net.Tests/core/Index/Test2BBinaryDocValues.cs
@@ -54,17 +54,17 @@ namespace Lucene.Net.Index
            .SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH).SetRAMBufferSizeMB(256.0).SetMergeScheduler(new ConcurrentMergeScheduler()).SetMergePolicy(NewLogMergePolicy(false, 10)).SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE));
 
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[4];
+            var bytes = new byte[4];
             BytesRef data = new BytesRef(bytes);
             BinaryDocValuesField dvField = new BinaryDocValuesField("dv", data);
             doc.Add(dvField);
 
             for (int i = 0; i < int.MaxValue; i++)
             {
-                bytes[0] = (sbyte)(i >> 24);
-                bytes[1] = (sbyte)(i >> 16);
-                bytes[2] = (sbyte)(i >> 8);
-                bytes[3] = (sbyte)i;
+                bytes[0] = (byte)(i >> 24);
+                bytes[1] = (byte)(i >> 16);
+                bytes[2] = (byte)(i >> 8);
+                bytes[3] = (byte)i;
                 w.AddDocument(doc);
                 if (i % 100000 == 0)
                 {
@@ -88,10 +88,10 @@ namespace Lucene.Net.Index
                 BinaryDocValues dv = reader.GetBinaryDocValues("dv");
                 for (int i = 0; i < reader.MaxDoc; i++)
                 {
-                    bytes[0] = (sbyte)(expectedValue >> 24);
-                    bytes[1] = (sbyte)(expectedValue >> 16);
-                    bytes[2] = (sbyte)(expectedValue >> 8);
-                    bytes[3] = (sbyte)expectedValue;
+                    bytes[0] = (byte)(expectedValue >> 24);
+                    bytes[1] = (byte)(expectedValue >> 16);
+                    bytes[2] = (byte)(expectedValue >> 8);
+                    bytes[3] = (byte)expectedValue;
                     dv.Get(i, scratch);
                     Assert.AreEqual(data, scratch);
                     expectedValue++;
@@ -116,15 +116,15 @@ namespace Lucene.Net.Index
            .SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH).SetRAMBufferSizeMB(256.0).SetMergeScheduler(new ConcurrentMergeScheduler()).SetMergePolicy(NewLogMergePolicy(false, 10)).SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE));
 
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[4];
-            ByteArrayDataOutput encoder = new ByteArrayDataOutput((byte[])(Array)bytes);
+            var bytes = new byte[4];
+            ByteArrayDataOutput encoder = new ByteArrayDataOutput(bytes);
             BytesRef data = new BytesRef(bytes);
             BinaryDocValuesField dvField = new BinaryDocValuesField("dv", data);
             doc.Add(dvField);
 
             for (int i = 0; i < int.MaxValue; i++)
             {
-                encoder.Reset((byte[])(Array)bytes);
+                encoder.Reset(bytes);
                 encoder.WriteVInt(i % 65535); // 1, 2, or 3 bytes
                 data.Length = encoder.Position;
                 w.AddDocument(doc);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/Test2BSortedDocValues.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/Test2BSortedDocValues.cs b/src/Lucene.Net.Tests/core/Index/Test2BSortedDocValues.cs
index cf666ad..842c6e3 100644
--- a/src/Lucene.Net.Tests/core/Index/Test2BSortedDocValues.cs
+++ b/src/Lucene.Net.Tests/core/Index/Test2BSortedDocValues.cs
@@ -51,15 +51,15 @@ namespace Lucene.Net.Index
            .SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH).SetRAMBufferSizeMB(256.0).SetMergeScheduler(new ConcurrentMergeScheduler()).SetMergePolicy(NewLogMergePolicy(false, 10)).SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE));
 
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[2];
+            var bytes = new byte[2];
             BytesRef data = new BytesRef(bytes);
             SortedDocValuesField dvField = new SortedDocValuesField("dv", data);
             doc.Add(dvField);
 
             for (int i = 0; i < int.MaxValue; i++)
             {
-                bytes[0] = (sbyte)(i >> 8);
-                bytes[1] = (sbyte)i;
+                bytes[0] = (byte)(i >> 8);
+                bytes[1] = (byte)i;
                 w.AddDocument(doc);
                 if (i % 100000 == 0)
                 {
@@ -83,8 +83,8 @@ namespace Lucene.Net.Index
                 BinaryDocValues dv = reader.GetSortedDocValues("dv");
                 for (int i = 0; i < reader.MaxDoc; i++)
                 {
-                    bytes[0] = (sbyte)(expectedValue >> 8);
-                    bytes[1] = (sbyte)expectedValue;
+                    bytes[0] = (byte)(expectedValue >> 8);
+                    bytes[1] = (byte)expectedValue;
                     dv.Get(i, scratch);
                     Assert.AreEqual(data, scratch);
                     expectedValue++;
@@ -109,17 +109,17 @@ namespace Lucene.Net.Index
            .SetMaxBufferedDocs(IndexWriterConfig.DISABLE_AUTO_FLUSH).SetRAMBufferSizeMB(256.0).SetMergeScheduler(new ConcurrentMergeScheduler()).SetMergePolicy(NewLogMergePolicy(false, 10)).SetOpenMode(IndexWriterConfig.OpenMode_e.CREATE));
 
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[4];
+            var bytes = new byte[4];
             BytesRef data = new BytesRef(bytes);
             SortedDocValuesField dvField = new SortedDocValuesField("dv", data);
             doc.Add(dvField);
 
             for (int i = 0; i < int.MaxValue; i++)
             {
-                bytes[0] = (sbyte)(i >> 24);
-                bytes[1] = (sbyte)(i >> 16);
-                bytes[2] = (sbyte)(i >> 8);
-                bytes[3] = (sbyte)i;
+                bytes[0] = (byte)(i >> 24);
+                bytes[1] = (byte)(i >> 16);
+                bytes[2] = (byte)(i >> 8);
+                bytes[3] = (byte)i;
                 w.AddDocument(doc);
                 if (i % 100000 == 0)
                 {
@@ -143,10 +143,10 @@ namespace Lucene.Net.Index
                 BinaryDocValues dv = reader.GetSortedDocValues("dv");
                 for (int i = 0; i < reader.MaxDoc; i++)
                 {
-                    bytes[0] = (sbyte)(counter >> 24);
-                    bytes[1] = (sbyte)(counter >> 16);
-                    bytes[2] = (sbyte)(counter >> 8);
-                    bytes[3] = (sbyte)counter;
+                    bytes[0] = (byte)(counter >> 24);
+                    bytes[1] = (byte)(counter >> 16);
+                    bytes[2] = (byte)(counter >> 8);
+                    bytes[3] = (byte)counter;
                     counter++;
                     dv.Get(i, scratch);
                     Assert.AreEqual(data, scratch);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/Test2BTerms.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/Test2BTerms.cs b/src/Lucene.Net.Tests/core/Index/Test2BTerms.cs
index a36a885..aa53677 100644
--- a/src/Lucene.Net.Tests/core/Index/Test2BTerms.cs
+++ b/src/Lucene.Net.Tests/core/Index/Test2BTerms.cs
@@ -82,7 +82,7 @@ namespace Lucene.Net.Index
                 int shift = 32;
                 for (int i = 0; i < 5; i++)
                 {
-                    Bytes.Bytes[i] = unchecked((sbyte)((TermCounter >> shift) & 0xFF));
+                    Bytes.Bytes[i] = unchecked((byte)((TermCounter >> shift) & 0xFF));
                     shift -= 8;
                 }
                 TermCounter++;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/Test4GBStoredFields.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/Test4GBStoredFields.cs b/src/Lucene.Net.Tests/core/Index/Test4GBStoredFields.cs
index cf245ec..d1bbe3d 100644
--- a/src/Lucene.Net.Tests/core/Index/Test4GBStoredFields.cs
+++ b/src/Lucene.Net.Tests/core/Index/Test4GBStoredFields.cs
@@ -60,11 +60,11 @@ namespace Lucene.Net.Index
             ft.Stored = true;
             ft.Freeze();
             int valueLength = RandomInts.NextIntBetween(Random(), 1 << 13, 1 << 20);
-            sbyte[] value = new sbyte[valueLength];
+            var value = new byte[valueLength];
             for (int i = 0; i < valueLength; ++i)
             {
                 // random so that even compressing codecs can't compress it
-                value[i] = (sbyte)Random().Next(256);
+                value[i] = (byte)Random().Next(256);
             }
             Field f = new Field("fld", value, ft);
             doc.Add(f);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs b/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
index 9cc5f21..cd262d6 100644
--- a/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestBinaryDocValuesUpdates.cs
@@ -58,7 +58,7 @@ namespace Lucene.Net.Index
         {
             bdv.Get(idx, scratch);
             idx = scratch.Offset;
-            sbyte b = scratch.Bytes[idx++];
+            var b = scratch.Bytes[idx++];
             long value = b & 0x7FL;
             for (int shift = 7; (b & 0x80L) != 0; shift += 7)
             {
@@ -75,10 +75,10 @@ namespace Lucene.Net.Index
             BytesRef bytes = new BytesRef(10); // negative longs may take 10 bytes
             while ((value & ~0x7FL) != 0L)
             {
-                bytes.Bytes[bytes.Length++] = unchecked((sbyte)((value & 0x7FL) | 0x80L));
+                bytes.Bytes[bytes.Length++] = unchecked((byte)((value & 0x7FL) | 0x80L));
                 value = (long)((ulong)value >> 7);
             }
-            bytes.Bytes[bytes.Length++] = (sbyte)value;
+            bytes.Bytes[bytes.Length++] = (byte)value;
             //    System.err.println("[" + Thread.currentThread().getName() + "] value=" + orig + ", bytes=" + bytes);
             return bytes;
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestBinaryTerms.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestBinaryTerms.cs b/src/Lucene.Net.Tests/core/Index/TestBinaryTerms.cs
index e972b35..b00230f 100644
--- a/src/Lucene.Net.Tests/core/Index/TestBinaryTerms.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestBinaryTerms.cs
@@ -49,8 +49,8 @@ namespace Lucene.Net.Index
 
             for (int i = 0; i < 256; i++)
             {
-                bytes.Bytes[0] = (sbyte)i;
-                bytes.Bytes[1] = unchecked((sbyte)(255 - i));
+                bytes.Bytes[0] = (byte)i;
+                bytes.Bytes[1] = unchecked((byte)(255 - i));
                 bytes.Length = 2;
                 Document doc = new Document();
                 FieldType customType = new FieldType();
@@ -67,8 +67,8 @@ namespace Lucene.Net.Index
 
             for (int i = 0; i < 256; i++)
             {
-                bytes.Bytes[0] = (sbyte)i;
-                bytes.Bytes[1] = unchecked((sbyte)(255 - i));
+                bytes.Bytes[0] = (byte)i;
+                bytes.Bytes[1] = unchecked((byte)(255 - i));
                 bytes.Length = 2;
                 TopDocs docs = @is.Search(new TermQuery(new Term("bytes", bytes)), 5);
                 Assert.AreEqual(1, docs.TotalHits);
@@ -82,7 +82,7 @@ namespace Lucene.Net.Index
         [Test]
         public virtual void TestToString()
         {
-            Term term = new Term("foo", new BytesRef(new sbyte[] { unchecked((sbyte)0xff), unchecked((sbyte)0xfe) }));
+            Term term = new Term("foo", new BytesRef(new[] { unchecked((byte)0xff), unchecked((byte)0xfe) }));
             Assert.AreEqual("foo:[ff fe]", term.ToString());
         }
     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestCodecs.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestCodecs.cs b/src/Lucene.Net.Tests/core/Index/TestCodecs.cs
index c54c2d3..ca0113b 100644
--- a/src/Lucene.Net.Tests/core/Index/TestCodecs.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestCodecs.cs
@@ -352,10 +352,10 @@ namespace Lucene.Net.Index
                             BytesRef payload;
                             if (storePayloads && Random().Next(4) == 0)
                             {
-                                sbyte[] bytes = new sbyte[1 + Random().Next(5)];
+                                var bytes = new byte[1 + Random().Next(5)];
                                 for (int l = 0; l < bytes.Length; l++)
                                 {
-                                    bytes[l] = (sbyte)Random().Next(255);
+                                    bytes[l] = (byte)Random().Next(255);
                                 }
                                 payload = new BytesRef(bytes);
                             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestConsistentFieldNumbers.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestConsistentFieldNumbers.cs b/src/Lucene.Net.Tests/core/Index/TestConsistentFieldNumbers.cs
index 6027953..f91bda1 100644
--- a/src/Lucene.Net.Tests/core/Index/TestConsistentFieldNumbers.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestConsistentFieldNumbers.cs
@@ -179,7 +179,7 @@ namespace Lucene.Net.Index
                     IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(Random().NextBoolean() ? NoMergePolicy.NO_COMPOUND_FILES : NoMergePolicy.COMPOUND_FILES));
                     Document d = new Document();
                     d.Add(new TextField("f1", "d2 first field", Field.Store.YES));
-                    d.Add(new StoredField("f3", new sbyte[] { 1, 2, 3 }));
+                    d.Add(new StoredField("f3", new byte[] { 1, 2, 3 }));
                     writer.AddDocument(d);
                     writer.Dispose();
                     SegmentInfos sis = new SegmentInfos();
@@ -199,7 +199,7 @@ namespace Lucene.Net.Index
                     Document d = new Document();
                     d.Add(new TextField("f1", "d3 first field", Field.Store.YES));
                     d.Add(new TextField("f2", "d3 second field", Field.Store.YES));
-                    d.Add(new StoredField("f3", new sbyte[] { 1, 2, 3, 4, 5 }));
+                    d.Add(new StoredField("f3", new byte[] { 1, 2, 3, 4, 5 }));
                     writer.AddDocument(d);
                     writer.Dispose();
                     SegmentInfos sis = new SegmentInfos();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestDirectoryReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestDirectoryReader.cs b/src/Lucene.Net.Tests/core/Index/TestDirectoryReader.cs
index 88eb374..c94ce59 100644
--- a/src/Lucene.Net.Tests/core/Index/TestDirectoryReader.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestDirectoryReader.cs
@@ -365,7 +365,7 @@ namespace Lucene.Net.Index
         public virtual void TestBinaryFields()
         {
             Directory dir = NewDirectory();
-            sbyte[] bin = new sbyte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+            byte[] bin = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 
             IndexWriter writer = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())).SetMergePolicy(NewLogMergePolicy()));
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestDocValuesIndexing.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestDocValuesIndexing.cs b/src/Lucene.Net.Tests/core/Index/TestDocValuesIndexing.cs
index ea2ae46..a09265a 100644
--- a/src/Lucene.Net.Tests/core/Index/TestDocValuesIndexing.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestDocValuesIndexing.cs
@@ -195,7 +195,7 @@ namespace Lucene.Net.Index
             Directory d = NewDirectory();
             IndexWriter w = new IndexWriter(d, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[32764];
+            var bytes = new byte[32764];
             BytesRef b = new BytesRef();
             b.Bytes = bytes;
             b.Length = bytes.Length;
@@ -392,9 +392,9 @@ namespace Lucene.Net.Index
             iwc.SetMergePolicy(NewLogMergePolicy());
             IndexWriter iwriter = new IndexWriter(directory, iwc);
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[100000];
+            var bytes = new byte[100000];
             BytesRef b = new BytesRef(bytes);
-            Random().NextBytes((byte[])(Array)bytes);
+            Random().NextBytes(bytes);
             doc.Add(new SortedDocValuesField("dv", b));
             try
             {
@@ -421,7 +421,7 @@ namespace Lucene.Net.Index
             iwc.SetMergePolicy(NewLogMergePolicy());
             IndexWriter iwriter = new IndexWriter(directory, iwc);
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[100000];
+            byte[] bytes = new byte[100000];
             BytesRef b = new BytesRef(bytes);
             Random().NextBytes((byte[])(Array)bytes);
             doc.Add(new SortedSetDocValuesField("dv", b));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestDocumentWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestDocumentWriter.cs b/src/Lucene.Net.Tests/core/Index/TestDocumentWriter.cs
index 997f4ff..0c6d6fb 100644
--- a/src/Lucene.Net.Tests/core/Index/TestDocumentWriter.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestDocumentWriter.cs
@@ -242,7 +242,7 @@ namespace Lucene.Net.Index
                     if (first)
                     {
                         // set payload on first position only
-                        payloadAtt.Payload = new BytesRef(new sbyte[] { 100 });
+                        payloadAtt.Payload = new BytesRef(new byte[] { 100 });
                         first = false;
                     }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
index 8631da7..587292e 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriter.cs
@@ -1464,10 +1464,10 @@ namespace Lucene.Net.Index
         {
             Directory dir = NewDirectory();
             IndexWriter w = new IndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random())));
-            sbyte[] b = new sbyte[50];
+            var b = new byte[50];
             for (int i = 0; i < 50; i++)
             {
-                b[i] = (sbyte)(i + 77);
+                b[i] = (byte)(i + 77);
             }
 
             Document doc = new Document();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
index 6fc21f6..97048c8 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterExceptions.cs
@@ -1925,7 +1925,7 @@ namespace Lucene.Net.Index
             t1.PositionIncrement = int.MaxValue - 500;
             if (Random().NextBoolean())
             {
-                t1.Payload = new BytesRef(new sbyte[] { 0x1 });
+                t1.Payload = new BytesRef(new byte[] { 0x1 });
             }
             TokenStream overflowingTokenStream = new CannedTokenStream(new Token[] { t1 });
             Field field = new TextField("foo", overflowingTokenStream);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestIndexWriterUnicode.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexWriterUnicode.cs b/src/Lucene.Net.Tests/core/Index/TestIndexWriterUnicode.cs
index 3120efd..5263810 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexWriterUnicode.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexWriterUnicode.cs
@@ -202,7 +202,7 @@ namespace Lucene.Net.Index
                 UnicodeUtil.UTF16toUTF8(buffer, 0, 20, utf8);
                 if (!hasIllegal)
                 {
-                    sbyte[] b = (new string(buffer, 0, 20)).GetBytes(IOUtils.CHARSET_UTF_8);
+                    var b = (new string(buffer, 0, 20)).GetBytes(IOUtils.CHARSET_UTF_8);
                     Assert.AreEqual(b.Length, utf8.Length);
                     for (int i = 0; i < b.Length; i++)
                     {
@@ -254,7 +254,7 @@ namespace Lucene.Net.Index
                 UnicodeUtil.UTF8toUTF16(utf8.Bytes, 0, utf8.Length, utf16);
                 Assert.AreEqual(s1, new string(utf16.Chars, 0, utf16.Length), "codepoint " + ch);
 
-                sbyte[] b = s1.GetBytes(Encoding.UTF8);
+                var b = s1.GetBytes(Encoding.UTF8);
                 Assert.AreEqual(utf8.Length, b.Length);
                 for (int j = 0; j < utf8.Length; j++)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs b/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
index 48898b7..5d49c99 100644
--- a/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestIndexableField.cs
@@ -166,10 +166,10 @@ namespace Lucene.Net.Index
             {
                 if ((Counter % 10) == 3)
                 {
-                    sbyte[] bytes = new sbyte[10];
+                    var bytes = new byte[10];
                     for (int idx = 0; idx < bytes.Length; idx++)
                     {
-                        bytes[idx] = (sbyte)(Counter + idx);
+                        bytes[idx] = (byte)(Counter + idx);
                     }
                     return new BytesRef(bytes, 0, bytes.Length);
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestMultiLevelSkipList.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestMultiLevelSkipList.cs b/src/Lucene.Net.Tests/core/Index/TestMultiLevelSkipList.cs
index aa94dc8..83f7490 100644
--- a/src/Lucene.Net.Tests/core/Index/TestMultiLevelSkipList.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestMultiLevelSkipList.cs
@@ -151,7 +151,7 @@ namespace Lucene.Net.Index
                 bool hasNext = input.IncrementToken();
                 if (hasNext)
                 {
-                    PayloadAtt.Payload = new BytesRef(new sbyte[] { (sbyte)PayloadCount.IncrementAndGet() });
+                    PayloadAtt.Payload = new BytesRef(new[] { (byte)PayloadCount.IncrementAndGet() });
                 }
                 return hasNext;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Index/TestPayloads.cs b/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
index dde563c..02b57bf 100644
--- a/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
+++ b/src/Lucene.Net.Tests/core/Index/TestPayloads.cs
@@ -153,7 +153,7 @@ namespace Lucene.Net.Index
             string content = sb.ToString();
 
             int payloadDataLength = numTerms * numDocs * 2 + numTerms * numDocs * (numDocs - 1) / 2;
-            sbyte[] payloadData = GenerateRandomData(payloadDataLength);
+            var payloadData = GenerateRandomData(payloadDataLength);
 
             Document d = new Document();
             d.Add(NewTextField(fieldName, content, Field.Store.NO));
@@ -188,7 +188,7 @@ namespace Lucene.Net.Index
              */
             IndexReader reader = DirectoryReader.Open(dir);
 
-            sbyte[] verifyPayloadData = new sbyte[payloadDataLength];
+            var verifyPayloadData = new byte[payloadDataLength];
             offset = 0;
             DocsAndPositionsEnum[] tps = new DocsAndPositionsEnum[numTerms];
             for (int i = 0; i < numTerms; i++)
@@ -286,8 +286,8 @@ namespace Lucene.Net.Index
             tp.NextPosition();
 
             BytesRef bref = tp.Payload;
-            verifyPayloadData = new sbyte[bref.Length];
-            sbyte[] portion = new sbyte[1500];
+            verifyPayloadData = new byte[bref.Length];
+            var portion = new byte[1500];
             Array.Copy(payloadData, 100, portion, 0, 1500);
 
             AssertByteArrayEquals(portion, bref.Bytes, bref.Offset, bref.Length);
@@ -296,18 +296,18 @@ namespace Lucene.Net.Index
 
         internal static readonly Encoding Utf8 = IOUtils.CHARSET_UTF_8;
 
-        private void GenerateRandomData(sbyte[] data)
+        private void GenerateRandomData(byte[] data)
         {
             // this test needs the random data to be valid unicode
             string s = TestUtil.RandomFixedByteLengthUnicodeString(Random(), data.Length);
-            sbyte[] b = s.GetBytes(Utf8);
+            var b = s.GetBytes(Utf8);
             Debug.Assert(b.Length == data.Length);
             System.Buffer.BlockCopy(b, 0, data, 0, b.Length);
         }
 
-        private sbyte[] GenerateRandomData(int n)
+        private byte[] GenerateRandomData(int n)
         {
-            sbyte[] data = new sbyte[n];
+            var data = new byte[n];
             GenerateRandomData(data);
             return data;
         }
@@ -332,7 +332,7 @@ namespace Lucene.Net.Index
             return terms;
         }
 
-        internal virtual void AssertByteArrayEquals(sbyte[] b1, sbyte[] b2)
+        internal virtual void AssertByteArrayEquals(byte[] b1, byte[] b2)
         {
             if (b1.Length != b2.Length)
             {
@@ -348,7 +348,7 @@ namespace Lucene.Net.Index
             }
         }
 
-        internal virtual void AssertByteArrayEquals(sbyte[] b1, sbyte[] b2, int b2offset, int b2length)
+        internal virtual void AssertByteArrayEquals(byte[] b1, byte[] b2, int b2offset, int b2length)
         {
             if (b1.Length != b2length)
             {
@@ -369,20 +369,20 @@ namespace Lucene.Net.Index
         /// </summary>
         private class PayloadAnalyzer : Analyzer
         {
-            internal IDictionary<string, PayloadData> FieldToData = new Dictionary<string, PayloadData>();
+            internal readonly IDictionary<string, PayloadData> FieldToData = new Dictionary<string, PayloadData>();
 
             public PayloadAnalyzer()
                 : base(PER_FIELD_REUSE_STRATEGY)
             {
             }
 
-            public PayloadAnalyzer(string field, sbyte[] data, int offset, int length)
+            public PayloadAnalyzer(string field, byte[] data, int offset, int length)
                 : base(PER_FIELD_REUSE_STRATEGY)
             {
                 SetPayloadData(field, data, offset, length);
             }
 
-            internal virtual void SetPayloadData(string field, sbyte[] data, int offset, int length)
+            internal virtual void SetPayloadData(string field, byte[] data, int offset, int length)
             {
                 FieldToData[field] = new PayloadData(data, offset, length);
             }
@@ -398,11 +398,11 @@ namespace Lucene.Net.Index
 
             internal class PayloadData
             {
-                internal sbyte[] Data;
+                internal byte[] Data;
                 internal int Offset;
                 internal int Length;
 
-                internal PayloadData(sbyte[] data, int offset, int length)
+                internal PayloadData(byte[] data, int offset, int length)
                 {
                     this.Data = data;
                     this.Offset = offset;
@@ -416,14 +416,14 @@ namespace Lucene.Net.Index
         /// </summary>
         private class PayloadFilter : TokenFilter
         {
-            internal sbyte[] Data;
+            internal byte[] Data;
             internal int Length;
             internal int Offset;
             internal int StartOffset;
             internal IPayloadAttribute PayloadAtt;
             internal ICharTermAttribute TermAttribute;
 
-            public PayloadFilter(TokenStream @in, sbyte[] data, int offset, int length)
+            public PayloadFilter(TokenStream @in, byte[] data, int offset, int length)
                 : base(@in)
             {
                 this.Data = data;
@@ -553,7 +553,7 @@ namespace Lucene.Net.Index
         {
             private readonly TestPayloads OuterInstance;
 
-            internal sbyte[] Payload;
+            private byte[] Payload;
             internal bool First;
             internal ByteArrayPool Pool;
             internal string Term;
@@ -594,28 +594,28 @@ namespace Lucene.Net.Index
 
         private class ByteArrayPool
         {
-            internal IList<sbyte[]> Pool;
+            internal readonly IList<byte[]> Pool;
 
             internal ByteArrayPool(int capacity, int size)
             {
-                Pool = new List<sbyte[]>();
+                Pool = new List<byte[]>();
                 for (int i = 0; i < capacity; i++)
                 {
-                    Pool.Add(new sbyte[size]);
+                    Pool.Add(new byte[size]);
                 }
             }
 
-            internal virtual sbyte[] Get()
+            internal virtual byte[] Get()
             {
-                lock (this)
+                lock (this) // TODO use BlockingCollection / BCL datastructures instead
                 {
-                    sbyte[] retArray = Pool[0];
+                    var retArray = Pool[0];
                     Pool.RemoveAt(0);
                     return retArray;
                 }
             }
 
-            internal virtual void Release(sbyte[] b)
+            internal virtual void Release(byte[] b)
             {
                 lock (this)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/Payloads/PayloadHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/Payloads/PayloadHelper.cs b/src/Lucene.Net.Tests/core/Search/Payloads/PayloadHelper.cs
index 71ea1e1..b9d3543 100644
--- a/src/Lucene.Net.Tests/core/Search/Payloads/PayloadHelper.cs
+++ b/src/Lucene.Net.Tests/core/Search/Payloads/PayloadHelper.cs
@@ -44,9 +44,9 @@ namespace Lucene.Net.Search.Payloads
     ///
     public class PayloadHelper
     {
-        private sbyte[] PayloadField = new sbyte[] { 1 };
-        private sbyte[] PayloadMultiField1 = new sbyte[] { 2 };
-        private sbyte[] PayloadMultiField2 = new sbyte[] { 4 };
+        private byte[] PayloadField = new byte[] { 1 };
+        private byte[] PayloadMultiField1 = new byte[] { 2 };
+        private byte[] PayloadMultiField2 = new byte[] { 4 };
         public const string NO_PAYLOAD_FIELD = "noPayloadField";
         public const string MULTI_FIELD = "multiField";
         public const string FIELD = "field";

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadNearQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadNearQuery.cs b/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadNearQuery.cs
index 82ef6d1..7ac3334 100644
--- a/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadNearQuery.cs
+++ b/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadNearQuery.cs
@@ -46,8 +46,8 @@ namespace Lucene.Net.Search.Payloads
         private static IndexReader Reader;
         private static Directory Directory;
         private static BoostingSimilarity Similarity = new BoostingSimilarity();
-        private static sbyte[] Payload2 = new sbyte[] { 2 };
-        private static sbyte[] Payload4 = new sbyte[] { 4 };
+        private static byte[] Payload2 = { 2 };
+        private static byte[] Payload4 = { 4 };
 
         private class PayloadAnalyzer : Analyzer
         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadTermQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadTermQuery.cs b/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadTermQuery.cs
index 8f49550..0076c67 100644
--- a/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadTermQuery.cs
+++ b/src/Lucene.Net.Tests/core/Search/Payloads/TestPayloadTermQuery.cs
@@ -45,10 +45,10 @@ namespace Lucene.Net.Search.Payloads
     {
         private static IndexSearcher Searcher;
         private static IndexReader Reader;
-        private static Similarity Similarity = new BoostingSimilarity();
-        private static readonly sbyte[] PayloadField = new sbyte[] { 1 };
-        private static readonly sbyte[] PayloadMultiField1 = new sbyte[] { 2 };
-        private static readonly sbyte[] PayloadMultiField2 = new sbyte[] { 4 };
+        private static readonly Similarity Similarity = new BoostingSimilarity();
+        private static readonly byte[] PayloadField = { 1 };
+        private static readonly byte[] PayloadMultiField1 = { 2 };
+        private static readonly byte[] PayloadMultiField2 = { 4 };
         protected internal static Directory Directory;
 
         private class PayloadAnalyzer : Analyzer

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/Spans/JustCompileSearchSpans.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/Spans/JustCompileSearchSpans.cs b/src/Lucene.Net.Tests/core/Search/Spans/JustCompileSearchSpans.cs
index 55e4412..9cc35e7 100644
--- a/src/Lucene.Net.Tests/core/Search/Spans/JustCompileSearchSpans.cs
+++ b/src/Lucene.Net.Tests/core/Search/Spans/JustCompileSearchSpans.cs
@@ -63,7 +63,7 @@ namespace Lucene.Net.Search.Spans
                 throw new System.NotSupportedException(UNSUPPORTED_MSG);
             }
 
-            public override ICollection<sbyte[]> Payload
+            public override ICollection<byte[]> Payload
             {
                 get
                 {
@@ -108,7 +108,7 @@ namespace Lucene.Net.Search.Spans
 
         internal sealed class JustCompilePayloadSpans : Spans
         {
-            public override ICollection<sbyte[]> Payload
+            public override ICollection<byte[]> Payload
             {
                 get
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/Spans/MultiSpansWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/Spans/MultiSpansWrapper.cs b/src/Lucene.Net.Tests/core/Search/Spans/MultiSpansWrapper.cs
index ad0f3e5..7c47ab2 100644
--- a/src/Lucene.Net.Tests/core/Search/Spans/MultiSpansWrapper.cs
+++ b/src/Lucene.Net.Tests/core/Search/Spans/MultiSpansWrapper.cs
@@ -37,11 +37,11 @@ namespace Lucene.Net.Search.Spans
     /// </summary>
     public class MultiSpansWrapper : Spans // can't be package private due to payloads
     {
-        private SpanQuery Query;
-        private IList<AtomicReaderContext> Leaves;
+        private readonly SpanQuery Query;
+        private readonly IList<AtomicReaderContext> Leaves;
         private int LeafOrd = 0;
         private Spans Current;
-        private IDictionary<Term, TermContext> TermContexts;
+        private readonly IDictionary<Term, TermContext> TermContexts;
         private readonly int NumLeaves;
 
         private MultiSpansWrapper(IList<AtomicReaderContext> leaves, SpanQuery query, IDictionary<Term, TermContext> termContexts)
@@ -177,13 +177,13 @@ namespace Lucene.Net.Search.Spans
             return Current.End();
         }
 
-        public override ICollection<sbyte[]> Payload
+        public override ICollection<byte[]> Payload
         {
             get
             {
                 if (Current == null)
                 {
-                    return new List<sbyte[]>();
+                    return new List<byte[]>();
                 }
                 return Current.Payload;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/Spans/TestBasics.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/Spans/TestBasics.cs b/src/Lucene.Net.Tests/core/Search/Spans/TestBasics.cs
index b013b58..0ccea8f 100644
--- a/src/Lucene.Net.Tests/core/Search/Spans/TestBasics.cs
+++ b/src/Lucene.Net.Tests/core/Search/Spans/TestBasics.cs
@@ -415,14 +415,14 @@ namespace Lucene.Net.Search.Spans
         {
             SpanTermQuery term1 = new SpanTermQuery(new Term("field", "five"));
             BytesRef pay = new BytesRef(("pos: " + 5).GetBytes(IOUtils.CHARSET_UTF_8));
-            SpanQuery query = new SpanPayloadCheckQuery(term1, new List<sbyte[]>() { pay.Bytes });
+            SpanQuery query = new SpanPayloadCheckQuery(term1, new List<byte[]>() { pay.Bytes });
             CheckHits(query, new int[] { 1125, 1135, 1145, 1155, 1165, 1175, 1185, 1195, 1225, 1235, 1245, 1255, 1265, 1275, 1285, 1295, 1325, 1335, 1345, 1355, 1365, 1375, 1385, 1395, 1425, 1435, 1445, 1455, 1465, 1475, 1485, 1495, 1525, 1535, 1545, 1555, 1565, 1575, 1585, 1595, 1625, 1635, 1645, 1655, 1665, 1675, 1685, 1695, 1725, 1735, 1745, 1755, 1765, 1775, 1785, 1795, 1825, 1835, 1845, 1855, 1865, 1875, 1885, 1895, 1925, 1935, 1945, 1955, 1965, 1975, 1985, 1995 });
             Assert.IsTrue(Searcher.Explain(query, 1125).Value > 0.0f);
 
             SpanTermQuery term2 = new SpanTermQuery(new Term("field", "hundred"));
             SpanNearQuery snq;
             SpanQuery[] clauses;
-            IList<sbyte[]> list;
+            IList<byte[]> list;
             BytesRef pay2;
             clauses = new SpanQuery[2];
             clauses[0] = term1;
@@ -430,7 +430,7 @@ namespace Lucene.Net.Search.Spans
             snq = new SpanNearQuery(clauses, 0, true);
             pay = new BytesRef(("pos: " + 0).GetBytes(IOUtils.CHARSET_UTF_8));
             pay2 = new BytesRef(("pos: " + 1).GetBytes(IOUtils.CHARSET_UTF_8));
-            list = new List<sbyte[]>();
+            list = new List<byte[]>();
             list.Add(pay.Bytes);
             list.Add(pay2.Bytes);
             query = new SpanNearPayloadCheckQuery(snq, list);
@@ -443,7 +443,7 @@ namespace Lucene.Net.Search.Spans
             pay = new BytesRef(("pos: " + 0).GetBytes(IOUtils.CHARSET_UTF_8));
             pay2 = new BytesRef(("pos: " + 1).GetBytes(IOUtils.CHARSET_UTF_8));
             BytesRef pay3 = new BytesRef(("pos: " + 2).GetBytes(IOUtils.CHARSET_UTF_8));
-            list = new List<sbyte[]>();
+            list = new List<byte[]>();
             list.Add(pay.Bytes);
             list.Add(pay2.Bytes);
             list.Add(pay3.Bytes);
@@ -471,7 +471,7 @@ namespace Lucene.Net.Search.Spans
             query = new SpanPositionRangeQuery(oneThousHunThree, 0, 6);
             CheckHits(query, new int[] { 1103, 1203, 1303, 1403, 1503, 1603, 1703, 1803, 1903 });
 
-            ICollection<sbyte[]> payloads = new List<sbyte[]>();
+            var payloads = new List<byte[]>();
             BytesRef pay = new BytesRef(("pos: " + 0).GetBytes(IOUtils.CHARSET_UTF_8));
             BytesRef pay2 = new BytesRef(("pos: " + 1).GetBytes(IOUtils.CHARSET_UTF_8));
             BytesRef pay3 = new BytesRef(("pos: " + 3).GetBytes(IOUtils.CHARSET_UTF_8));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/Spans/TestPayloadSpans.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/Spans/TestPayloadSpans.cs b/src/Lucene.Net.Tests/core/Search/Spans/TestPayloadSpans.cs
index 6017223..cdff08e 100644
--- a/src/Lucene.Net.Tests/core/Search/Spans/TestPayloadSpans.cs
+++ b/src/Lucene.Net.Tests/core/Search/Spans/TestPayloadSpans.cs
@@ -279,11 +279,10 @@ namespace Lucene.Net.Search.Spans
             {
                 while (spans.Next())
                 {
-                    ICollection<sbyte[]> payloads = spans.Payload;
-
-                    foreach (sbyte[] payload in payloads)
+                    var payloads = spans.Payload;
+                    foreach (var payload in payloads)
                     {
-                        payloadSet.Add(Encoding.UTF8.GetString((byte[])(Array)payload));
+                        payloadSet.Add(Encoding.UTF8.GetString(payload));
                     }
                 }
             }
@@ -309,7 +308,7 @@ namespace Lucene.Net.Search.Spans
 
             SpanTermQuery stq1 = new SpanTermQuery(new Term("content", "a"));
             SpanTermQuery stq2 = new SpanTermQuery(new Term("content", "k"));
-            SpanQuery[] sqs = new SpanQuery[] { stq1, stq2 };
+            SpanQuery[] sqs = { stq1, stq2 };
             SpanNearQuery snq = new SpanNearQuery(sqs, 0, true);
             Spans spans = MultiSpansWrapper.Wrap(@is.TopReaderContext, snq);
 
@@ -319,8 +318,8 @@ namespace Lucene.Net.Search.Spans
             {
                 while (spans.Next())
                 {
-                    ICollection<sbyte[]> payloads = spans.Payload;
-                    foreach (sbyte[] payload in payloads)
+                    var payloads = spans.Payload;
+                    foreach (var payload in payloads)
                     {
                         payloadSet.Add(Encoding.UTF8.GetString((byte[])(Array)payload));
                     }
@@ -358,11 +357,10 @@ namespace Lucene.Net.Search.Spans
             {
                 while (spans.Next())
                 {
-                    ICollection<sbyte[]> payloads = spans.Payload;
-
-                    foreach (sbyte[] payload in payloads)
+                    var payloads = spans.Payload;
+                    foreach (var payload in payloads)
                     {
-                        payloadSet.Add(Encoding.UTF8.GetString((byte[])(Array)payload));
+                        payloadSet.Add(Encoding.UTF8.GetString(payload));
                     }
                 }
             }
@@ -396,11 +394,11 @@ namespace Lucene.Net.Search.Spans
 
             PayloadSpanUtil psu = new PayloadSpanUtil(searcher.TopReaderContext);
 
-            ICollection<sbyte[]> payloads = psu.GetPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr")));
+            var payloads = psu.GetPayloadsForQuery(new TermQuery(new Term(PayloadHelper.FIELD, "rr")));
             if (VERBOSE)
             {
                 Console.WriteLine("Num payloads:" + payloads.Count);
-                foreach (sbyte[] bytes in payloads)
+                foreach (var bytes in payloads)
                 {
                     Console.WriteLine(Encoding.UTF8.GetString((byte[])(Array)bytes));
                 }
@@ -429,9 +427,9 @@ namespace Lucene.Net.Search.Spans
                 //See payload helper, for the PayloadHelper.FIELD field, there is a single byte payload at every token
                 if (spans.PayloadAvailable)
                 {
-                    ICollection<sbyte[]> payload = spans.Payload;
+                    var payload = spans.Payload;
                     Assert.IsTrue(payload.Count == expectedNumPayloads, "payload Size: " + payload.Count + " is not: " + expectedNumPayloads);
-                    foreach (sbyte[] thePayload in payload)
+                    foreach (var thePayload in payload)
                     {
                         Assert.IsTrue(thePayload.Length == expectedPayloadLength, "payload[0] Size: " + thePayload.Length + " is not: " + expectedPayloadLength);
                         Assert.IsTrue(thePayload[0] == expectedFirstByte, thePayload[0] + " does not equal: " + expectedFirstByte);
@@ -479,11 +477,11 @@ namespace Lucene.Net.Search.Spans
                 }
                 if (spans.PayloadAvailable)
                 {
-                    ICollection<sbyte[]> payload = spans.Payload;
+                    var payload = spans.Payload;
                     if (VERBOSE)
                     {
                         Console.WriteLine("payloads for span:" + payload.Count);
-                        foreach (sbyte[] bytes in payload)
+                        foreach (var bytes in payload)
                         {
                             Console.WriteLine("doc:" + spans.Doc() + " s:" + spans.Start() + " e:" + spans.End() + " " + Encoding.UTF8.GetString((byte[])(Array)bytes));
                         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Search/TestPositionIncrement.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Search/TestPositionIncrement.cs b/src/Lucene.Net.Tests/core/Search/TestPositionIncrement.cs
index 982c244..da754ea 100644
--- a/src/Lucene.Net.Tests/core/Search/TestPositionIncrement.cs
+++ b/src/Lucene.Net.Tests/core/Search/TestPositionIncrement.cs
@@ -272,9 +272,9 @@ namespace Lucene.Net.Search
                 {
                     Console.WriteLine("doc " + pspans.Doc() + ": span " + pspans.Start() + " to " + pspans.End());
                 }
-                ICollection<sbyte[]> payloads = pspans.Payload;
+                var payloads = pspans.Payload;
                 sawZero |= pspans.Start() == 0;
-                foreach (sbyte[] bytes in payloads)
+                foreach (var bytes in payloads)
                 {
                     count++;
                     if (VERBOSE)
@@ -304,11 +304,11 @@ namespace Lucene.Net.Search
 
             sawZero = false;
             PayloadSpanUtil psu = new PayloadSpanUtil(@is.TopReaderContext);
-            ICollection<sbyte[]> pls = psu.GetPayloadsForQuery(snq);
+            var pls = psu.GetPayloadsForQuery(snq);
             count = pls.Count;
-            foreach (sbyte[] bytes in pls)
+            foreach (var bytes in pls)
             {
-                string s = Encoding.UTF8.GetString((byte[])(Array)bytes);
+                string s = Encoding.UTF8.GetString(bytes);
                 //System.out.println(s);
                 sawZero |= s.Equals("pos: 0");
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs b/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
index 8d0f3b6..aa7807c 100644
--- a/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
+++ b/src/Lucene.Net.Tests/core/Store/TestMultiMMap.cs
@@ -251,12 +251,12 @@ namespace Lucene.Net.Store
             {
                 MMapDirectory mmapDir = new MMapDirectory(CreateTempDir("testSeekEnd"), null, 1 << i);
                 IndexOutput io = mmapDir.CreateOutput("bytes", NewIOContext(Random()));
-                sbyte[] bytes = new sbyte[1 << i];
+                var bytes = new byte[1 << i];
                 Random().NextBytes((byte[])(Array)bytes);
                 io.WriteBytes(bytes, bytes.Length);
                 io.Dispose();
                 IndexInput ii = mmapDir.OpenInput("bytes", NewIOContext(Random()));
-                sbyte[] actual = new sbyte[1 << i];
+                var actual = new byte[1 << i];
                 ii.ReadBytes(actual, 0, actual.Length);
                 Assert.AreEqual(new BytesRef(bytes), new BytesRef(actual));
                 ii.Seek(1 << i);
@@ -272,13 +272,13 @@ namespace Lucene.Net.Store
             {
                 MMapDirectory mmapDir = new MMapDirectory(CreateTempDir("testSeekSliceEnd"), null, 1 << i);
                 IndexOutput io = mmapDir.CreateOutput("bytes", NewIOContext(Random()));
-                sbyte[] bytes = new sbyte[1 << i];
-                Random().NextBytes((byte[])(Array)bytes);
+                var bytes = new byte[1 << i];
+                Random().NextBytes(bytes);
                 io.WriteBytes(bytes, bytes.Length);
                 io.Dispose();
                 IndexInputSlicer slicer = mmapDir.CreateSlicer("bytes", NewIOContext(Random()));
                 IndexInput ii = slicer.OpenSlice("full slice", 0, bytes.Length);
-                sbyte[] actual = new sbyte[1 << i];
+                var actual = new byte[1 << i];
                 ii.ReadBytes(actual, 0, actual.Length);
                 Assert.AreEqual(new BytesRef(bytes), new BytesRef(actual));
                 ii.Seek(1 << i);
@@ -295,19 +295,19 @@ namespace Lucene.Net.Store
             {
                 MMapDirectory mmapDir = new MMapDirectory(CreateTempDir("testSeeking"), null, 1 << i);
                 IndexOutput io = mmapDir.CreateOutput("bytes", NewIOContext(Random()));
-                sbyte[] bytes = new sbyte[1 << (i + 1)]; // make sure we switch buffers
-                Random().NextBytes((byte[])(Array)bytes);
+                var bytes = new byte[1 << (i + 1)]; // make sure we switch buffers
+                Random().NextBytes(bytes);
                 io.WriteBytes(bytes, bytes.Length);
                 io.Dispose();
                 IndexInput ii = mmapDir.OpenInput("bytes", NewIOContext(Random()));
-                sbyte[] actual = new sbyte[1 << (i + 1)]; // first read all bytes
+                var actual = new byte[1 << (i + 1)]; // first read all bytes
                 ii.ReadBytes(actual, 0, actual.Length);
                 Assert.AreEqual(new BytesRef(bytes), new BytesRef(actual));
                 for (int sliceStart = 0; sliceStart < bytes.Length; sliceStart++)
                 {
                     for (int sliceLength = 0; sliceLength < bytes.Length - sliceStart; sliceLength++)
                     {
-                        sbyte[] slice = new sbyte[sliceLength];
+                        var slice = new byte[sliceLength];
                         ii.Seek(sliceStart);
                         ii.ReadBytes(slice, 0, slice.Length);
                         Assert.AreEqual(new BytesRef(bytes, sliceStart, sliceLength), new BytesRef(slice));
@@ -327,12 +327,12 @@ namespace Lucene.Net.Store
             {
                 MMapDirectory mmapDir = new MMapDirectory(CreateTempDir("testSlicedSeeking"), null, 1 << i);
                 IndexOutput io = mmapDir.CreateOutput("bytes", NewIOContext(Random()));
-                sbyte[] bytes = new sbyte[1 << (i + 1)]; // make sure we switch buffers
-                Random().NextBytes((byte[])(Array)bytes);
+                var bytes = new byte[1 << (i + 1)]; // make sure we switch buffers
+                Random().NextBytes(bytes);
                 io.WriteBytes(bytes, bytes.Length);
                 io.Dispose();
                 IndexInput ii = mmapDir.OpenInput("bytes", NewIOContext(Random()));
-                sbyte[] actual = new sbyte[1 << (i + 1)]; // first read all bytes
+                var actual = new byte[1 << (i + 1)]; // first read all bytes
                 ii.ReadBytes(actual, 0, actual.Length);
                 ii.Dispose();
                 Assert.AreEqual(new BytesRef(bytes), new BytesRef(actual));
@@ -341,7 +341,7 @@ namespace Lucene.Net.Store
                 {
                     for (int sliceLength = 0; sliceLength < bytes.Length - sliceStart; sliceLength++)
                     {
-                        sbyte[] slice = new sbyte[sliceLength];
+                        var slice = new byte[sliceLength];
                         IndexInput input = slicer.OpenSlice("bytesSlice", sliceStart, slice.Length);
                         input.ReadBytes(slice, 0, slice.Length);
                         input.Dispose();

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/Automaton/TestDeterminizeLexicon.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Automaton/TestDeterminizeLexicon.cs b/src/Lucene.Net.Tests/core/Util/Automaton/TestDeterminizeLexicon.cs
index ef5f3c3..63b5aeb 100644
--- a/src/Lucene.Net.Tests/core/Util/Automaton/TestDeterminizeLexicon.cs
+++ b/src/Lucene.Net.Tests/core/Util/Automaton/TestDeterminizeLexicon.cs
@@ -64,7 +64,7 @@ namespace Lucene.Net.Util.Automaton
             var lexByte = new ByteRunAutomaton(lex);
             foreach (string s in terms)
             {
-                sbyte[] bytes = s.GetBytes(Encoding.UTF8);
+                var bytes = s.GetBytes(Encoding.UTF8);
                 Assert.IsTrue(lexByte.Run(bytes, 0, bytes.Length));
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/Automaton/TestUTF32ToUTF8.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Automaton/TestUTF32ToUTF8.cs b/src/Lucene.Net.Tests/core/Util/Automaton/TestUTF32ToUTF8.cs
index ce82c79..5e421a8 100644
--- a/src/Lucene.Net.Tests/core/Util/Automaton/TestUTF32ToUTF8.cs
+++ b/src/Lucene.Net.Tests/core/Util/Automaton/TestUTF32ToUTF8.cs
@@ -202,7 +202,7 @@ namespace Lucene.Net.Util.Automaton
 
             // make sure byte dfa accepts empty string
             Assert.IsTrue(bra.IsAccept(bra.InitialState));
-            Assert.IsTrue(bra.Run(new sbyte[0], 0, 0));
+            Assert.IsTrue(bra.Run(new byte[0], 0, 0));
         }
 
         [Test]
@@ -216,7 +216,7 @@ namespace Lucene.Net.Util.Automaton
 
             Assert.IsTrue(cra.Run(input));
 
-            sbyte[] bytes = input.GetBytes(Encoding.UTF8);
+            var bytes = input.GetBytes(Encoding.UTF8);
             Assert.IsTrue(bra.Run(bytes, 0, bytes.Length)); // this one fails!
         }
 
@@ -231,7 +231,7 @@ namespace Lucene.Net.Util.Automaton
 
             Assert.IsTrue(cra.Run(input));
 
-            sbyte[] bytes = input.GetBytes(Encoding.UTF8);
+            var bytes = input.GetBytes(Encoding.UTF8);
             Assert.IsTrue(bra.Run(bytes, 0, bytes.Length));
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs b/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
index 394a655..4fee6e0 100644
--- a/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
+++ b/src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs
@@ -151,14 +151,14 @@ namespace Lucene.Net.Util.Fst
                     Outputs<BytesRef> outputs = ByteSequenceOutputs.Singleton;
                     Builder<BytesRef> b = new Builder<BytesRef>(FST.INPUT_TYPE.BYTE1, 0, 0, true, true, int.MaxValue, outputs, null, doPack, PackedInts.COMPACT, true, 15);
 
-                    sbyte[] outputBytes = new sbyte[20];
+                    var outputBytes = new byte[20];
                     BytesRef output = new BytesRef(outputBytes);
                     Arrays.Fill(ints, 0);
                     int count = 0;
                     Random r = new Random(seed);
                     while (true)
                     {
-                        r.NextBytes((byte[])(Array)outputBytes);
+                        r.NextBytes(outputBytes);
                         //System.out.println("add: " + input + " -> " + output);
                         b.Add(input, BytesRef.DeepCopyOf(output));
                         count++;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/Test2BPagedBytes.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/Test2BPagedBytes.cs b/src/Lucene.Net.Tests/core/Util/Test2BPagedBytes.cs
index 0987266..76089b9 100644
--- a/src/Lucene.Net.Tests/core/Util/Test2BPagedBytes.cs
+++ b/src/Lucene.Net.Tests/core/Util/Test2BPagedBytes.cs
@@ -71,9 +71,9 @@ namespace Lucene.Net.Util
             while (netBytes < 1.1 * int.MaxValue)
             {
                 int numBytes = TestUtil.NextInt(r2, 1, 32768);
-                byte[] bytes = new byte[numBytes];
+                var bytes = new byte[numBytes];
                 r2.NextBytes(bytes);
-                BytesRef expected = new BytesRef((sbyte[])(Array)bytes);
+                BytesRef expected = new BytesRef(bytes);
 
                 BytesRef actual = new BytesRef();
                 reader.FillSlice(actual, netBytes, numBytes);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/TestBytesRef.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestBytesRef.cs b/src/Lucene.Net.Tests/core/Util/TestBytesRef.cs
index 3e9a3bbb..1e3c467 100644
--- a/src/Lucene.Net.Tests/core/Util/TestBytesRef.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestBytesRef.cs
@@ -34,7 +34,7 @@ namespace Lucene.Net.Util
         [Test]
         public virtual void TestFromBytes()
         {
-            sbyte[] bytes = new sbyte[] { (sbyte)'a', (sbyte)'b', (sbyte)'c', (sbyte)'d' };
+            var bytes = new [] { (byte)'a', (byte)'b', (byte)'c', (byte)'d' };
             BytesRef b = new BytesRef(bytes);
             Assert.AreEqual(bytes, b.Bytes);
             Assert.AreEqual(0, b.Offset);
@@ -64,7 +64,7 @@ namespace Lucene.Net.Util
         [Test]
         public virtual void TestAppend()
         {
-            sbyte[] bytes = new sbyte[] { (sbyte)'a', (sbyte)'b', (sbyte)'c', (sbyte)'d' };
+            var bytes = new[] { (byte)'a', (byte)'b', (byte)'c', (byte)'d' };
             BytesRef b = new BytesRef(bytes, 1, 3); // bcd
             b.Append(new BytesRef("e"));
             Assert.AreEqual("bcde", b.Utf8ToString());
@@ -74,7 +74,7 @@ namespace Lucene.Net.Util
         [Test]
         public virtual void TestCopyBytes()
         {
-            sbyte[] bytes = new sbyte[] { (sbyte)'a', (sbyte)'b', (sbyte)'c', (sbyte)'d' };
+            var bytes = new[] { (byte)'a', (byte)'b', (byte)'c', (byte)'d' };
             BytesRef b = new BytesRef(bytes, 1, 3); // bcd
             b.CopyBytes(new BytesRef("bcde"));
             Assert.AreEqual("bcde", b.Utf8ToString());

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs b/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
index 353f18f..1f63abd 100644
--- a/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestBytesRefHash.cs
@@ -326,11 +326,11 @@ namespace Lucene.Net.Util
         [ExpectedException(typeof(MaxBytesLengthExceededException))]
         public virtual void TestLargeValue()
         {
-            int[] sizes = new int[] { Random().Next(5), ByteBlockPool.BYTE_BLOCK_SIZE - 33 + Random().Next(31), ByteBlockPool.BYTE_BLOCK_SIZE - 1 + Random().Next(37) };
+            int[] sizes = { Random().Next(5), ByteBlockPool.BYTE_BLOCK_SIZE - 33 + Random().Next(31), ByteBlockPool.BYTE_BLOCK_SIZE - 1 + Random().Next(37) };
             BytesRef @ref = new BytesRef();
             for (int i = 0; i < sizes.Length; i++)
             {
-                @ref.Bytes = new sbyte[sizes[i]];
+                @ref.Bytes = new byte[sizes[i]];
                 @ref.Offset = 0;
                 @ref.Length = sizes[i];
                 try

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/TestRecyclingByteBlockAllocator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestRecyclingByteBlockAllocator.cs b/src/Lucene.Net.Tests/core/Util/TestRecyclingByteBlockAllocator.cs
index 6359227..8847fc7 100644
--- a/src/Lucene.Net.Tests/core/Util/TestRecyclingByteBlockAllocator.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestRecyclingByteBlockAllocator.cs
@@ -43,8 +43,8 @@ namespace Lucene.Net.Util
         public virtual void TestAllocate()
         {
             RecyclingByteBlockAllocator allocator = NewAllocator();
-            HashSet<sbyte[]> set = new HashSet<sbyte[]>();
-            sbyte[] block = allocator.ByteBlock;
+            var set = new HashSet<byte[]>();
+            var block = allocator.ByteBlock;
             set.Add(block);
             Assert.IsNotNull(block);
             int size = block.Length;
@@ -65,9 +65,9 @@ namespace Lucene.Net.Util
         public virtual void TestAllocateAndRecycle()
         {
             RecyclingByteBlockAllocator allocator = NewAllocator();
-            HashSet<sbyte[]> allocated = new HashSet<sbyte[]>();
+            var allocated = new HashSet<byte[]>();
 
-            sbyte[] block = allocator.ByteBlock;
+            var block = allocator.ByteBlock;
             allocated.Add(block);
             Assert.IsNotNull(block);
             int size = block.Length;
@@ -84,10 +84,10 @@ namespace Lucene.Net.Util
                     Assert.IsTrue(allocated.Add(block), "block is returned twice");
                     Assert.AreEqual(size * (allocated.Count + allocator.NumBufferedBlocks()), allocator.BytesUsed());
                 }
-                sbyte[][] array = allocated.ToArray(/*new sbyte[0][]*/);
+                var array = allocated.ToArray();
                 int begin = Random().Next(array.Length);
                 int end = begin + Random().Next(array.Length - begin);
-                IList<sbyte[]> selected = new List<sbyte[]>();
+                var selected = new List<byte[]>();
                 for (int j = begin; j < end; j++)
                 {
                     selected.Add(array[j]);
@@ -96,7 +96,7 @@ namespace Lucene.Net.Util
                 for (int j = begin; j < end; j++)
                 {
                     Assert.IsNull(array[j]);
-                    sbyte[] b = selected[0];
+                    var b = selected[0];
                     selected.RemoveAt(0);
                     Assert.IsTrue(allocated.Remove(b));
                 }
@@ -107,9 +107,9 @@ namespace Lucene.Net.Util
         public virtual void TestAllocateAndFree()
         {
             RecyclingByteBlockAllocator allocator = NewAllocator();
-            HashSet<sbyte[]> allocated = new HashSet<sbyte[]>();
+            var allocated = new HashSet<byte[]>();
             int freeButAllocated = 0;
-            sbyte[] block = allocator.ByteBlock;
+            var block = allocator.ByteBlock;
             allocated.Add(block);
             Assert.IsNotNull(block);
             int size = block.Length;
@@ -128,12 +128,12 @@ namespace Lucene.Net.Util
                     Assert.AreEqual(size * (allocated.Count + allocator.NumBufferedBlocks()), allocator.BytesUsed());
                 }
 
-                sbyte[][] array = allocated.ToArray(/*new sbyte[0][]*/);
+                var array = allocated.ToArray();
                 int begin = Random().Next(array.Length);
                 int end = begin + Random().Next(array.Length - begin);
                 for (int j = begin; j < end; j++)
                 {
-                    sbyte[] b = array[j];
+                    var b = array[j];
                     Assert.IsTrue(allocated.Remove(b));
                 }
                 allocator.RecycleByteBlocks(array, begin, end);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Util/TestUnicodeUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Util/TestUnicodeUtil.cs b/src/Lucene.Net.Tests/core/Util/TestUnicodeUtil.cs
index 0727056..1b8ae72 100644
--- a/src/Lucene.Net.Tests/core/Util/TestUnicodeUtil.cs
+++ b/src/Lucene.Net.Tests/core/Util/TestUnicodeUtil.cs
@@ -127,17 +127,17 @@ namespace Lucene.Net.Util
             }
         }
 
-        private sbyte[] AsByteArray(params int[] ints)
+        private static byte[] AsByteArray(params int[] ints)
         {
-            sbyte[] asByteArray = new sbyte[ints.Length];
+            var asByteArray = new byte[ints.Length];
             for (int i = 0; i < ints.Length; i++)
             {
-                asByteArray[i] = (sbyte)ints[i];
+                asByteArray[i] = (byte)ints[i];
             }
             return asByteArray;
         }
 
-        private void AssertcodePointCountThrowsAssertionOn(params sbyte[] bytes)
+        private static void AssertcodePointCountThrowsAssertionOn(params byte[] bytes)
         {
             bool threwAssertion = false;
             try


Mime
View raw message