You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by sy...@apache.org on 2014/11/10 16:25:23 UTC

[1/5] lucenenet git commit: Getting rid of most sbyte usage in public API

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


[3/5] lucenenet git commit: Getting rid of most sbyte usage in public API

Posted by sy...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/SpanNotQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/SpanNotQuery.cs b/src/Lucene.Net.Core/Search/Spans/SpanNotQuery.cs
index dc2e31c..05c042a 100644
--- a/src/Lucene.Net.Core/Search/Spans/SpanNotQuery.cs
+++ b/src/Lucene.Net.Core/Search/Spans/SpanNotQuery.cs
@@ -240,14 +240,14 @@ namespace Lucene.Net.Search.Spans
                 return includeSpans.End();
             }
 
-            public override ICollection<sbyte[]> Payload
+            public override ICollection<byte[]> Payload
             {
                 get
                 {
-                    List<sbyte[]> result = null;
+                    List<byte[]> result = null;
                     if (includeSpans.PayloadAvailable)
                     {
-                        result = new List<sbyte[]>(includeSpans.Payload);
+                        result = new List<byte[]>(includeSpans.Payload);
                     }
                     return result;
                 }
@@ -277,13 +277,13 @@ namespace Lucene.Net.Search.Spans
         {
             SpanNotQuery clone = null;
 
-            SpanQuery rewrittenInclude = (SpanQuery)include.Rewrite(reader);
+            var rewrittenInclude = (SpanQuery)include.Rewrite(reader);
             if (rewrittenInclude != include)
             {
                 clone = (SpanNotQuery)this.Clone();
                 clone.include = rewrittenInclude;
             }
-            SpanQuery rewrittenExclude = (SpanQuery)exclude.Rewrite(reader);
+            var rewrittenExclude = (SpanQuery)exclude.Rewrite(reader);
             if (rewrittenExclude != exclude)
             {
                 if (clone == null)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs b/src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs
index 8db67a1..dec18e1 100644
--- a/src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs
+++ b/src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs
@@ -326,15 +326,15 @@ namespace Lucene.Net.Search.Spans
                 return Top().End();
             }
 
-            public override ICollection<sbyte[]> Payload
+            public override ICollection<byte[]> Payload
             {
                 get
                 {
-                    List<sbyte[]> result = null;
+                    List<byte[]> result = null;
                     Spans theTop = Top();
                     if (theTop != null && theTop.PayloadAvailable)
                     {
-                        result = new List<sbyte[]>(theTop.Payload);
+                        result = new List<byte[]>(theTop.Payload);
                     }
                     return result;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/SpanPayloadCheckQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/SpanPayloadCheckQuery.cs b/src/Lucene.Net.Core/Search/Spans/SpanPayloadCheckQuery.cs
index fab8344..86be021 100644
--- a/src/Lucene.Net.Core/Search/Spans/SpanPayloadCheckQuery.cs
+++ b/src/Lucene.Net.Core/Search/Spans/SpanPayloadCheckQuery.cs
@@ -36,12 +36,12 @@ namespace Lucene.Net.Search.Spans
     /// </summary>
     public class SpanPayloadCheckQuery : SpanPositionCheckQuery
     {
-        protected internal readonly ICollection<sbyte[]> PayloadToMatch;
+        protected internal readonly ICollection<byte[]> PayloadToMatch;
 
         ///
         /// <param name="match"> The underlying <seealso cref="Lucene.Net.Search.Spans.SpanQuery"/> to check </param>
         /// <param name="payloadToMatch"> The <seealso cref="java.util.Collection"/> of payloads to match </param>
-        public SpanPayloadCheckQuery(SpanQuery match, ICollection<sbyte[]> payloadToMatch)
+        public SpanPayloadCheckQuery(SpanQuery match, ICollection<byte[]> payloadToMatch)
             : base(match)
         {
             if (match is SpanNearQuery)
@@ -56,14 +56,14 @@ namespace Lucene.Net.Search.Spans
             bool result = spans.PayloadAvailable;
             if (result == true)
             {
-                ICollection<sbyte[]> candidate = spans.Payload;
+                var candidate = spans.Payload;
                 if (candidate.Count == PayloadToMatch.Count)
                 {
                     //TODO: check the byte arrays are the same
-                    IEnumerator<sbyte[]> toMatchIter = PayloadToMatch.GetEnumerator();
+                    var toMatchIter = PayloadToMatch.GetEnumerator();
                     //check each of the byte arrays, in order
                     //hmm, can't rely on order here
-                    foreach (sbyte[] candBytes in candidate)
+                    foreach (var candBytes in candidate)
                     {
                         toMatchIter.MoveNext();
                         //if one is a mismatch, then return false
@@ -89,7 +89,7 @@ namespace Lucene.Net.Search.Spans
             buffer.Append("spanPayCheck(");
             buffer.Append(match.ToString(field));
             buffer.Append(", payloadRef: ");
-            foreach (sbyte[] bytes in PayloadToMatch)
+            foreach (var bytes in PayloadToMatch)
             {
                 ToStringUtils.ByteArray(buffer, bytes);
                 buffer.Append(';');

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/SpanPositionCheckQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/SpanPositionCheckQuery.cs b/src/Lucene.Net.Core/Search/Spans/SpanPositionCheckQuery.cs
index 723bf06..bd0e472 100644
--- a/src/Lucene.Net.Core/Search/Spans/SpanPositionCheckQuery.cs
+++ b/src/Lucene.Net.Core/Search/Spans/SpanPositionCheckQuery.cs
@@ -107,7 +107,7 @@ namespace Lucene.Net.Search.Spans
         {
             SpanPositionCheckQuery clone = null;
 
-            SpanQuery rewritten = (SpanQuery)match.Rewrite(reader);
+            var rewritten = (SpanQuery)match.Rewrite(reader);
             if (rewritten != match)
             {
                 clone = (SpanPositionCheckQuery)this.Clone();
@@ -198,14 +198,14 @@ namespace Lucene.Net.Search.Spans
                 return Spans.End();
             }
 
-            public override ICollection<sbyte[]> Payload
+            public override ICollection<byte[]> Payload
             {
                 get
                 {
-                    List<sbyte[]> result = null;
+                    List<byte[]> result = null;
                     if (Spans.PayloadAvailable)
                     {
-                        result = new List<sbyte[]>(Spans.Payload);
+                        result = new List<byte[]>(Spans.Payload);
                     }
                     return result; //TODO: any way to avoid the new construction?
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/Spans.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/Spans.cs b/src/Lucene.Net.Core/Search/Spans/Spans.cs
index d187ba8..e84a276 100644
--- a/src/Lucene.Net.Core/Search/Spans/Spans.cs
+++ b/src/Lucene.Net.Core/Search/Spans/Spans.cs
@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.IO;
 
 namespace Lucene.Net.Search.Spans
 {
@@ -82,7 +83,7 @@ namespace Lucene.Net.Search.Spans
         /// <returns> a List of byte arrays containing the data of this payload, otherwise null if isPayloadAvailable is false </returns>
         /// <exception cref="IOException"> if there is a low-level I/O error </exception>
         // TODO: Remove warning after API has been finalized
-        public abstract ICollection<sbyte[]> Payload { get; }
+        public abstract ICollection<byte[]> Payload { get; }
 
         /// <summary>
         /// Checks if a payload can be loaded at this position.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/TermSpans.cs b/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
index 8a339c8..1489824 100644
--- a/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
+++ b/src/Lucene.Net.Core/Search/Spans/TermSpans.cs
@@ -113,16 +113,16 @@ namespace Lucene.Net.Search.Spans
         }
 
         // TODO: Remove warning after API has been finalized
-        public override ICollection<sbyte[]> Payload
+        public override ICollection<byte[]> Payload
         {
             get
             {
-                BytesRef payload = Postings_Renamed.Payload;
+                var payload = Postings_Renamed.Payload;
                 ReadPayload = true;
-                sbyte[] bytes;
+                byte[] bytes;
                 if (payload != null)
                 {
-                    bytes = new sbyte[payload.Length];
+                    bytes = new byte[payload.Length];
                     Array.Copy(payload.Bytes, payload.Offset, bytes, 0, payload.Length);
                 }
                 else
@@ -184,7 +184,7 @@ namespace Lucene.Net.Search.Spans
                 return -1;
             }
 
-            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.Core/Store/DataOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/DataOutput.cs b/src/Lucene.Net.Core/Store/DataOutput.cs
index 04ee1b8..63edc09 100644
--- a/src/Lucene.Net.Core/Store/DataOutput.cs
+++ b/src/Lucene.Net.Core/Store/DataOutput.cs
@@ -255,13 +255,18 @@ namespace Lucene.Net.Store
         /// <seealso cref= DataInput#readString() </seealso>
         public virtual void WriteString(string s)
         {
-            BytesRef utf8Result = new BytesRef(10);
+            var utf8Result = new BytesRef(10);
             UnicodeUtil.UTF16toUTF8(s.ToCharArray(), 0, s.Length, utf8Result);
             WriteVInt(utf8Result.Length);
             WriteBytes(utf8Result.Bytes, 0, utf8Result.Length);
         }
 
-        private static int COPY_BUFFER_SIZE = 16384;
+        public void Write(byte[] b, int off, int len)
+        {
+            WriteBytes(b, off, len);
+        }
+
+        private const int COPY_BUFFER_SIZE = 16384;
         private sbyte[] CopyBuffer;
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Store/FSDirectory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/FSDirectory.cs b/src/Lucene.Net.Core/Store/FSDirectory.cs
index 1c80319..aaa278f 100644
--- a/src/Lucene.Net.Core/Store/FSDirectory.cs
+++ b/src/Lucene.Net.Core/Store/FSDirectory.cs
@@ -125,7 +125,7 @@ namespace Lucene.Net.Store
             {
                 file.Create();
             }
-            catch (IOException ioe)
+            catch (IOException)
             {
                 //File already exists
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Store/NativeFSLockFactory.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/NativeFSLockFactory.cs b/src/Lucene.Net.Core/Store/NativeFSLockFactory.cs
index 743184e..e21210a 100644
--- a/src/Lucene.Net.Core/Store/NativeFSLockFactory.cs
+++ b/src/Lucene.Net.Core/Store/NativeFSLockFactory.cs
@@ -443,7 +443,7 @@ namespace Lucene.Net.Store
                         }
                         return !obtained;
                     }
-                    catch (System.IO.IOException ioe)
+                    catch (IOException)
                     {
                         return false;
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Store/RAMOutputStream.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Store/RAMOutputStream.cs b/src/Lucene.Net.Core/Store/RAMOutputStream.cs
index 4e3183b..09f1a1a 100644
--- a/src/Lucene.Net.Core/Store/RAMOutputStream.cs
+++ b/src/Lucene.Net.Core/Store/RAMOutputStream.cs
@@ -82,7 +82,7 @@ namespace Lucene.Net.Store
         /// Copy the current contents of this buffer to output
         ///  byte array
         /// </summary>
-        public virtual void WriteTo(sbyte[] bytes, int offset)
+        public virtual void WriteTo(byte[] bytes, int offset)
         {
             Flush();
             long end = File.Length_Renamed;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Support/StringSupport.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/StringSupport.cs b/src/Lucene.Net.Core/Support/StringSupport.cs
index b7dc25a..94f9108 100644
--- a/src/Lucene.Net.Core/Support/StringSupport.cs
+++ b/src/Lucene.Net.Core/Support/StringSupport.cs
@@ -1,14 +1,13 @@
 using Lucene.Net.Util;
-using System;
 using System.Text;
 
 namespace Lucene.Net.Support
 {
     public static class StringSupport
     {
-        public static sbyte[] GetBytes(this string str, Encoding enc)
+        public static byte[] GetBytes(this string str, Encoding enc)
         {
-            return (sbyte[])(Array)enc.GetBytes(str);
+            return enc.GetBytes(str);
         }
 
         public static BytesRef ToBytesRefArray(this string str, Encoding enc)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/ArrayUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/ArrayUtil.cs b/src/Lucene.Net.Core/Util/ArrayUtil.cs
index 22e4603..031169a 100644
--- a/src/Lucene.Net.Core/Util/ArrayUtil.cs
+++ b/src/Lucene.Net.Core/Util/ArrayUtil.cs
@@ -445,23 +445,18 @@ namespace Lucene.Net.Util
             }
         }
 
-        public static sbyte[] Grow(sbyte[] array)
-        {
-            return Grow(array, 1 + array.Length);
-        }
-
         public static byte[] Grow(byte[] array)
         {
             return Grow(array, 1 + array.Length);
         }
 
-        public static sbyte[] Shrink(sbyte[] array, int targetSize)
+        public static byte[] Shrink(byte[] array, int targetSize)
         {
             Debug.Assert(targetSize >= 0, "size must be positive (got " + targetSize + "): likely integer overflow?");
             int newSize = GetShrinkSize(array.Length, targetSize, 1);
             if (newSize != array.Length)
             {
-                sbyte[] newArray = new sbyte[newSize];
+                var newArray = new byte[newSize];
                 Array.Copy(array, 0, newArray, 0, newSize);
                 return newArray;
             }
@@ -548,7 +543,7 @@ namespace Lucene.Net.Util
             Debug.Assert(minSize >= 0, "size must be positive (got " + minSize + "): likely integer overflow?");
             if (array.Length < minSize)
             {
-                int[][] newArray = new int[Oversize(minSize, RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
+                var newArray = new int[Oversize(minSize, RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
                 Array.Copy(array, 0, newArray, 0, array.Length);
                 return newArray;
             }
@@ -683,7 +678,7 @@ namespace Lucene.Net.Util
         /// <returns> true if the two arrays, starting at their respective offsets, are equal
         /// </returns>
         /// <seealso cref= java.util.Arrays#equals(byte[], byte[]) </seealso>
-        public static bool Equals(sbyte[] left, int offsetLeft, sbyte[] right, int offsetRight, int length)
+        public static bool Equals(byte[] left, int offsetLeft, byte[] right, int offsetRight, int length)
         {
             if ((offsetLeft + length <= left.Length) && (offsetRight + length <= right.Length))
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Automaton/ByteRunAutomaton.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Automaton/ByteRunAutomaton.cs b/src/Lucene.Net.Core/Util/Automaton/ByteRunAutomaton.cs
index 96c7e9a..0eddb45 100644
--- a/src/Lucene.Net.Core/Util/Automaton/ByteRunAutomaton.cs
+++ b/src/Lucene.Net.Core/Util/Automaton/ByteRunAutomaton.cs
@@ -37,13 +37,13 @@ namespace Lucene.Net.Util.Automaton
         /// <summary>
         /// Returns true if the given byte array is accepted by this automaton
         /// </summary>
-        public virtual bool Run(sbyte[] s, int offset, int length)
+        public virtual bool Run(byte[] s, int offset, int length)
         {
-            int p = Initial;
-            int l = offset + length;
+            var p = Initial;
+            var l = offset + length;
             for (int i = offset; i < l; i++)
             {
-                p = Step(p, s[i] & 0xFF);
+                p = Step(p, ((sbyte)s[i]) & 0xFF);
                 if (p == -1)
                 {
                     return false;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Automaton/CompiledAutomaton.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Automaton/CompiledAutomaton.cs b/src/Lucene.Net.Core/Util/Automaton/CompiledAutomaton.cs
index 7eef428..ed51849 100644
--- a/src/Lucene.Net.Core/Util/Automaton/CompiledAutomaton.cs
+++ b/src/Lucene.Net.Core/Util/Automaton/CompiledAutomaton.cs
@@ -239,7 +239,7 @@ namespace Lucene.Net.Util.Automaton
                 term.Grow(1 + idx);
             }
             //if (DEBUG) System.out.println("  add floorLabel=" + (char) floorLabel + " idx=" + idx);
-            term.Bytes[idx] = (sbyte)floorLabel;
+            term.Bytes[idx] = (byte)floorLabel;
 
             state = maxTransition.To.Number;
             idx++;
@@ -266,7 +266,7 @@ namespace Lucene.Net.Util.Automaton
                         term.Grow(1 + idx);
                     }
                     //if (DEBUG) System.out.println("  push maxLabel=" + (char) lastTransition.max + " idx=" + idx);
-                    term.Bytes[idx] = (sbyte)lastTransition.Max_Renamed;
+                    term.Bytes[idx] = (byte)lastTransition.Max_Renamed;
                     state = lastTransition.To.Number;
                     idx++;
                 }
@@ -338,7 +338,7 @@ namespace Lucene.Net.Util.Automaton
             int idx = 0;
             while (true)
             {
-                int label = input.Bytes[input.Offset + idx] & 0xff;
+                int label = ((sbyte)input.Bytes[input.Offset + idx]) & 0xff;
                 int nextState = RunAutomaton.Step(state, label);
                 //if (DEBUG) System.out.println("  cycle label=" + (char) label + " nextState=" + nextState);
 
@@ -351,7 +351,7 @@ namespace Lucene.Net.Util.Automaton
                         {
                             output.Grow(1 + idx);
                         }
-                        output.Bytes[idx] = (sbyte)label;
+                        output.Bytes[idx] = (byte)label;
                         output.Length = input.Length;
                         //if (DEBUG) System.out.println("  input is accepted; return term=" + output.utf8ToString());
                         return output;
@@ -416,7 +416,7 @@ namespace Lucene.Net.Util.Automaton
                     {
                         output.Grow(1 + idx);
                     }
-                    output.Bytes[idx] = (sbyte)label;
+                    output.Bytes[idx] = (byte)label;
                     stack.Add(state);
                     state = nextState;
                     idx++;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Automaton/SpecialOperations.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Automaton/SpecialOperations.cs b/src/Lucene.Net.Core/Util/Automaton/SpecialOperations.cs
index f634ab7..75c8f86 100644
--- a/src/Lucene.Net.Core/Util/Automaton/SpecialOperations.cs
+++ b/src/Lucene.Net.Core/Util/Automaton/SpecialOperations.cs
@@ -170,7 +170,7 @@ namespace Lucene.Net.Util.Automaton
                     if (t.Min_Renamed == t.Max_Renamed && !visited.Contains(t.To))
                     {
                         @ref.Grow(++@ref.Length);
-                        @ref.Bytes[@ref.Length - 1] = (sbyte)t.Min_Renamed;
+                        @ref.Bytes[@ref.Length - 1] = (byte)t.Min_Renamed;
                         s = t.To;
                         done = false;
                     }
@@ -223,7 +223,7 @@ namespace Lucene.Net.Util.Automaton
             int num = @ref.Length >> 1;
             for (int i = @ref.Offset; i < (@ref.Offset + num); i++)
             {
-                sbyte b = @ref.Bytes[i];
+                var b = @ref.Bytes[i];
                 @ref.Bytes[i] = @ref.Bytes[@ref.Offset * 2 + @ref.Length - i - 1];
                 @ref.Bytes[@ref.Offset * 2 + @ref.Length - i - 1] = b;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/BitUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BitUtil.cs b/src/Lucene.Net.Core/Util/BitUtil.cs
index ef40adc..48cee94 100644
--- a/src/Lucene.Net.Core/Util/BitUtil.cs
+++ b/src/Lucene.Net.Core/Util/BitUtil.cs
@@ -60,11 +60,6 @@ namespace Lucene.Net.Util // from org.apache.solr.util rev 555343
             return BYTE_COUNTS[b & 0xFF];
         }
 
-        public static int BitCount(sbyte b)
-        {
-            return BYTE_COUNTS[b & 0xFF];
-        }
-
         /// <summary>
         /// Return the list of bits which are set in b encoded as followed:
         /// <code>(i >>> (4 * n)) & 0x0F</code> is the offset of the n-th set bit of
@@ -75,14 +70,9 @@ namespace Lucene.Net.Util // from org.apache.solr.util rev 555343
         /// <li><code>(0x43 >>> 8) & 0x0F</code> is 0, meaning there is no more bit set in this byte.</li>
         /// </ul>
         /// </summary>
-        public static int BitList(sbyte b)
-        {
-            return BIT_LISTS[b & 0xFF];
-        }
-
         public static int BitList(byte b)
         {
-            return BitList((sbyte)b);
+            return BIT_LISTS[b & 0xFF];
         }
 
         // The pop methods used to rely on bit-manipulation tricks for speed but it

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/ByteBlockPool.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/ByteBlockPool.cs b/src/Lucene.Net.Core/Util/ByteBlockPool.cs
index e7e1d9d..2b2680f 100644
--- a/src/Lucene.Net.Core/Util/ByteBlockPool.cs
+++ b/src/Lucene.Net.Core/Util/ByteBlockPool.cs
@@ -61,19 +61,19 @@ namespace Lucene.Net.Util
                 this.BlockSize = blockSize;
             }
 
-            public abstract void RecycleByteBlocks(sbyte[][] blocks, int start, int end);
+            public abstract void RecycleByteBlocks(byte[][] blocks, int start, int end);
 
-            public virtual void RecycleByteBlocks(List<sbyte[]> blocks)
+            public virtual void RecycleByteBlocks(List<byte[]> blocks)
             {
                 var b = blocks.ToArray();
                 RecycleByteBlocks(b, 0, b.Length);
             }
 
-            public virtual sbyte[] ByteBlock
+            public virtual byte[] ByteBlock
             {
                 get
                 {
-                    return new sbyte[BlockSize];
+                    return new byte[BlockSize];
                 }
             }
         }
@@ -92,7 +92,7 @@ namespace Lucene.Net.Util
             {
             }
 
-            public override void RecycleByteBlocks(sbyte[][] blocks, int start, int end)
+            public override void RecycleByteBlocks(byte[][] blocks, int start, int end)
             {
             }
         }
@@ -116,16 +116,16 @@ namespace Lucene.Net.Util
                 this.BytesUsed = bytesUsed;
             }
 
-            public override sbyte[] ByteBlock
+            public override byte[] ByteBlock
             {
                 get
                 {
                     BytesUsed.AddAndGet(BlockSize);
-                    return new sbyte[BlockSize];
+                    return new byte[BlockSize];
                 }
             }
 
-            public override void RecycleByteBlocks(sbyte[][] blocks, int start, int end)
+            public override void RecycleByteBlocks(byte[][] blocks, int start, int end)
             {
                 BytesUsed.AddAndGet(-((end - start) * BlockSize));
                 for (var i = start; i < end; i++)
@@ -139,7 +139,7 @@ namespace Lucene.Net.Util
         /// array of buffers currently used in the pool. Buffers are allocated if
         /// needed don't modify this outside of this class.
         /// </summary>
-        public sbyte[][] Buffers = new sbyte[10][];
+        public byte[][] Buffers = new byte[10][];
 
         /// <summary>
         /// index into the buffers array pointing to the current buffer used as the head </summary>
@@ -152,7 +152,7 @@ namespace Lucene.Net.Util
         /// <summary>
         /// Current head buffer
         /// </summary>
-        public sbyte[] Buffer;
+        public byte[] Buffer;
 
         /// <summary>
         /// Current head offset </summary>
@@ -196,11 +196,11 @@ namespace Lucene.Net.Util
                     {
                         // Fully zero fill buffers that we fully used
                         //Array.Clear(Buffers[i], 0, Buffers[i].Length);
-                        Arrays.Fill(Buffers[i], (sbyte)0);
+                        Arrays.Fill(Buffers[i], (byte)0);
                     }
                     // Partial zero fill the final buffer
                     //Array.Clear(Buffers[BufferUpto], 0, BufferUpto);
-                    Arrays.Fill(Buffers[BufferUpto], 0, ByteUpto, (sbyte)0);
+                    Arrays.Fill(Buffers[BufferUpto], 0, ByteUpto, (byte)0);
                 }
 
                 if (BufferUpto > 0 || !reuseFirst)
@@ -239,7 +239,7 @@ namespace Lucene.Net.Util
         {
             if (1 + BufferUpto == Buffers.Length)
             {
-                var newBuffers = new sbyte[ArrayUtil.Oversize(Buffers.Length + 1, RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
+                var newBuffers = new byte[ArrayUtil.Oversize(Buffers.Length + 1, RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
                 Array.Copy(Buffers, 0, newBuffers, 0, Buffers.Length);
                 Buffers = newBuffers;
             }
@@ -291,7 +291,7 @@ namespace Lucene.Net.Util
         /// Creates a new byte slice with the given starting size and
         /// returns the slices offset in the pool.
         /// </summary>
-        public int AllocSlice(sbyte[] slice, int upto)
+        public int AllocSlice(byte[] slice, int upto)
         {
             int level = slice[upto] & 15;
             int newLevel = NEXT_LEVEL_ARRAY[level];
@@ -314,13 +314,13 @@ namespace Lucene.Net.Util
             Buffer[newUpto + 2] = slice[upto - 1];
 
             // Write forwarding address at end of last slice:
-            slice[upto - 3] = (sbyte)Number.URShift(offset, 24);
-            slice[upto - 2] = (sbyte)Number.URShift(offset, 16);
-            slice[upto - 1] = (sbyte)Number.URShift(offset, 8);
-            slice[upto] = (sbyte)offset;
+            slice[upto - 3] = (byte)Number.URShift(offset, 24);
+            slice[upto - 2] = (byte)Number.URShift(offset, 16);
+            slice[upto - 1] = (byte)Number.URShift(offset, 8);
+            slice[upto] = (byte)offset;
 
             // Write new level:
-            Buffer[ByteUpto - 1] = (sbyte)(16 | newLevel);
+            Buffer[ByteUpto - 1] = (byte)(16 | newLevel);
 
             return newUpto + 3;
         }
@@ -387,18 +387,18 @@ namespace Lucene.Net.Util
         /// length into the given byte array at offset <tt>off</tt>.
         /// <p>Note: this method allows to copy across block boundaries.</p>
         /// </summary>
-        public void ReadBytes(long offset, sbyte[] bytes, int off, int length)
+        public void ReadBytes(long offset, byte[] bytes, int off, int length)
         {
             if (length == 0)
             {
                 return;
             }
-            int bytesOffset = off;
-            int bytesLength = length;
-            int bufferIndex = (int)(offset >> BYTE_BLOCK_SHIFT);
-            sbyte[] buffer = Buffers[bufferIndex];
-            int pos = (int)(offset & BYTE_BLOCK_MASK);
-            int overflow = (pos + length) - BYTE_BLOCK_SIZE;
+            var bytesOffset = off;
+            var bytesLength = length;
+            var bufferIndex = (int)(offset >> BYTE_BLOCK_SHIFT);
+            var buffer = Buffers[bufferIndex];
+            var pos = (int)(offset & BYTE_BLOCK_MASK);
+            var overflow = (pos + length) - BYTE_BLOCK_SIZE;
             do
             {
                 if (overflow <= 0)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/BytesRef.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRef.cs b/src/Lucene.Net.Core/Util/BytesRef.cs
index f79331f..dc3e4c4 100644
--- a/src/Lucene.Net.Core/Util/BytesRef.cs
+++ b/src/Lucene.Net.Core/Util/BytesRef.cs
@@ -38,11 +38,11 @@ namespace Lucene.Net.Util
     {
         /// <summary>
         /// An empty byte array for convenience </summary>
-        public static readonly sbyte[] EMPTY_BYTES = new sbyte[0];
+        public static readonly byte[] EMPTY_BYTES = new byte[0];
 
         /// <summary>
         /// The contents of the BytesRef. Should never be {@code null}. </summary>
-        public sbyte[] Bytes;
+        public byte[] Bytes;
 
         /// <summary>
         /// Offset of first valid byte. </summary>
@@ -63,7 +63,7 @@ namespace Lucene.Net.Util
         /// this instance will directly reference bytes w/o making a copy.
         /// bytes should not be null.
         /// </summary>
-        public BytesRef(sbyte[] bytes, int offset, int length)
+        public BytesRef(byte[] bytes, int offset, int length)
         {
             this.Bytes = bytes;
             this.Offset = offset;
@@ -75,7 +75,7 @@ namespace Lucene.Net.Util
         /// this instance will directly reference bytes w/o making a copy.
         /// bytes should not be null
         /// </summary>
-        public BytesRef(sbyte[] bytes)
+        public BytesRef(byte[] bytes)
             : this(bytes, 0, bytes.Length)
         {
         }
@@ -86,7 +86,7 @@ namespace Lucene.Net.Util
         /// </summary>
         public BytesRef(int capacity)
         {
-            this.Bytes = new sbyte[capacity];
+            this.Bytes = new byte[capacity];
         }
 
         /// <summary>
@@ -146,9 +146,9 @@ namespace Lucene.Net.Util
             Debug.Assert(other != null);
             if (Length == other.Length)
             {
-                int otherUpto = other.Offset;
-                sbyte[] otherBytes = other.Bytes;
-                int end = Offset + Length;
+                var otherUpto = other.Offset;
+                var otherBytes = other.Bytes;
+                var end = Offset + Length;
                 for (int upto = Offset; upto < end; upto++, otherUpto++)
                 {
                     if (Bytes[upto] != otherBytes[otherUpto])
@@ -240,7 +240,7 @@ namespace Lucene.Net.Util
         {
             if (Bytes.Length - Offset < other.Length)
             {
-                Bytes = new sbyte[other.Length];
+                Bytes = new byte[other.Length];
                 Offset = 0;
             }
             Array.Copy(other.Bytes, other.Offset, Bytes, Offset, other.Length);
@@ -258,7 +258,7 @@ namespace Lucene.Net.Util
             int newLen = Length + other.Length;
             if (Bytes.Length - Offset < newLen)
             {
-                sbyte[] newBytes = new sbyte[newLen];
+                var newBytes = new byte[newLen];
                 Array.Copy(Bytes, Offset, newBytes, 0, Length);
                 Offset = 0;
                 Bytes = newBytes;
@@ -309,9 +309,9 @@ namespace Lucene.Net.Util
 
             public virtual int Compare(BytesRef a, BytesRef b)
             {
-                sbyte[] aBytes = a.Bytes;
+                var aBytes = a.Bytes;
                 int aUpto = a.Offset;
-                sbyte[] bBytes = b.Bytes;
+                var bBytes = b.Bytes;
                 int bUpto = b.Offset;
 
                 int aStop = aUpto + Math.Min(a.Length, b.Length);
@@ -357,9 +357,9 @@ namespace Lucene.Net.Util
 
             public virtual int Compare(BytesRef a, BytesRef b)
             {
-                sbyte[] aBytes = a.Bytes;
+                var aBytes = a.Bytes;
                 int aUpto = a.Offset;
-                sbyte[] bBytes = b.Bytes;
+                var bBytes = b.Bytes;
                 int bUpto = b.Offset;
 
                 int aStop;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/BytesRefHash.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRefHash.cs b/src/Lucene.Net.Core/Util/BytesRefHash.cs
index f1e3ef6..704dfaa 100644
--- a/src/Lucene.Net.Core/Util/BytesRefHash.cs
+++ b/src/Lucene.Net.Core/Util/BytesRefHash.cs
@@ -321,7 +321,7 @@ namespace Lucene.Net.Util
                     }
                     Pool.NextBuffer();
                 }
-                sbyte[] buffer = Pool.Buffer;
+                var buffer = Pool.Buffer;
                 int bufferUpto = Pool.ByteUpto;
                 if (Count >= BytesStart.Length)
                 {
@@ -339,7 +339,7 @@ namespace Lucene.Net.Util
                 if (length < 128)
                 {
                     // 1 byte to store length
-                    buffer[bufferUpto] = (sbyte)length;
+                    buffer[bufferUpto] = (byte)length;
                     Pool.ByteUpto += length + 1;
                     Debug.Assert(length >= 0, "Length must be positive: " + length);
                     Array.Copy(bytes.Bytes, bytes.Offset, buffer, bufferUpto + 1, length);
@@ -347,8 +347,8 @@ namespace Lucene.Net.Util
                 else
                 {
                     // 2 byte to store length
-                    buffer[bufferUpto] = unchecked((sbyte)(0x80 | (length & 0x7f)));
-                    buffer[bufferUpto + 1] = unchecked((sbyte)((length >> 7) & 0xff));
+                    buffer[bufferUpto] = unchecked((byte)(0x80 | (length & 0x7f)));
+                    buffer[bufferUpto + 1] = unchecked((byte)((length >> 7) & 0xff));
                     Pool.ByteUpto += length + 2;
                     Array.Copy(bytes.Bytes, bytes.Offset, buffer, bufferUpto + 2, length);
                 }
@@ -469,7 +469,7 @@ namespace Lucene.Net.Util
                     {
                         int off = BytesStart[e0];
                         int start = off & ByteBlockPool.BYTE_BLOCK_MASK;
-                        sbyte[] bytes = Pool.Buffers[off >> ByteBlockPool.BYTE_BLOCK_SHIFT];
+                        var bytes = Pool.Buffers[off >> ByteBlockPool.BYTE_BLOCK_SHIFT];
                         int len;
                         int pos;
                         if ((bytes[start] & 0x80) == 0)
@@ -514,7 +514,7 @@ namespace Lucene.Net.Util
         }
 
         // TODO: maybe use long?  But our keys are typically short...
-        private int DoHash(sbyte[] bytes, int offset, int length)
+        private static int DoHash(byte[] bytes, int offset, int length)
         {
             return StringHelper.Murmurhash3_x86_32(bytes, offset, length, StringHelper.GOOD_FAST_HASH_SEED);
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
index 51ac203..9be4680 100644
--- a/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
+++ b/src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs
@@ -129,7 +129,7 @@ namespace Lucene.Net.Util.Fst
             }
             set
             {
-                Current_Renamed.Bytes[Upto] = (sbyte)value;
+                Current_Renamed.Bytes[Upto] = (byte)value;
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Fst/FST.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/FST.cs b/src/Lucene.Net.Core/Util/Fst/FST.cs
index 86608ed..4f5596b 100644
--- a/src/Lucene.Net.Core/Util/Fst/FST.cs
+++ b/src/Lucene.Net.Core/Util/Fst/FST.cs
@@ -507,7 +507,7 @@ namespace Lucene.Net.Util.Fst
                 RAMOutputStream ros = new RAMOutputStream();
                 Outputs.WriteFinalOutput(emptyOutput, ros);
 
-                sbyte[] emptyOutputBytes = new sbyte[(int)ros.FilePointer];
+                var emptyOutputBytes = new byte[(int)ros.FilePointer];
                 ros.WriteTo(emptyOutputBytes, 0);
 
                 if (!Packed)
@@ -517,7 +517,7 @@ namespace Lucene.Net.Util.Fst
                     int upto = 0;
                     while (upto < stopAt)
                     {
-                        sbyte b = emptyOutputBytes[upto];
+                        var b = emptyOutputBytes[upto];
                         emptyOutputBytes[upto] = emptyOutputBytes[emptyOutputBytes.Length - upto - 1];
                         emptyOutputBytes[emptyOutputBytes.Length - upto - 1] = b;
                         upto++;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Fst/Util.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Fst/Util.cs b/src/Lucene.Net.Core/Util/Fst/Util.cs
index 4c15642..46260e9 100644
--- a/src/Lucene.Net.Core/Util/Fst/Util.cs
+++ b/src/Lucene.Net.Core/Util/Fst/Util.cs
@@ -1041,7 +1041,7 @@ namespace Lucene.Net.Util.Fst
                 int value = input.Ints[i + input.Offset];
                 // NOTE: we allow -128 to 255
                 Debug.Assert(value >= sbyte.MinValue && value <= 255, "value " + value + " doesn't fit into byte");
-                scratch.Bytes[i] = (sbyte)value;
+                scratch.Bytes[i] = (byte)value;
             }
             scratch.Length = input.Length;
             return scratch;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/GrowableByteArrayDataOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/GrowableByteArrayDataOutput.cs b/src/Lucene.Net.Core/Util/GrowableByteArrayDataOutput.cs
index 5a2b51b..0525b7f 100644
--- a/src/Lucene.Net.Core/Util/GrowableByteArrayDataOutput.cs
+++ b/src/Lucene.Net.Core/Util/GrowableByteArrayDataOutput.cs
@@ -27,7 +27,7 @@ namespace Lucene.Net.Util
     {
         /// <summary>
         /// The bytes </summary>
-        public sbyte[] Bytes;
+        public byte[] Bytes;
 
         /// <summary>
         /// The length </summary>
@@ -37,7 +37,7 @@ namespace Lucene.Net.Util
         /// Create a <seealso cref="GrowableByteArrayDataOutput"/> with the given initial capacity. </summary>
         public GrowableByteArrayDataOutput(int cp)
         {
-            this.Bytes = new sbyte[ArrayUtil.Oversize(cp, 1)];
+            this.Bytes = new byte[ArrayUtil.Oversize(cp, 1)];
             this.Length = 0;
         }
 
@@ -47,7 +47,7 @@ namespace Lucene.Net.Util
             {
                 Bytes = ArrayUtil.Grow(Bytes);
             }
-            Bytes[Length++] = (sbyte)b;
+            Bytes[Length++] = b;
         }
 
         public override void WriteBytes(byte[] b, int off, int len)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/NumericUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/NumericUtils.cs b/src/Lucene.Net.Core/Util/NumericUtils.cs
index 41ce83a..a806358 100644
--- a/src/Lucene.Net.Core/Util/NumericUtils.cs
+++ b/src/Lucene.Net.Core/Util/NumericUtils.cs
@@ -148,16 +148,16 @@ namespace Lucene.Net.Util
             bytes.Length = nChars + 1; // one extra for the byte that contains the shift info
             if (bytes.Bytes.Length < bytes.Length)
             {
-                bytes.Bytes = new sbyte[NumericUtils.BUF_SIZE_LONG]; // use the max
+                bytes.Bytes = new byte[NumericUtils.BUF_SIZE_LONG]; // use the max
             }
-            bytes.Bytes[0] = (sbyte)(SHIFT_START_LONG + shift);
+            bytes.Bytes[0] = (byte)(SHIFT_START_LONG + shift);
             ulong sortableBits = BitConverter.ToUInt64(BitConverter.GetBytes(val), 0) ^ 0x8000000000000000L;
             sortableBits = sortableBits >> shift;
             while (nChars > 0)
             {
                 // Store 7 bits per byte for compatibility
                 // with UTF-8 encoding of terms
-                bytes.Bytes[nChars--] = (sbyte)(sortableBits & 0x7f);
+                bytes.Bytes[nChars--] = (byte)(sortableBits & 0x7f);
                 sortableBits = sortableBits >> 7;
             }
         }
@@ -180,16 +180,16 @@ namespace Lucene.Net.Util
             bytes.Length = nChars + 1; // one extra for the byte that contains the shift info
             if (bytes.Bytes.Length < bytes.Length)
             {
-                bytes.Bytes = new sbyte[NumericUtils.BUF_SIZE_LONG]; // use the max
+                bytes.Bytes = new byte[NumericUtils.BUF_SIZE_LONG]; // use the max
             }
-            bytes.Bytes[0] = (sbyte)(SHIFT_START_INT + shift);
+            bytes.Bytes[0] = (byte)(SHIFT_START_INT + shift);
             int sortableBits = val ^ unchecked((int)0x80000000);
             sortableBits = Number.URShift(sortableBits, shift);
             while (nChars > 0)
             {
                 // Store 7 bits per byte for compatibility
                 // with UTF-8 encoding of terms
-                bytes.Bytes[nChars--] = (sbyte)(sortableBits & 0x7f);
+                bytes.Bytes[nChars--] = (byte)(sortableBits & 0x7f);
                 sortableBits = (int)((uint)sortableBits >> 7);
             }
         }
@@ -235,7 +235,7 @@ namespace Lucene.Net.Util
             for (int i = val.Offset + 1, limit = val.Offset + val.Length; i < limit; i++)
             {
                 sortableBits <<= 7;
-                sbyte b = val.Bytes[i];
+                var b = val.Bytes[i];
                 if (b < 0)
                 {
                     throw new System.FormatException("Invalid prefixCoded numerical value representation (byte " + (b & 0xff).ToString("x") + " at position " + (i - val.Offset) + " is invalid)");
@@ -258,12 +258,12 @@ namespace Lucene.Net.Util
             for (int i = val.Offset, limit = val.Offset + val.Length; i < limit; i++)
             {
                 sortableBits <<= 7;
-                sbyte b = val.Bytes[i];
+                var b = val.Bytes[i];
                 if (b < 0)
                 {
                     throw new System.FormatException("Invalid prefixCoded numerical value representation (byte " + (b & 0xff).ToString("x") + " at position " + (i - val.Offset) + " is invalid)");
                 }
-                sortableBits |= (byte)b;
+                sortableBits |= (sbyte)b;
             }
             return (int)((sortableBits << GetPrefixCodedIntShift(val)) ^ 0x80000000);
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/OpenBitSetIterator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/OpenBitSetIterator.cs b/src/Lucene.Net.Core/Util/OpenBitSetIterator.cs
index 8f3fc3d..dda1433 100644
--- a/src/Lucene.Net.Core/Util/OpenBitSetIterator.cs
+++ b/src/Lucene.Net.Core/Util/OpenBitSetIterator.cs
@@ -68,7 +68,7 @@ namespace Lucene.Net.Util
                 WordShift += 8;
                 Word = (long)((ulong)Word >> 8);
             }
-            IndexArray = BitUtil.BitList((sbyte)Word);
+            IndexArray = BitUtil.BitList((byte)Word);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs b/src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs
index 41677c8..e385989 100644
--- a/src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs
+++ b/src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs
@@ -326,7 +326,7 @@ namespace Lucene.Net.Util
                 }
 
                 EncodeBlock();
-                sbyte[] dataArr = Arrays.CopyOf(Data.Bytes, Data.Length + MAX_BYTE_BLOCK_COUNT);
+                var dataArr = Arrays.CopyOf(Data.Bytes, Data.Length + MAX_BYTE_BLOCK_COUNT);
 
                 int indexSize = (NumBlocks - 1) / IndexInterval_Renamed + 1;
                 MonotonicAppendingLongBuffer docIDs, offsets;
@@ -365,11 +365,11 @@ namespace Lucene.Net.Util
             }
         }
 
-        internal readonly sbyte[] Data;
+        internal readonly byte[] Data;
         internal readonly MonotonicAppendingLongBuffer DocIDs, Offsets; // for the index
         internal readonly int Cardinality_Renamed, IndexInterval;
 
-        internal PForDeltaDocIdSet(sbyte[] data, int cardinality, int indexInterval, MonotonicAppendingLongBuffer docIDs, MonotonicAppendingLongBuffer offsets)
+        internal PForDeltaDocIdSet(byte[] data, int cardinality, int indexInterval, MonotonicAppendingLongBuffer docIDs, MonotonicAppendingLongBuffer offsets)
         {
             this.Data = data;
             this.Cardinality_Renamed = cardinality;
@@ -406,7 +406,7 @@ namespace Lucene.Net.Util
             internal readonly MonotonicAppendingLongBuffer DocIDs, Offsets;
 
             internal readonly int Cardinality;
-            internal readonly sbyte[] Data;
+            internal readonly byte[] Data;
             internal int Offset; // offset in data
 
             internal readonly int[] NextDocs;
@@ -417,7 +417,7 @@ namespace Lucene.Net.Util
             internal int BlockIdx;
             internal int DocID_Renamed;
 
-            internal Iterator(sbyte[] data, int cardinality, int indexInterval, MonotonicAppendingLongBuffer docIDs, MonotonicAppendingLongBuffer offsets)
+            internal Iterator(byte[] data, int cardinality, int indexInterval, MonotonicAppendingLongBuffer docIDs, MonotonicAppendingLongBuffer offsets)
             {
                 this.Data = data;
                 this.Cardinality = cardinality;
@@ -438,7 +438,7 @@ namespace Lucene.Net.Util
                 return DocID_Renamed;
             }
 
-            internal virtual void PforDecompress(sbyte token)
+            internal virtual void PforDecompress(byte token)
             {
                 int bitsPerValue = token & 0x1F;
                 if (bitsPerValue == 0)
@@ -470,13 +470,13 @@ namespace Lucene.Net.Util
                 }
             }
 
-            internal virtual void UnaryDecompress(sbyte token)
+            internal virtual void UnaryDecompress(byte token)
             {
                 Debug.Assert((token & HAS_EXCEPTIONS) == 0);
                 int docID = this.DocID_Renamed;
                 for (int i = 0; i < BLOCK_SIZE; )
                 {
-                    sbyte b = Data[Offset++];
+                    var b = Data[Offset++];
                     for (int bitList = BitUtil.BitList(b); bitList != 0; ++i, bitList = (int)((uint)bitList >> 4))
                     {
                         NextDocs[i] = docID + (bitList & 0x0F);
@@ -487,7 +487,7 @@ namespace Lucene.Net.Util
 
             internal virtual void DecompressBlock()
             {
-                sbyte token = Data[Offset++];
+                var token = Data[Offset++];
 
                 if ((token & UNARY) != 0)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs b/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs
index b05d687..1868b79 100644
--- a/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs
+++ b/src/Lucene.Net.Core/Util/Packed/AbstractBlockPackedWriter.cs
@@ -50,7 +50,7 @@ namespace Lucene.Net.Util.Packed
 
         protected internal DataOutput @out;
         protected internal readonly long[] Values;
-        protected internal sbyte[] Blocks;
+        protected internal byte[] Blocks;
         protected internal int Off;
         protected internal long Ord_Renamed;
         protected internal bool Finished;
@@ -145,7 +145,7 @@ namespace Lucene.Net.Util.Packed
             int blockSize = encoder.ByteBlockCount() * iterations;
             if (Blocks == null || Blocks.Length < blockSize)
             {
-                Blocks = new sbyte[blockSize];
+                Blocks = new byte[blockSize];
             }
             if (Off < Values.Length)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs b/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs
index 5c9c402..9a4fb51 100644
--- a/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BlockPackedReaderIterator.cs
@@ -98,7 +98,7 @@ namespace Lucene.Net.Util.Packed
         internal readonly int BlockSize;
         internal readonly long[] Values;
         internal readonly LongsRef ValuesRef;
-        internal sbyte[] Blocks;
+        internal byte[] Blocks;
         internal int Off;
         internal long Ord_Renamed;
 
@@ -192,7 +192,7 @@ namespace Lucene.Net.Util.Packed
             {
                 if (Blocks == null)
                 {
-                    Blocks = new sbyte[BlockSize];
+                    Blocks = new byte[BlockSize];
                 }
                 long skipped = 0;
                 while (skipped < count)
@@ -268,7 +268,7 @@ namespace Lucene.Net.Util.Packed
                 int blocksSize = iterations * decoder.ByteBlockCount();
                 if (Blocks == null || Blocks.Length < blocksSize)
                 {
-                    Blocks = new sbyte[blocksSize];
+                    Blocks = new byte[blocksSize];
                 }
 
                 int valueCount = (int)Math.Min(this.ValueCount - Ord_Renamed, BlockSize);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs
index 6826bef..8d58411 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperation.cs
@@ -27,19 +27,19 @@ namespace Lucene.Net.Util.Packed
     /// </summary>
     internal abstract class BulkOperation : PackedInts.Decoder, PackedInts.Encoder
     {
-        public abstract void Encode(int[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations);
+        public abstract void Encode(int[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations);
 
         public abstract void Encode(int[] values, int valuesOffset, long[] blocks, int blocksOffset, int iterations);
 
-        public abstract void Encode(long[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations);
+        public abstract void Encode(long[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations);
 
         public abstract void Encode(long[] values, int valuesOffset, long[] blocks, int blocksOffset, int iterations);
 
-        public abstract void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations);
+        public abstract void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations);
 
         public abstract void Decode(long[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations);
 
-        public abstract void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations);
+        public abstract void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations);
 
         public abstract void Decode(long[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations);
 
@@ -74,11 +74,11 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        protected internal virtual int WriteLong(long block, sbyte[] blocks, int blocksOffset)
+        protected internal virtual int WriteLong(long block, byte[] blocks, int blocksOffset)
         {
             for (int j = 1; j <= 8; ++j)
             {
-                blocks[blocksOffset++] = (sbyte)((long)((ulong)block >> (64 - (j << 3))));
+                blocks[blocksOffset++] = (byte)((long)((ulong)block >> (64 - (j << 3))));
             }
             return blocksOffset;
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs
index dc564ca..3214d0b 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked.cs
@@ -102,7 +102,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             long nextValue = 0L;
             int bitsLeft = BitsPerValue;
@@ -155,7 +155,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             int nextValue = 0;
             int bitsLeft = BitsPerValue;
@@ -242,7 +242,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Encode(long[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations)
+        public override void Encode(long[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations)
         {
             int nextBlock = 0;
             int bitsLeft = 8;
@@ -260,11 +260,11 @@ namespace Lucene.Net.Util.Packed
                 {
                     // flush as many blocks as possible
                     int bits = BitsPerValue - bitsLeft;
-                    blocks[blocksOffset++] = (sbyte)(nextBlock | ((long)((ulong)v >> bits)));
+                    blocks[blocksOffset++] = (byte)(nextBlock | ((long)((ulong)v >> bits)));
                     while (bits >= 8)
                     {
                         bits -= 8;
-                        blocks[blocksOffset++] = (sbyte)((long)((ulong)v >> bits));
+                        blocks[blocksOffset++] = (byte)((long)((ulong)v >> bits));
                     }
                     // then buffer
                     bitsLeft = 8 - bits;
@@ -274,7 +274,7 @@ namespace Lucene.Net.Util.Packed
             Debug.Assert(bitsLeft == 8);
         }
 
-        public override void Encode(int[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations)
+        public override void Encode(int[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations)
         {
             int nextBlock = 0;
             int bitsLeft = 8;
@@ -292,11 +292,11 @@ namespace Lucene.Net.Util.Packed
                 {
                     // flush as many blocks as possible
                     int bits = BitsPerValue - bitsLeft;
-                    blocks[blocksOffset++] = (sbyte)(nextBlock | ((int)((uint)v >> bits)));
+                    blocks[blocksOffset++] = (byte)(nextBlock | ((int)((uint)v >> bits)));
                     while (bits >= 8)
                     {
                         bits -= 8;
-                        blocks[blocksOffset++] = (sbyte)((int)((uint)v >> bits));
+                        blocks[blocksOffset++] = (byte)((int)((uint)v >> bits));
                     }
                     // then buffer
                     bitsLeft = 8 - bits;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked1.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked1.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked1.cs
index a8101e8..76c53e1 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked1.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked1.cs
@@ -41,11 +41,11 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
-                sbyte block = blocks[blocksOffset++];
+                var block = blocks[blocksOffset++];
                 values[valuesOffset++] = ((int)((uint)block >> 7)) & 1;
                 values[valuesOffset++] = ((int)((uint)block >> 6)) & 1;
                 values[valuesOffset++] = ((int)((uint)block >> 5)) & 1;
@@ -69,11 +69,11 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
-                sbyte block = blocks[blocksOffset++];
+                var block = blocks[blocksOffset++];
                 values[valuesOffset++] = ((int)((uint)block >> 7)) & 1;
                 values[valuesOffset++] = ((int)((uint)block >> 6)) & 1;
                 values[valuesOffset++] = ((int)((uint)block >> 5)) & 1;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked10.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked10.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked10.cs
index 3b30e44..521d7b6 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked10.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked10.cs
@@ -73,7 +73,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -133,7 +133,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked11.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked11.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked11.cs
index 26189d7..f19f299 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked11.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked11.cs
@@ -111,7 +111,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -219,7 +219,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked12.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked12.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked12.cs
index f204b7c..c72492d 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked12.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked12.cs
@@ -55,7 +55,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -93,7 +93,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked13.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked13.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked13.cs
index f650464..c1f3f75 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked13.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked13.cs
@@ -113,7 +113,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -225,7 +225,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked14.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked14.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked14.cs
index db5a5e3..a8847ce 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked14.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked14.cs
@@ -75,7 +75,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -139,7 +139,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked15.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked15.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked15.cs
index e9f645b..dd8ef4e 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked15.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked15.cs
@@ -115,7 +115,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -231,7 +231,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked16.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked16.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked16.cs
index 8a54331..01c4bcf 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked16.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked16.cs
@@ -41,7 +41,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
@@ -61,7 +61,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked17.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked17.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked17.cs
index 0fda078..2fc2ff1 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked17.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked17.cs
@@ -117,7 +117,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -237,7 +237,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked18.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked18.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked18.cs
index edef331..6ed22d4 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked18.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked18.cs
@@ -77,7 +77,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -145,7 +145,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked19.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked19.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked19.cs
index 60d13c2..ed52c91 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked19.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked19.cs
@@ -119,7 +119,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -243,7 +243,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked2.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked2.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked2.cs
index 88bdb32..713b0fe 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked2.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked2.cs
@@ -41,11 +41,11 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
-                sbyte block = blocks[blocksOffset++];
+                var block = blocks[blocksOffset++];
                 values[valuesOffset++] = ((int)((uint)block >> 6)) & 3;
                 values[valuesOffset++] = ((int)((uint)block >> 4)) & 3;
                 values[valuesOffset++] = ((int)((uint)block >> 2)) & 3;
@@ -65,11 +65,11 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
-                sbyte block = blocks[blocksOffset++];
+                var block = blocks[blocksOffset++];
                 values[valuesOffset++] = ((int)((uint)block >> 6)) & 3;
                 values[valuesOffset++] = ((int)((uint)block >> 4)) & 3;
                 values[valuesOffset++] = ((int)((uint)block >> 2)) & 3;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked20.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked20.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked20.cs
index 9869374..95f7873 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked20.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked20.cs
@@ -57,7 +57,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -99,7 +99,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked21.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked21.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked21.cs
index ab524ce..d5daa92 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked21.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked21.cs
@@ -121,7 +121,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -249,7 +249,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked22.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked22.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked22.cs
index 76ff7b2..6f2ead3 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked22.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked22.cs
@@ -79,7 +79,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -151,7 +151,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked23.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked23.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked23.cs
index 38fdbe5..edca46c 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked23.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked23.cs
@@ -123,7 +123,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -255,7 +255,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked24.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked24.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked24.cs
index 2e0f9de..c8178c3 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked24.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked24.cs
@@ -47,7 +47,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -76,7 +76,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked3.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked3.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked3.cs
index 6f2abd6..ab99609 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked3.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked3.cs
@@ -103,7 +103,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -195,7 +195,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked4.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked4.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked4.cs
index 2f49b31..0c5279e 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked4.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked4.cs
@@ -41,11 +41,11 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
-                sbyte block = blocks[blocksOffset++];
+                var block = blocks[blocksOffset++];
                 values[valuesOffset++] = ((int)((uint)block >> 4)) & 15;
                 values[valuesOffset++] = block & 15;
             }
@@ -63,11 +63,11 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
-                sbyte block = blocks[blocksOffset++];
+                var block = blocks[blocksOffset++];
                 values[valuesOffset++] = ((int)((uint)block >> 4)) & 15;
                 values[valuesOffset++] = block & 15;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked5.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked5.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked5.cs
index c2fcb5b..ff32c4f 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked5.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked5.cs
@@ -105,7 +105,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -201,7 +201,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked6.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked6.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked6.cs
index 68a32da..6450d7a 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked6.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked6.cs
@@ -71,7 +71,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -127,7 +127,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked7.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked7.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked7.cs
index 2e93305..9ad7361 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked7.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked7.cs
@@ -107,7 +107,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -207,7 +207,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked8.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked8.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked8.cs
index 6acc676..fe96aba 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked8.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked8.cs
@@ -41,7 +41,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {
@@ -61,7 +61,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int j = 0; j < iterations; ++j)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked9.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked9.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked9.cs
index a6d099c..5d73724 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked9.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPacked9.cs
@@ -109,7 +109,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -213,7 +213,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {


[5/5] lucenenet git commit: Bring ByteSequencesWriter back in

Posted by sy...@apache.org.
Bring ByteSequencesWriter back in


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

Branch: refs/heads/master
Commit: ee575336c5322b926cef2ddc4d556eb5b0709828
Parents: 139ad81
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Mon Nov 10 17:25:17 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Mon Nov 10 17:25:17 2014 +0200

----------------------------------------------------------------------
 src/Lucene.Net.Core/Lucene.Net.csproj           |   1 +
 .../Compatibility/BinaryWriterDataOutput.cs     |  31 +++++
 src/Lucene.Net.Core/Util/OfflineSorter.cs       | 134 ++++++++++---------
 3 files changed, 100 insertions(+), 66 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ee575336/src/Lucene.Net.Core/Lucene.Net.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.csproj b/src/Lucene.Net.Core/Lucene.Net.csproj
index 58a6c8a..1e8b3a0 100644
--- a/src/Lucene.Net.Core/Lucene.Net.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.csproj
@@ -617,6 +617,7 @@
     <Compile Include="Support\ByteBuffer.cs" />
     <Compile Include="Support\Character.cs" />
     <Compile Include="Support\Arrays.cs" />
+    <Compile Include="Support\Compatibility\BinaryWriterDataOutput.cs" />
     <Compile Include="Support\Compatibility\Collections.cs" />
     <Compile Include="Support\ConcurrentHashMap.cs" />
     <Compile Include="Support\ConcurrentHashMapWrapper.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ee575336/src/Lucene.Net.Core/Support/Compatibility/BinaryWriterDataOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Compatibility/BinaryWriterDataOutput.cs b/src/Lucene.Net.Core/Support/Compatibility/BinaryWriterDataOutput.cs
new file mode 100644
index 0000000..31e5b07
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/Compatibility/BinaryWriterDataOutput.cs
@@ -0,0 +1,31 @@
+using System;
+using System.IO;
+using Lucene.Net.Store;
+
+namespace Lucene.Net.Support.Compatibility
+{
+    public class BinaryWriterDataOutput : DataOutput, IDisposable
+    {
+        private readonly BinaryWriter bw;
+
+        public BinaryWriterDataOutput(BinaryWriter bw)
+        {
+            this.bw = bw;
+        }
+
+        public override void WriteByte(byte b)
+        {
+            bw.Write(b);
+        }
+
+        public override void WriteBytes(byte[] b, int offset, int length)
+        {
+            bw.Write(b, offset, length);
+        }
+
+        public void Dispose()
+        {
+            bw.Dispose();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ee575336/src/Lucene.Net.Core/Util/OfflineSorter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/OfflineSorter.cs b/src/Lucene.Net.Core/Util/OfflineSorter.cs
index 4f72585..db6db48 100644
--- a/src/Lucene.Net.Core/Util/OfflineSorter.cs
+++ b/src/Lucene.Net.Core/Util/OfflineSorter.cs
@@ -2,6 +2,8 @@ using System;
 using System.Collections.Generic;
 using System.Diagnostics;
 using System.IO;
+using Lucene.Net.Store;
+using Lucene.Net.Support.Compatibility;
 
 namespace Lucene.Net.Util
 {
@@ -512,72 +514,72 @@ namespace Lucene.Net.Util
 //            }
 //        }
 //
-//        /// <summary>
-//        /// Utility class to emit length-prefixed byte[] entries to an output stream for sorting.
-//        /// Complementary to <seealso cref="ByteSequencesReader"/>.
-//        /// </summary>
-//        public class ByteSequencesWriter : IDisposable
-//        {
-//            internal readonly DataOutput Os;
-//
-//            /// <summary>
-//            /// Constructs a ByteSequencesWriter to the provided File </summary>
-//            public ByteSequencesWriter(FileInfo file)
-//                : this(new DataOutputStream(new BufferedOutputStream(new FileOutputStream(file))))
-//            {
-//            }
-//
-//            /// <summary>
-//            /// Constructs a ByteSequencesWriter to the provided DataOutput </summary>
-//            public ByteSequencesWriter(DataOutput os)
-//            {
-//                this.Os = os;
-//            }
-//
-//            /// <summary>
-//            /// Writes a BytesRef. </summary>
-//            /// <seealso cref= #write(byte[], int, int) </seealso>
-//            public virtual void Write(BytesRef @ref)
-//            {
-//                Debug.Assert(@ref != null);
-//                Write(@ref.Bytes, @ref.Offset, @ref.Length);
-//            }
-//
-//            /// <summary>
-//            /// Writes a byte array. </summary>
-//            /// <seealso cref= #write(byte[], int, int) </seealso>
-//            public virtual void Write(sbyte[] bytes)
-//            {
-//                Write(bytes, 0, bytes.Length);
-//            }
-//
-//            /// <summary>
-//            /// Writes a byte array.
-//            /// <p>
-//            /// The length is written as a <code>short</code>, followed
-//            /// by the bytes.
-//            /// </summary>
-//            public virtual void Write(sbyte[] bytes, int off, int len)
-//            {
-//                Debug.Assert(bytes != null);
-//                Debug.Assert(off >= 0 && off + len <= bytes.Length);
-//                Debug.Assert(len >= 0);
-//                Os.WriteShort(len);
-//                Os.Write(bytes, off, len);
-//            }
-//
-//            /// <summary>
-//            /// Closes the provided <seealso cref="DataOutput"/> if it is <seealso cref="IDisposable"/>.
-//            /// </summary>
-//            public void Dispose()
-//            {
-//                var os = Os as IDisposable;
-//                if (os != null)
-//                {
-//                    os.Dispose();
-//                }
-//            }
-//        }
+        /// <summary>
+        /// Utility class to emit length-prefixed byte[] entries to an output stream for sorting.
+        /// Complementary to <seealso cref="ByteSequencesReader"/>.
+        /// </summary>
+        public class ByteSequencesWriter : IDisposable
+        {
+            internal readonly DataOutput Os;
+
+            /// <summary>
+            /// Constructs a ByteSequencesWriter to the provided File </summary>
+            public ByteSequencesWriter(string filePath)
+                : this(new BinaryWriterDataOutput(new BinaryWriter(new FileStream(filePath, FileMode.Open))))
+            {
+            }
+
+            /// <summary>
+            /// Constructs a ByteSequencesWriter to the provided DataOutput </summary>
+            public ByteSequencesWriter(DataOutput os)
+            {
+                this.Os = os;
+            }
+
+            /// <summary>
+            /// Writes a BytesRef. </summary>
+            /// <seealso cref= #write(byte[], int, int) </seealso>
+            public virtual void Write(BytesRef @ref)
+            {
+                Debug.Assert(@ref != null);
+                Write(@ref.Bytes, @ref.Offset, @ref.Length);
+            }
+
+            /// <summary>
+            /// Writes a byte array. </summary>
+            /// <seealso cref= #write(byte[], int, int) </seealso>
+            public virtual void Write(byte[] bytes)
+            {
+                Write(bytes, 0, bytes.Length);
+            }
+
+            /// <summary>
+            /// Writes a byte array.
+            /// <p>
+            /// The length is written as a <code>short</code>, followed
+            /// by the bytes.
+            /// </summary>
+            public virtual void Write(byte[] bytes, int off, int len)
+            {
+                Debug.Assert(bytes != null);
+                Debug.Assert(off >= 0 && off + len <= bytes.Length);
+                Debug.Assert(len >= 0);
+                Os.WriteShort((short)len);
+                Os.Write(bytes, off, len);
+            }
+
+            /// <summary>
+            /// Closes the provided <seealso cref="DataOutput"/> if it is <seealso cref="IDisposable"/>.
+            /// </summary>
+            public void Dispose()
+            {
+                var os = Os as IDisposable;
+                if (os != null)
+                {
+                    os.Dispose();
+                }
+            }
+        }
 //
 //        /// <summary>
 //        /// Utility class to read length-prefixed byte[] entries from an input.


[4/5] lucenenet git commit: Getting rid of most sbyte usage in public API

Posted by sy...@apache.org.
Getting rid of most sbyte usage in public API

(unsigned) byte is the native C# type and what we should support really, and also for CLS compliance


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

Branch: refs/heads/master
Commit: 139ad812a8079e865733ad13a52682dd333ebee9
Parents: a159335
Author: Itamar Syn-Hershko <it...@code972.com>
Authored: Mon Nov 10 17:24:49 2014 +0200
Committer: Itamar Syn-Hershko <it...@code972.com>
Committed: Mon Nov 10 17:24:49 2014 +0200

----------------------------------------------------------------------
 .../Codecs/BlockTreeTermsReader.cs              | 10 +--
 .../Codecs/BlockTreeTermsWriter.cs              |  4 +-
 .../CompressingStoredFieldsReader.cs            |  4 +-
 .../Compressing/CompressingTermVectorsWriter.cs |  2 +-
 .../Codecs/Compressing/CompressionMode.cs       | 14 ++--
 .../Codecs/Compressing/Compressor.cs            |  2 +-
 src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs   | 33 ++++-----
 .../Codecs/Lucene3x/Lucene3xFields.cs           | 56 +++++++--------
 .../Lucene3x/Lucene3xStoredFieldsReader.cs      |  4 +-
 .../Codecs/Lucene40/Lucene40DocValuesReader.cs  |  2 +-
 .../Codecs/Lucene40/Lucene40PostingsReader.cs   |  2 +-
 .../Lucene40/Lucene40StoredFieldsReader.cs      |  2 +-
 .../Lucene40/Lucene40TermVectorsReader.cs       | 32 ++++-----
 src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs  |  7 +-
 .../Codecs/Lucene41/Lucene41PostingsReader.cs   | 16 ++---
 .../Codecs/Lucene41/Lucene41PostingsWriter.cs   |  4 +-
 .../Lucene42/Lucene42DocValuesProducer.cs       |  6 +-
 .../Lucene45/Lucene45DocValuesProducer.cs       |  6 +-
 src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs |  2 +-
 .../Document/CompressionTools.cs                | 28 ++++----
 .../Document/DocumentStoredFieldVisitor.cs      |  2 +-
 src/Lucene.Net.Core/Document/Field.cs           | 30 ++------
 src/Lucene.Net.Core/Document/StoredField.cs     |  4 +-
 src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs | 10 +--
 src/Lucene.Net.Core/Index/ByteSliceReader.cs    |  2 +-
 src/Lucene.Net.Core/Index/ByteSliceWriter.cs    |  6 +-
 .../Index/FreqProxTermsWriterPerField.cs        |  2 +-
 .../Index/SortedDocValuesTermsEnum.cs           |  4 +-
 .../Index/SortedSetDocValuesTermsEnum.cs        |  4 +-
 src/Lucene.Net.Core/Index/StoredFieldVisitor.cs |  2 +-
 src/Lucene.Net.Core/Index/TermsHashPerField.cs  |  9 ++-
 src/Lucene.Net.Core/Search/FieldComparator.cs   |  4 +-
 .../Search/Payloads/PayloadNearQuery.cs         | 27 ++++---
 .../Search/Payloads/PayloadSpanUtil.cs          | 15 ++--
 .../Search/Spans/NearSpansOrdered.cs            | 20 +++---
 .../Search/Spans/NearSpansUnordered.cs          | 10 +--
 .../Search/Spans/SpanNearPayloadCheckQuery.cs   | 12 ++--
 .../Search/Spans/SpanNotQuery.cs                | 10 +--
 src/Lucene.Net.Core/Search/Spans/SpanOrQuery.cs |  6 +-
 .../Search/Spans/SpanPayloadCheckQuery.cs       | 12 ++--
 .../Search/Spans/SpanPositionCheckQuery.cs      |  8 +--
 src/Lucene.Net.Core/Search/Spans/Spans.cs       |  3 +-
 src/Lucene.Net.Core/Search/Spans/TermSpans.cs   | 10 +--
 src/Lucene.Net.Core/Store/DataOutput.cs         |  9 ++-
 src/Lucene.Net.Core/Store/FSDirectory.cs        |  2 +-
 .../Store/NativeFSLockFactory.cs                |  2 +-
 src/Lucene.Net.Core/Store/RAMOutputStream.cs    |  2 +-
 src/Lucene.Net.Core/Support/StringSupport.cs    |  5 +-
 src/Lucene.Net.Core/Util/ArrayUtil.cs           | 13 ++--
 .../Util/Automaton/ByteRunAutomaton.cs          |  8 +--
 .../Util/Automaton/CompiledAutomaton.cs         | 10 +--
 .../Util/Automaton/SpecialOperations.cs         |  4 +-
 src/Lucene.Net.Core/Util/BitUtil.cs             | 12 +---
 src/Lucene.Net.Core/Util/ByteBlockPool.cs       | 52 +++++++-------
 src/Lucene.Net.Core/Util/BytesRef.cs            | 28 ++++----
 src/Lucene.Net.Core/Util/BytesRefHash.cs        | 12 ++--
 src/Lucene.Net.Core/Util/Fst/BytesRefFSTEnum.cs |  2 +-
 src/Lucene.Net.Core/Util/Fst/FST.cs             |  4 +-
 src/Lucene.Net.Core/Util/Fst/Util.cs            |  2 +-
 .../Util/GrowableByteArrayDataOutput.cs         |  6 +-
 src/Lucene.Net.Core/Util/NumericUtils.cs        | 18 ++---
 src/Lucene.Net.Core/Util/OpenBitSetIterator.cs  |  2 +-
 src/Lucene.Net.Core/Util/PForDeltaDocIdSet.cs   | 18 ++---
 .../Util/Packed/AbstractBlockPackedWriter.cs    |  4 +-
 .../Util/Packed/BlockPackedReaderIterator.cs    |  6 +-
 .../Util/Packed/BulkOperation.cs                | 12 ++--
 .../Util/Packed/BulkOperationPacked.cs          | 16 ++---
 .../Util/Packed/BulkOperationPacked1.cs         |  8 +--
 .../Util/Packed/BulkOperationPacked10.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked11.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked12.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked13.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked14.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked15.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked16.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked17.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked18.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked19.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked2.cs         |  8 +--
 .../Util/Packed/BulkOperationPacked20.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked21.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked22.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked23.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked24.cs        |  4 +-
 .../Util/Packed/BulkOperationPacked3.cs         |  4 +-
 .../Util/Packed/BulkOperationPacked4.cs         |  8 +--
 .../Util/Packed/BulkOperationPacked5.cs         |  4 +-
 .../Util/Packed/BulkOperationPacked6.cs         |  4 +-
 .../Util/Packed/BulkOperationPacked7.cs         |  4 +-
 .../Util/Packed/BulkOperationPacked8.cs         |  4 +-
 .../Util/Packed/BulkOperationPacked9.cs         |  4 +-
 .../Packed/BulkOperationPackedSingleBlock.cs    | 15 ++--
 src/Lucene.Net.Core/Util/Packed/PackedInts.cs   |  8 +--
 .../Util/Packed/PackedReaderIterator.cs         |  6 +-
 src/Lucene.Net.Core/Util/Packed/PackedWriter.cs |  4 +-
 src/Lucene.Net.Core/Util/PagedBytes.cs          | 48 ++++++-------
 .../Util/RecyclingByteBlockAllocator.cs         | 14 ++--
 src/Lucene.Net.Core/Util/StringHelper.cs        | 14 ++--
 src/Lucene.Net.Core/Util/ToStringUtils.cs       |  2 +-
 src/Lucene.Net.Core/Util/UnicodeUtil.cs         | 75 ++++++++++----------
 src/Lucene.Net.Queries/TermsFilter.cs           |  4 +-
 .../Analysis/MockFixedLengthPayloadFilter.cs    |  4 +-
 .../Analysis/MockUTF16TermAttributeImpl.cs      |  2 +-
 .../Analysis/MockVariableLengthPayloadFilter.cs |  2 +-
 .../compressing/dummy/DummyCompressingCodec.cs  |  4 +-
 .../lucene42/Lucene42DocValuesConsumer.cs       |  2 +-
 .../Codecs/ramonly/RAMOnlyPostingsFormat.cs     | 12 ++--
 .../Index/BaseDocValuesFormatTestCase.cs        | 52 +++++++-------
 .../Index/BasePostingsFormatTestCase.cs         |  2 +-
 .../Index/BaseStoredFieldsFormatTestCase.cs     | 22 +++---
 src/Lucene.Net.TestFramework/Index/DocHelper.cs |  2 +-
 .../Index/FieldFilterAtomicReader.cs            |  4 +-
 .../Util/LuceneTestCase.cs                      |  4 +-
 .../Util/fst/FSTTester.cs                       |  2 +-
 src/Lucene.Net.Tests/core/Analysis/TestToken.cs |  4 +-
 .../Compressing/AbstractTestCompressionMode.cs  | 60 ++++++++--------
 .../AbstractTestLZ4CompressionMode.cs           | 14 ++--
 .../Compressing/TestFastDecompressionMode.cs    |  6 +-
 .../Codecs/Lucene41/TestBlockPostingsFormat3.cs |  2 +-
 .../core/Codecs/Lucene41/TestForUtil.cs         |  4 +-
 .../core/Document/TestBinaryDocument.cs         |  6 +-
 .../core/Document/TestDocument.cs               |  2 +-
 src/Lucene.Net.Tests/core/Document/TestField.cs |  2 +-
 .../core/Index/Test2BBinaryDocValues.cs         | 24 +++----
 .../core/Index/Test2BSortedDocValues.cs         | 28 ++++----
 src/Lucene.Net.Tests/core/Index/Test2BTerms.cs  |  2 +-
 .../core/Index/Test4GBStoredFields.cs           |  4 +-
 .../core/Index/TestBinaryDocValuesUpdates.cs    |  6 +-
 .../core/Index/TestBinaryTerms.cs               | 10 +--
 src/Lucene.Net.Tests/core/Index/TestCodecs.cs   |  4 +-
 .../core/Index/TestConsistentFieldNumbers.cs    |  4 +-
 .../core/Index/TestDirectoryReader.cs           |  2 +-
 .../core/Index/TestDocValuesIndexing.cs         |  8 +--
 .../core/Index/TestDocumentWriter.cs            |  2 +-
 .../core/Index/TestIndexWriter.cs               |  4 +-
 .../core/Index/TestIndexWriterExceptions.cs     |  2 +-
 .../core/Index/TestIndexWriterUnicode.cs        |  4 +-
 .../core/Index/TestIndexableField.cs            |  4 +-
 .../core/Index/TestMultiLevelSkipList.cs        |  2 +-
 src/Lucene.Net.Tests/core/Index/TestPayloads.cs | 50 ++++++-------
 .../core/Search/Payloads/PayloadHelper.cs       |  6 +-
 .../Search/Payloads/TestPayloadNearQuery.cs     |  4 +-
 .../Search/Payloads/TestPayloadTermQuery.cs     |  8 +--
 .../core/Search/Spans/JustCompileSearchSpans.cs |  4 +-
 .../core/Search/Spans/MultiSpansWrapper.cs      | 10 +--
 .../core/Search/Spans/TestBasics.cs             | 10 +--
 .../core/Search/Spans/TestPayloadSpans.cs       | 32 ++++-----
 .../core/Search/TestPositionIncrement.cs        | 10 +--
 .../core/Store/TestMultiMMap.cs                 | 26 +++----
 .../Util/Automaton/TestDeterminizeLexicon.cs    |  2 +-
 .../core/Util/Automaton/TestUTF32ToUTF8.cs      |  6 +-
 src/Lucene.Net.Tests/core/Util/Fst/Test2BFST.cs |  4 +-
 .../core/Util/Test2BPagedBytes.cs               |  4 +-
 src/Lucene.Net.Tests/core/Util/TestBytesRef.cs  |  6 +-
 .../core/Util/TestBytesRefHash.cs               |  4 +-
 .../Util/TestRecyclingByteBlockAllocator.cs     | 22 +++---
 .../core/Util/TestUnicodeUtil.cs                |  8 +--
 157 files changed, 758 insertions(+), 777 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs b/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
index b56fb28..154d23c 100644
--- a/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/BlockTreeTermsReader.cs
@@ -171,7 +171,7 @@ namespace Lucene.Net.Codecs
                     long numTerms = @in.ReadVLong();
                     Debug.Assert(numTerms >= 0);
                     int numBytes = @in.ReadVInt();
-                    BytesRef rootCode = new BytesRef(new sbyte[numBytes]);
+                    BytesRef rootCode = new BytesRef(new byte[numBytes]);
                     @in.ReadBytes(rootCode.Bytes, 0, numBytes);
                     rootCode.Length = numBytes;
                     FieldInfo fieldInfo = fieldInfos.FieldInfo(field);
@@ -1395,7 +1395,7 @@ namespace Lucene.Net.Codecs
                                 // A prefix of the common suffix overlaps with
                                 // the suffix of the block prefix so we first
                                 // test whether the prefix part matches:
-                                sbyte[] termBytes = Term_Renamed.Bytes;
+                                byte[] termBytes = Term_Renamed.Bytes;
                                 int termBytesPos = CurrentFrame.Prefix - lenInPrefix;
                                 Debug.Assert(termBytesPos >= 0);
                                 int termBytesPosEnd = CurrentFrame.Prefix;
@@ -2023,7 +2023,7 @@ namespace Lucene.Net.Codecs
                             if (!CurrentFrame.HasTerms)
                             {
                                 TermExists = false;
-                                Term_Renamed.Bytes[targetUpto] = (sbyte)targetLabel;
+                                Term_Renamed.Bytes[targetUpto] = (byte)targetLabel;
                                 Term_Renamed.Length = 1 + targetUpto;
                                 // if (DEBUG) {
                                 //   System.out.println("  FAST NOT_FOUND term=" + brToString(term));
@@ -2053,7 +2053,7 @@ namespace Lucene.Net.Codecs
                         {
                             // Follow this arc
                             arc = nextArc;
-                            Term_Renamed.Bytes[targetUpto] = (sbyte)targetLabel;
+                            Term_Renamed.Bytes[targetUpto] = (byte)targetLabel;
                             // Aggregate output as we go:
                             Debug.Assert(arc.Output != null);
                             if (arc.Output != OuterInstance.OuterInstance.NO_OUTPUT)
@@ -2339,7 +2339,7 @@ namespace Lucene.Net.Codecs
                         else
                         {
                             // Follow this arc
-                            Term_Renamed.Bytes[targetUpto] = (sbyte)targetLabel;
+                            Term_Renamed.Bytes[targetUpto] = (byte)targetLabel;
                             arc = nextArc;
                             // Aggregate output as we go:
                             Debug.Assert(arc.Output != null);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs b/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
index 62f879a..f70fa8b 100644
--- a/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/BlockTreeTermsWriter.cs
@@ -453,7 +453,7 @@ namespace Lucene.Net.Codecs
 
                 ByteSequenceOutputs outputs = ByteSequenceOutputs.Singleton;
                 Builder<BytesRef> indexBuilder = new Builder<BytesRef>(FST<BytesRef>.INPUT_TYPE.BYTE1, 0, 0, true, false, int.MaxValue, outputs, null, false, PackedInts.COMPACT, true, 15);
-                sbyte[] bytes = new sbyte[(int)scratchBytes.FilePointer];
+                var bytes = new byte[(int)scratchBytes.FilePointer];
                 Debug.Assert(bytes.Length > 0);
                 scratchBytes.WriteTo(bytes, 0);
                 indexBuilder.Add(Util.ToIntsRef(Prefix, ScratchIntsRef), new BytesRef(bytes, 0, bytes.Length));
@@ -885,7 +885,7 @@ namespace Lucene.Net.Codecs
                 BytesRef prefix = new BytesRef(indexPrefixLength);
                 for (int m = 0; m < indexPrefixLength; m++)
                 {
-                    prefix.Bytes[m] = (sbyte)prevTerm.Ints[m];
+                    prefix.Bytes[m] = (byte)prevTerm.Ints[m];
                 }
                 prefix.Length = indexPrefixLength;
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs b/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
index 8694735..dbf42b2 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/CompressingStoredFieldsReader.cs
@@ -190,14 +190,14 @@ namespace Lucene.Net.Codecs.Compressing
             {
                 case CompressingStoredFieldsWriter.BYTE_ARR:
                     int length = @in.ReadVInt();
-                    sbyte[] data = new sbyte[length];
+                    var data = new byte[length];
                     @in.ReadBytes(data, 0, length);
                     visitor.BinaryField(info, data);
                     break;
 
                 case CompressingStoredFieldsWriter.STRING:
                     length = @in.ReadVInt();
-                    data = new sbyte[length];
+                    data = new byte[length];
                     @in.ReadBytes(data, 0, length);
                     visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString((byte[])(Array)data));
                     break;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs b/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
index d94e1b9..9fccb35 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/CompressingTermVectorsWriter.cs
@@ -350,7 +350,7 @@ namespace Lucene.Net.Codecs.Compressing
             // copy last term
             if (LastTerm.Bytes.Length < term.Length)
             {
-                LastTerm.Bytes = new sbyte[ArrayUtil.Oversize(term.Length, 1)];
+                LastTerm.Bytes = new byte[ArrayUtil.Oversize(term.Length, 1)];
             }
             LastTerm.Offset = 0;
             LastTerm.Length = term.Length;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs b/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
index 1da51db..be238b3 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/CompressionMode.cs
@@ -155,7 +155,7 @@ namespace Lucene.Net.Codecs.Compressing
                 // add 7 padding bytes, this is not necessary but can help decompression run faster
                 if (bytes.Bytes.Length < originalLength + 7)
                 {
-                    bytes.Bytes = new sbyte[ArrayUtil.Oversize(originalLength + 7, 1)];
+                    bytes.Bytes = new byte[ArrayUtil.Oversize(originalLength + 7, 1)];
                 }
                 int decompressedLength = LZ4.Decompress(@in, offset + length, bytes.Bytes, 0);
                 if (decompressedLength > originalLength)
@@ -174,14 +174,14 @@ namespace Lucene.Net.Codecs.Compressing
 
         private sealed class LZ4FastCompressor : Compressor
         {
-            internal readonly LZ4.HashTable Ht;
+            private readonly LZ4.HashTable Ht;
 
             internal LZ4FastCompressor()
             {
                 Ht = new LZ4.HashTable();
             }
 
-            public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
+            public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
             {
                 LZ4.Compress(bytes, off, len, @out, Ht);
             }
@@ -196,7 +196,7 @@ namespace Lucene.Net.Codecs.Compressing
                 Ht = new LZ4.HCHashTable();
             }
 
-            public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
+            public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
             {
                 LZ4.CompressHC(bytes, off, len, @out, Ht);
             }
@@ -270,8 +270,8 @@ namespace Lucene.Net.Codecs.Compressing
 
         private class DeflateCompressor : Compressor
         {
-            internal readonly Deflater Compressor;
-            internal byte[] Compressed;
+            private readonly Deflater Compressor;
+            private byte[] Compressed;
 
             internal DeflateCompressor(int level)
             {
@@ -279,7 +279,7 @@ namespace Lucene.Net.Codecs.Compressing
                 Compressed = new byte[64];
             }
 
-            public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
+            public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
             {
                 Compressor.Reset();
                 Compressor.SetInput((byte[])(Array)bytes, off, len);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs b/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
index 0cff06a..666e90a 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/Compressor.cs
@@ -35,6 +35,6 @@ namespace Lucene.Net.Codecs.Compressing
         /// compressor to add all necessary information so that a <seealso cref="Decompressor"/>
         /// will know when to stop decompressing bytes from the stream.
         /// </summary>
-        public abstract void Compress(sbyte[] bytes, int off, int len, DataOutput @out);
+        public abstract void Compress(byte[] bytes, int off, int len, DataOutput @out);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs b/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
index 8328fa3..e473f45 100644
--- a/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
+++ b/src/Lucene.Net.Core/Codecs/Compressing/LZ4.cs
@@ -56,17 +56,18 @@ namespace Lucene.Net.Codecs.Compressing
             return Hash(i, HASH_LOG_HC);
         }
 
-        private static int ReadInt(sbyte[] buf, int i)
+        private static int ReadInt(byte[] buf, int i)
         {
-            return ((buf[i] & 0xFF) << 24) | ((buf[i + 1] & 0xFF) << 16) | ((buf[i + 2] & 0xFF) << 8) | (buf[i + 3] & 0xFF);
+            return ((((sbyte)buf[i]) & 0xFF) << 24) | ((((sbyte)buf[i + 1]) & 0xFF) << 16) | ((((sbyte)buf[i + 2]) & 0xFF) << 8) |
+                (((sbyte)buf[i + 3]) & 0xFF);
         }
 
-        private static bool ReadIntEquals(sbyte[] buf, int i, int j)
+        private static bool ReadIntEquals(byte[] buf, int i, int j)
         {
             return ReadInt(buf, i) == ReadInt(buf, j);
         }
 
-        private static int CommonBytes(sbyte[] b, int o1, int o2, int limit)
+        private static int CommonBytes(byte[] b, int o1, int o2, int limit)
         {
             Debug.Assert(o1 < o2);
             int count = 0;
@@ -77,7 +78,7 @@ namespace Lucene.Net.Codecs.Compressing
             return count;
         }
 
-        private static int CommonBytesBackward(sbyte[] b, int o1, int o2, int l1, int l2)
+        private static int CommonBytesBackward(byte[] b, int o1, int o2, int l1, int l2)
         {
             int count = 0;
             while (o1 > l1 && o2 > l2 && b[--o1] == b[--o2])
@@ -93,7 +94,7 @@ namespace Lucene.Net.Codecs.Compressing
         /// enough to be able to hold <b>all</b> decompressed data (meaning that you
         /// need to know the total decompressed length).
         /// </summary>
-        public static int Decompress(DataInput compressed, int decompressedLen, sbyte[] dest, int dOff)
+        public static int Decompress(DataInput compressed, int decompressedLen, byte[] dest, int dOff)
         {
             int destEnd = dest.Length;
 
@@ -172,7 +173,7 @@ namespace Lucene.Net.Codecs.Compressing
             @out.WriteByte((sbyte)l);
         }
 
-        private static void EncodeLiterals(sbyte[] bytes, int token, int anchor, int literalLen, DataOutput @out)
+        private static void EncodeLiterals(byte[] bytes, int token, int anchor, int literalLen, DataOutput @out)
         {
             @out.WriteByte((sbyte)token);
 
@@ -186,13 +187,13 @@ namespace Lucene.Net.Codecs.Compressing
             @out.WriteBytes(bytes, anchor, literalLen);
         }
 
-        private static void EncodeLastLiterals(sbyte[] bytes, int anchor, int literalLen, DataOutput @out)
+        private static void EncodeLastLiterals(byte[] bytes, int anchor, int literalLen, DataOutput @out)
         {
             int token = Math.Min(literalLen, 0x0F) << 4;
             EncodeLiterals(bytes, token, anchor, literalLen, @out);
         }
 
-        private static void EncodeSequence(sbyte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput @out)
+        private static void EncodeSequence(byte[] bytes, int anchor, int matchRef, int matchOff, int matchLen, DataOutput @out)
         {
             int literalLen = matchOff - anchor;
             Debug.Assert(matchLen >= 4);
@@ -239,7 +240,7 @@ namespace Lucene.Net.Codecs.Compressing
         /// at most 16KB of memory. <code>ht</code> shouldn't be shared across threads
         /// but can safely be reused.
         /// </summary>
-        public static void Compress(sbyte[] bytes, int off, int len, DataOutput @out, HashTable ht)
+        public static void Compress(byte[] bytes, int off, int len, DataOutput @out, HashTable ht)
         {
             int @base = off;
             int end = off + len;
@@ -340,7 +341,7 @@ namespace Lucene.Net.Codecs.Compressing
                 CollectionsHelper.Fill(ChainTable, (short)0);
             }
 
-            internal int HashPointer(sbyte[] bytes, int off)
+            internal int HashPointer(byte[] bytes, int off)
             {
                 int v = ReadInt(bytes, off);
                 int h = HashHC(v);
@@ -352,7 +353,7 @@ namespace Lucene.Net.Codecs.Compressing
                 return off - (ChainTable[off & MASK] & 0xFFFF);
             }
 
-            internal void AddHash(sbyte[] bytes, int off)
+            internal void AddHash(byte[] bytes, int off)
             {
                 int v = ReadInt(bytes, off);
                 int h = HashHC(v);
@@ -366,7 +367,7 @@ namespace Lucene.Net.Codecs.Compressing
                 HashTable[h] = off;
             }
 
-            internal void Insert(int off, sbyte[] bytes)
+            internal void Insert(int off, byte[] bytes)
             {
                 for (; NextToUpdate < off; ++NextToUpdate)
                 {
@@ -374,7 +375,7 @@ namespace Lucene.Net.Codecs.Compressing
                 }
             }
 
-            public bool InsertAndFindBestMatch(sbyte[] buf, int off, int matchLimit, Match match)
+            public bool InsertAndFindBestMatch(byte[] buf, int off, int matchLimit, Match match)
             {
                 match.Start = off;
                 match.Len = 0;
@@ -435,7 +436,7 @@ namespace Lucene.Net.Codecs.Compressing
                 return match.Len != 0;
             }
 
-            public bool InsertAndFindWiderMatch(sbyte[] buf, int off, int startLimit, int matchLimit, int minLen, Match match)
+            public bool InsertAndFindWiderMatch(byte[] buf, int off, int startLimit, int matchLimit, int minLen, Match match)
             {
                 match.Len = minLen;
 
@@ -477,7 +478,7 @@ namespace Lucene.Net.Codecs.Compressing
         /// fix overlapping matches. <code>ht</code> shouldn't be shared across threads
         /// but can safely be reused.
         /// </summary>
-        public static void CompressHC(sbyte[] src, int srcOff, int srcLen, DataOutput @out, HCHashTable ht)
+        public static void CompressHC(byte[] src, int srcOff, int srcLen, DataOutput @out, HCHashTable ht)
         {
             int srcEnd = srcOff + srcLen;
             int matchLimit = srcEnd - LAST_LITERALS;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
index 26fbfa1..fed442d 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xFields.cs
@@ -304,23 +304,23 @@ namespace Lucene.Net.Codecs.Lucene3x
 
             // Returns true if the unicode char is "after" the
             // surrogates in UTF16, ie >= U+E000 and <= U+FFFF:
-            internal bool IsHighBMPChar(sbyte[] b, int idx)
+            private bool IsHighBMPChar(byte[] b, int idx)
             {
-                return (b[idx] & UTF8_HIGH_BMP_LEAD) == UTF8_HIGH_BMP_LEAD;
+                return (((sbyte)b[idx]) & UTF8_HIGH_BMP_LEAD) == UTF8_HIGH_BMP_LEAD;
             }
 
             // Returns true if the unicode char in the UTF8 byte
             // sequence starting at idx encodes a char outside of
             // BMP (ie what would be a surrogate pair in UTF16):
-            internal bool IsNonBMPChar(sbyte[] b, int idx)
+            private bool IsNonBMPChar(byte[] b, int idx)
             {
-                return (b[idx] & UTF8_NON_BMP_LEAD) == UTF8_NON_BMP_LEAD;
+                return (((sbyte)b[idx]) & UTF8_NON_BMP_LEAD) == UTF8_NON_BMP_LEAD;
             }
 
-            internal readonly sbyte[] Scratch = new sbyte[4];
-            internal readonly BytesRef PrevTerm = new BytesRef();
-            internal readonly BytesRef ScratchTerm = new BytesRef();
-            internal int NewSuffixStart;
+            private readonly sbyte[] Scratch = new sbyte[4];
+            private readonly BytesRef PrevTerm = new BytesRef();
+            private readonly BytesRef ScratchTerm = new BytesRef();
+            private int NewSuffixStart;
 
             // Swap in S, in place of E:
             internal virtual bool SeekToNonBMP(SegmentTermEnum te, BytesRef term, int pos)
@@ -346,14 +346,14 @@ namespace Lucene.Net.Codecs.Lucene3x
                     term.Grow(4 + pos);
                 }
 
-                Scratch[0] = term.Bytes[pos];
-                Scratch[1] = term.Bytes[pos + 1];
-                Scratch[2] = term.Bytes[pos + 2];
+                Scratch[0] = (sbyte)term.Bytes[pos];
+                Scratch[1] = (sbyte)term.Bytes[pos + 1];
+                Scratch[2] = (sbyte)term.Bytes[pos + 2];
 
-                term.Bytes[pos] = unchecked((sbyte)0xf0);
-                term.Bytes[pos + 1] = unchecked((sbyte)0x90);
-                term.Bytes[pos + 2] = unchecked((sbyte)0x80);
-                term.Bytes[pos + 3] = unchecked((sbyte)0x80);
+                term.Bytes[pos] = unchecked((byte)0xf0);
+                term.Bytes[pos + 1] = unchecked((byte)0x90);
+                term.Bytes[pos + 2] = unchecked((byte)0x80);
+                term.Bytes[pos + 3] = unchecked((byte)0x80);
                 term.Length = 4 + pos;
 
                 if (DEBUG_SURROGATES)
@@ -406,9 +406,9 @@ namespace Lucene.Net.Codecs.Lucene3x
 
                 // Restore term:
                 term.Length = savLength;
-                term.Bytes[pos] = Scratch[0];
-                term.Bytes[pos + 1] = Scratch[1];
-                term.Bytes[pos + 2] = Scratch[2];
+                term.Bytes[pos] = (byte)Scratch[0];
+                term.Bytes[pos + 1] = (byte)Scratch[1];
+                term.Bytes[pos + 2] = (byte)Scratch[2];
 
                 return matches;
             }
@@ -494,7 +494,7 @@ namespace Lucene.Net.Codecs.Lucene3x
                 if (PrevTerm.Length > NewSuffixStart && IsNonBMPChar(PrevTerm.Bytes, NewSuffixStart) && IsHighBMPChar(ScratchTerm.Bytes, NewSuffixStart))
                 {
                     // Seek type 2 -- put 0xFF at this position:
-                    ScratchTerm.Bytes[NewSuffixStart] = unchecked((sbyte)0xff);
+                    ScratchTerm.Bytes[NewSuffixStart] = unchecked((byte)0xff);
                     ScratchTerm.Length = NewSuffixStart + 1;
 
                     if (DEBUG_SURROGATES)
@@ -676,13 +676,13 @@ namespace Lucene.Net.Codecs.Lucene3x
                         Debug.Assert(ScratchTerm.Length >= upTo + 4);
 
                         int savLength = ScratchTerm.Length;
-                        Scratch[0] = ScratchTerm.Bytes[upTo];
-                        Scratch[1] = ScratchTerm.Bytes[upTo + 1];
-                        Scratch[2] = ScratchTerm.Bytes[upTo + 2];
+                        Scratch[0] = (sbyte)ScratchTerm.Bytes[upTo];
+                        Scratch[1] = (sbyte)ScratchTerm.Bytes[upTo + 1];
+                        Scratch[2] = (sbyte)ScratchTerm.Bytes[upTo + 2];
 
-                        ScratchTerm.Bytes[upTo] = UTF8_HIGH_BMP_LEAD;
-                        ScratchTerm.Bytes[upTo + 1] = unchecked((sbyte)0x80);
-                        ScratchTerm.Bytes[upTo + 2] = unchecked((sbyte)0x80);
+                        ScratchTerm.Bytes[upTo] = (byte)UTF8_HIGH_BMP_LEAD;
+                        ScratchTerm.Bytes[upTo + 1] = unchecked((byte)0x80);
+                        ScratchTerm.Bytes[upTo + 2] = unchecked((byte)0x80);
                         ScratchTerm.Length = upTo + 3;
 
                         if (DEBUG_SURROGATES)
@@ -694,9 +694,9 @@ namespace Lucene.Net.Codecs.Lucene3x
                         // TODO: more efficient seek?
                         OuterInstance.TermsDict.SeekEnum(SeekTermEnum, new Term(fieldInfo.Name, ScratchTerm), true);
 
-                        ScratchTerm.Bytes[upTo] = Scratch[0];
-                        ScratchTerm.Bytes[upTo + 1] = Scratch[1];
-                        ScratchTerm.Bytes[upTo + 2] = Scratch[2];
+                        ScratchTerm.Bytes[upTo] = (byte)Scratch[0];
+                        ScratchTerm.Bytes[upTo + 1] = (byte)Scratch[1];
+                        ScratchTerm.Bytes[upTo + 2] = (byte)Scratch[2];
                         ScratchTerm.Length = savLength;
 
                         // Did we find a match?

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
index fc54c30..6ced971 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene3x/Lucene3xStoredFieldsReader.cs
@@ -318,7 +318,7 @@ namespace Lucene.Net.Codecs.Lucene3x
             else
             {
                 int length = FieldsStream.ReadVInt();
-                sbyte[] bytes = new sbyte[length];
+                var bytes = new byte[length];
                 FieldsStream.ReadBytes(bytes, 0, length);
                 if ((bits & FIELD_IS_BINARY) != 0)
                 {
@@ -326,7 +326,7 @@ namespace Lucene.Net.Codecs.Lucene3x
                 }
                 else
                 {
-                    visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString((byte[])(Array)bytes));
+                    visitor.StringField(info, IOUtils.CHARSET_UTF_8.GetString(bytes));
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/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 865b6c1..1825397 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40DocValuesReader.cs
@@ -691,7 +691,7 @@ namespace Lucene.Net.Codecs.Lucene40
                 long startAddress = Reader.Get(docID);
                 BytesRef lengthBytes = new BytesRef();
                 BytesReader.FillSlice(lengthBytes, startAddress, 1);
-                sbyte code = lengthBytes.Bytes[lengthBytes.Offset];
+                var code = lengthBytes.Bytes[lengthBytes.Offset];
                 if ((code & 128) == 0)
                 {
                     // length is 1 byte

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
index 5ff23f0..58f67f8 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40PostingsReader.cs
@@ -1028,7 +1028,7 @@ namespace Lucene.Net.Codecs.Lucene40
                 if (Payload_Renamed == null)
                 {
                     Payload_Renamed = new BytesRef();
-                    Payload_Renamed.Bytes = new sbyte[1];
+                    Payload_Renamed.Bytes = new byte[1];
                 }
 
                 this.LiveDocs = liveDocs;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
index 45f15b5..be570d6 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40StoredFieldsReader.cs
@@ -219,7 +219,7 @@ namespace Lucene.Net.Codecs.Lucene40
             else
             {
                 int length = FieldsStream.ReadVInt();
-                sbyte[] bytes = new sbyte[length];
+                var bytes = new byte[length];
                 FieldsStream.ReadBytes(bytes, 0, length);
                 if ((bits & Lucene40StoredFieldsWriter.FIELD_IS_BINARY) != 0)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
index 7b259a7..4c4b4d8 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene40/Lucene40TermVectorsReader.cs
@@ -447,8 +447,8 @@ namespace Lucene.Net.Codecs.Lucene40
             private int NumTerms;
             private int NextTerm;
             private int Freq;
-            private BytesRef LastTerm = new BytesRef();
-            private BytesRef Term_Renamed = new BytesRef();
+            private readonly BytesRef LastTerm = new BytesRef();
+            private readonly BytesRef Term_Renamed = new BytesRef();
             private bool StorePositions;
             private bool StoreOffsets;
             private bool StorePayloads;
@@ -462,7 +462,7 @@ namespace Lucene.Net.Codecs.Lucene40
             internal int[] PayloadOffsets;
 
             internal int LastPayloadLength;
-            internal sbyte[] PayloadData;
+            internal byte[] PayloadData;
 
             // NOTE: tvf is pre-positioned by caller
             public TVTermsEnum(Lucene40TermVectorsReader outerInstance)
@@ -566,7 +566,7 @@ namespace Lucene.Net.Codecs.Lucene40
                         totalPayloadLength += LastPayloadLength;
                         Debug.Assert(totalPayloadLength >= 0);
                     }
-                    PayloadData = new sbyte[totalPayloadLength];
+                    PayloadData = new byte[totalPayloadLength];
                     Tvf.ReadBytes(PayloadData, 0, PayloadData.Length);
                 } // no payloads
                 else if (StorePositions)
@@ -715,18 +715,18 @@ namespace Lucene.Net.Codecs.Lucene40
             }
         }
 
-        private class TVDocsAndPositionsEnum : DocsAndPositionsEnum
+        private sealed class TVDocsAndPositionsEnum : DocsAndPositionsEnum
         {
-            internal bool DidNext;
-            internal int Doc = -1;
-            internal int NextPos;
-            internal Bits LiveDocs;
-            internal int[] Positions;
-            internal int[] StartOffsets;
-            internal int[] EndOffsets;
-            internal int[] PayloadOffsets;
-            internal BytesRef Payload_Renamed = new BytesRef();
-            internal sbyte[] PayloadBytes;
+            private bool DidNext;
+            private int Doc = -1;
+            private int NextPos;
+            private Bits LiveDocs;
+            private int[] Positions;
+            private int[] StartOffsets;
+            private int[] EndOffsets;
+            private int[] PayloadOffsets;
+            private readonly BytesRef Payload_Renamed = new BytesRef();
+            private byte[] PayloadBytes;
 
             public override int Freq()
             {
@@ -764,7 +764,7 @@ namespace Lucene.Net.Codecs.Lucene40
                 return SlowAdvance(target);
             }
 
-            public virtual void Reset(Bits liveDocs, int[] positions, int[] startOffsets, int[] endOffsets, int[] payloadLengths, sbyte[] payloadBytes)
+            public void Reset(Bits liveDocs, int[] positions, int[] startOffsets, int[] endOffsets, int[] payloadLengths, byte[] payloadBytes)
             {
                 this.LiveDocs = liveDocs;
                 this.Positions = positions;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs b/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
index ffc030e..c64cff9 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene41/ForUtil.cs
@@ -1,3 +1,4 @@
+using System.IO;
 using Lucene.Net.Store;
 using Lucene.Net.Support;
 using Lucene.Net.Util.Packed;
@@ -164,7 +165,7 @@ namespace Lucene.Net.Codecs.Lucene41
         /// <param name="encoded">  a buffer to use to encode data </param>
         /// <param name="out">      the destination output </param>
         /// <exception cref="IOException"> If there is a low-level I/O error </exception>
-        public void WriteBlock(int[] data, sbyte[] encoded, IndexOutput @out)
+        public void WriteBlock(int[] data, byte[] encoded, IndexOutput @out)
         {
             if (IsAllEqual(data))
             {
@@ -181,7 +182,7 @@ namespace Lucene.Net.Codecs.Lucene41
             int encodedSize = EncodedSizes[numBits];
             Debug.Assert(iters * encoder.ByteBlockCount() >= encodedSize);
 
-            @out.WriteByte((sbyte)numBits);
+            @out.WriteByte((byte)numBits);
 
             encoder.Encode(data, 0, encoded, 0, iters);
             @out.WriteBytes(encoded, encodedSize);
@@ -194,7 +195,7 @@ namespace Lucene.Net.Codecs.Lucene41
         /// <param name="encoded">   a buffer that can be used to store encoded data </param>
         /// <param name="decoded">   where to write decoded data </param>
         /// <exception cref="IOException"> If there is a low-level I/O error </exception>
-        public void ReadBlock(IndexInput @in, sbyte[] encoded, int[] decoded)
+        public void ReadBlock(IndexInput @in, byte[] encoded, int[] decoded)
         {
             int numBits = @in.ReadByte();
             Debug.Assert(numBits <= 32, numBits.ToString());

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
index 80a26bd..a8be2f1 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsReader.cs
@@ -294,7 +294,7 @@ namespace Lucene.Net.Codecs.Lucene41
         {
             private readonly Lucene41PostingsReader OuterInstance;
 
-            internal readonly sbyte[] Encoded;
+            internal readonly byte[] Encoded;
 
             internal readonly int[] DocDeltaBuffer = new int[ForUtil.MAX_DATA_SIZE];
             internal readonly int[] FreqBuffer = new int[ForUtil.MAX_DATA_SIZE];
@@ -345,7 +345,7 @@ namespace Lucene.Net.Codecs.Lucene41
                 IndexHasPos = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
                 IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
                 IndexHasPayloads = fieldInfo.HasPayloads();
-                Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+                Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
             }
 
             public bool CanReuse(IndexInput docIn, FieldInfo fieldInfo)
@@ -598,7 +598,7 @@ namespace Lucene.Net.Codecs.Lucene41
         {
             private readonly Lucene41PostingsReader OuterInstance;
 
-            internal readonly sbyte[] Encoded;
+            internal readonly byte[] Encoded;
 
             internal readonly int[] DocDeltaBuffer = new int[ForUtil.MAX_DATA_SIZE];
             internal readonly int[] FreqBuffer = new int[ForUtil.MAX_DATA_SIZE];
@@ -665,7 +665,7 @@ namespace Lucene.Net.Codecs.Lucene41
                 this.StartDocIn = outerInstance.DocIn;
                 this.DocIn = null;
                 this.PosIn = (IndexInput)outerInstance.PosIn.Clone();
-                Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+                Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
                 IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
                 IndexHasPayloads = fieldInfo.HasPayloads();
             }
@@ -1065,7 +1065,7 @@ namespace Lucene.Net.Codecs.Lucene41
         {
             private readonly Lucene41PostingsReader OuterInstance;
 
-            internal readonly sbyte[] Encoded;
+            internal readonly byte[] Encoded;
 
             internal readonly int[] DocDeltaBuffer = new int[ForUtil.MAX_DATA_SIZE];
             internal readonly int[] FreqBuffer = new int[ForUtil.MAX_DATA_SIZE];
@@ -1075,7 +1075,7 @@ namespace Lucene.Net.Codecs.Lucene41
             internal readonly int[] OffsetStartDeltaBuffer;
             internal readonly int[] OffsetLengthBuffer;
 
-            internal sbyte[] PayloadBytes;
+            internal byte[] PayloadBytes;
             internal int PayloadByteUpto;
             internal int PayloadLength;
 
@@ -1154,7 +1154,7 @@ namespace Lucene.Net.Codecs.Lucene41
                 this.DocIn = null;
                 this.PosIn = (IndexInput)outerInstance.PosIn.Clone();
                 this.PayIn = (IndexInput)outerInstance.PayIn.Clone();
-                Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+                Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
                 IndexHasOffsets = fieldInfo.FieldIndexOptions >= FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
                 if (IndexHasOffsets)
                 {
@@ -1173,7 +1173,7 @@ namespace Lucene.Net.Codecs.Lucene41
                 if (IndexHasPayloads)
                 {
                     PayloadLengthBuffer = new int[ForUtil.MAX_DATA_SIZE];
-                    PayloadBytes = new sbyte[128];
+                    PayloadBytes = new byte[128];
                     Payload_Renamed = new BytesRef();
                 }
                 else

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
index 1a8da9c..27c636a 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene41/Lucene41PostingsWriter.cs
@@ -104,7 +104,7 @@ namespace Lucene.Net.Codecs.Lucene41
         private int LastStartOffset;
         private int DocCount;
 
-        internal readonly sbyte[] Encoded;
+        internal readonly byte[] Encoded;
 
         private readonly ForUtil ForUtil;
         private readonly Lucene41SkipWriter SkipWriter;
@@ -183,7 +183,7 @@ namespace Lucene.Net.Codecs.Lucene41
             // TODO: should we try skipping every 2/4 blocks...?
             SkipWriter = new Lucene41SkipWriter(MaxSkipLevels, Lucene41PostingsFormat.BLOCK_SIZE, state.SegmentInfo.DocCount, DocOut, posOut, payOut);
 
-            Encoded = new sbyte[ForUtil.MAX_ENCODED_SIZE];
+            Encoded = new byte[ForUtil.MAX_ENCODED_SIZE];
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
index 566f66a..2648940 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene42/Lucene42DocValuesProducer.cs
@@ -495,7 +495,7 @@ namespace Lucene.Net.Codecs.Lucene42
                     @in.Position = 0;
                     Fst.GetFirstArc(FirstArc);
                     IntsRef output = Lucene.Net.Util.Fst.Util.GetByOutput(Fst, ord, @in, FirstArc, ScratchArc, ScratchInts);
-                    result.Bytes = new sbyte[output.Length];
+                    result.Bytes = new byte[output.Length];
                     result.Offset = 0;
                     result.Length = 0;
                     Util.ToBytesRef(output, result);
@@ -639,7 +639,7 @@ namespace Lucene.Net.Codecs.Lucene42
                     @in.Position = 0;
                     Fst.GetFirstArc(FirstArc);
                     IntsRef output = Lucene.Net.Util.Fst.Util.GetByOutput(Fst, ord, @in, FirstArc, ScratchArc, ScratchInts);
-                    result.Bytes = new sbyte[output.Length];
+                    result.Bytes = new byte[output.Length];
                     result.Offset = 0;
                     result.Length = 0;
                     Lucene.Net.Util.Fst.Util.ToBytesRef(output, result);
@@ -811,7 +811,7 @@ namespace Lucene.Net.Codecs.Lucene42
                 BytesReader.Position = 0;
                 Fst.GetFirstArc(FirstArc);
                 IntsRef output = Lucene.Net.Util.Fst.Util.GetByOutput(Fst, ord, BytesReader, FirstArc, ScratchArc, ScratchInts);
-                ScratchBytes.Bytes = new sbyte[output.Length];
+                ScratchBytes.Bytes = new byte[output.Length];
                 ScratchBytes.Offset = 0;
                 ScratchBytes.Length = 0;
                 Lucene.Net.Util.Fst.Util.ToBytesRef(output, ScratchBytes);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs b/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
index 3cf7593..9719632 100644
--- a/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
+++ b/src/Lucene.Net.Core/Codecs/Lucene45/Lucene45DocValuesProducer.cs
@@ -485,7 +485,7 @@ namespace Lucene.Net.Codecs.Lucene45
                     Data.Seek(address);
                     // NOTE: we could have one buffer, but various consumers (e.g. FieldComparatorSource)
                     // assume "they" own the bytes after calling this!
-                    sbyte[] buffer = new sbyte[Bytes.MaxLength];
+                    var buffer = new byte[Bytes.MaxLength];
                     Data.ReadBytes(buffer, 0, buffer.Length);
                     result.Bytes = buffer;
                     result.Offset = 0;
@@ -555,7 +555,7 @@ namespace Lucene.Net.Codecs.Lucene45
                     Data.Seek(startAddress);
                     // NOTE: we could have one buffer, but various consumers (e.g. FieldComparatorSource)
                     // assume "they" own the bytes after calling this!
-                    sbyte[] buffer = new sbyte[length];
+                    var buffer = new byte[length];
                     Data.ReadBytes(buffer, 0, buffer.Length);
                     result.Bytes = buffer;
                     result.Offset = 0;
@@ -1215,7 +1215,7 @@ namespace Lucene.Net.Codecs.Lucene45
                 private void SetTerm()
                 {
                     // TODO: is there a cleaner way
-                    term.Bytes = new sbyte[termBuffer.Length];
+                    term.Bytes = new byte[termBuffer.Length];
                     term.Offset = 0;
                     term.CopyBytes(termBuffer);
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs b/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
index bd4431f..7027641 100644
--- a/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
+++ b/src/Lucene.Net.Core/Codecs/TermVectorsWriter.cs
@@ -173,7 +173,7 @@ namespace Lucene.Net.Codecs
                         if (payload == null)
                         {
                             payload = new BytesRef();
-                            payload.Bytes = new sbyte[payloadLength];
+                            payload.Bytes = new byte[payloadLength];
                         }
                         else if (payload.Bytes.Length < payloadLength)
                         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/CompressionTools.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/CompressionTools.cs b/src/Lucene.Net.Core/Document/CompressionTools.cs
index 567c522..8fdf733 100644
--- a/src/Lucene.Net.Core/Document/CompressionTools.cs
+++ b/src/Lucene.Net.Core/Document/CompressionTools.cs
@@ -40,20 +40,20 @@ namespace Lucene.Net.Documents
         ///  specified compressionLevel (constants are defined in
         ///  java.util.zip.Deflater).
         /// </summary>
-        public static byte[] Compress(sbyte[] value, int offset, int length, int compressionLevel)
+        public static byte[] Compress(byte[] value, int offset, int length, int compressionLevel)
         {
             /* Create an expandable byte array to hold the compressed data.
              * You cannot use an array that's the same size as the orginal because
              * there is no guarantee that the compressed data will be smaller than
              * the uncompressed data. */
-            ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
+            var bos = new ByteArrayOutputStream(length);
 
             Deflater compressor = SharpZipLib.CreateDeflater();
 
             try
             {
                 compressor.SetLevel(compressionLevel);
-                compressor.SetInput((byte[])(Array)value, offset, length);
+                compressor.SetInput(value, offset, length);
                 compressor.Finish();
 
                 // Compress the data
@@ -73,14 +73,14 @@ namespace Lucene.Net.Documents
 
         /// <summary>
         /// Compresses the specified byte range, with default BEST_COMPRESSION level </summary>
-        public static byte[] Compress(sbyte[] value, int offset, int length)
+        public static byte[] Compress(byte[] value, int offset, int length)
         {
             return Compress(value, offset, length, Deflater.BEST_COMPRESSION);
         }
 
         /// <summary>
         /// Compresses all bytes in the array, with default BEST_COMPRESSION level </summary>
-        public static byte[] Compress(sbyte[] value)
+        public static byte[] Compress(byte[] value)
         {
             return Compress(value, 0, value.Length, Deflater.BEST_COMPRESSION);
         }
@@ -99,7 +99,7 @@ namespace Lucene.Net.Documents
         /// </summary>
         public static byte[] CompressString(string value, int compressionLevel)
         {
-            BytesRef result = new BytesRef();
+            var result = new BytesRef();
             UnicodeUtil.UTF16toUTF8(value.ToCharArray(), 0, value.Length, result);
             return Compress(result.Bytes, 0, result.Length, compressionLevel);
         }
@@ -117,7 +117,7 @@ namespace Lucene.Net.Documents
         /// Decompress the byte array previously returned by
         ///  compress
         /// </summary>
-        public static byte[] Decompress(sbyte[] value)
+        public static byte[] Decompress(byte[] value)
         {
             return Decompress(value, 0, value.Length);
         }
@@ -126,19 +126,19 @@ namespace Lucene.Net.Documents
         /// Decompress the byte array previously returned by
         ///  compress
         /// </summary>
-        public static byte[] Decompress(sbyte[] value, int offset, int length)
+        public static byte[] Decompress(byte[] value, int offset, int length)
         {
             // Create an expandable byte array to hold the decompressed data
-            ByteArrayOutputStream bos = new ByteArrayOutputStream(length);
+            var bos = new ByteArrayOutputStream(length);
 
             Inflater decompressor = SharpZipLib.CreateInflater();
 
             try
             {
-                decompressor.SetInput((byte[])(Array)value);
+                decompressor.SetInput(value);
 
                 // Decompress the data
-                byte[] buf = new byte[1024];
+                var buf = new byte[1024];
                 while (!decompressor.IsFinished)
                 {
                     int count = decompressor.Inflate(buf);
@@ -156,7 +156,7 @@ namespace Lucene.Net.Documents
         /// Decompress the byte array previously returned by
         ///  compressString back into a String
         /// </summary>
-        public static string DecompressString(sbyte[] value)
+        public static string DecompressString(byte[] value)
         {
             return DecompressString(value, 0, value.Length);
         }
@@ -165,11 +165,11 @@ namespace Lucene.Net.Documents
         /// Decompress the byte array previously returned by
         ///  compressString back into a String
         /// </summary>
-        public static string DecompressString(sbyte[] value, int offset, int length)
+        public static string DecompressString(byte[] value, int offset, int length)
         {
             byte[] bytes = Decompress(value, offset, length);
             CharsRef result = new CharsRef(bytes.Length);
-            UnicodeUtil.UTF8toUTF16((sbyte[])(Array)bytes, 0, bytes.Length, result);
+            UnicodeUtil.UTF8toUTF16(bytes, 0, bytes.Length, result);
             return new string(result.Chars, 0, result.length);
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs b/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
index 28aa5a7..7607d01 100644
--- a/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
+++ b/src/Lucene.Net.Core/Document/DocumentStoredFieldVisitor.cs
@@ -62,7 +62,7 @@ namespace Lucene.Net.Documents
             this.FieldsToAdd = null;
         }
 
-        public override void BinaryField(FieldInfo fieldInfo, sbyte[] value)
+        public override void BinaryField(FieldInfo fieldInfo, byte[] value)
         {
             Doc.Add(new StoredField(fieldInfo.Name, value));
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/Field.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/Field.cs b/src/Lucene.Net.Core/Document/Field.cs
index 1c656bf..d93f0f4 100644
--- a/src/Lucene.Net.Core/Document/Field.cs
+++ b/src/Lucene.Net.Core/Document/Field.cs
@@ -185,7 +185,7 @@ namespace Lucene.Net.Documents
         /// <exception cref="IllegalArgumentException"> if the field name is null,
         ///         or the field's type is indexed() </exception>
         /// <exception cref="NullPointerException"> if the type is null </exception>
-        public Field(string name, sbyte[] value, FieldType type)
+        public Field(string name, byte[] value, FieldType type)
             : this(name, value, 0, value.Length, type)
         {
         }
@@ -203,7 +203,7 @@ namespace Lucene.Net.Documents
         /// <exception cref="IllegalArgumentException"> if the field name is null,
         ///         or the field's type is indexed() </exception>
         /// <exception cref="NullPointerException"> if the type is null </exception>
-        public Field(string name, sbyte[] value, int offset, int length, FieldType type)
+        public Field(string name, byte[] value, int offset, int length, FieldType type)
             : this(name, new BytesRef(value, offset, length), type)
         {
         }
@@ -343,28 +343,6 @@ namespace Lucene.Net.Documents
         /// <summary>
         /// Expert: change the value of this field. See
         /// <seealso cref="#setStringValue(String)"/>.
-        /// </summary>
-        public virtual sbyte[] SBytesValue
-        {
-            set
-            {
-                BytesRef temp = (new BytesRef(value));
-                if (!(FieldsData is BytesRef))
-                {
-                    throw new ArgumentException("cannot change value type from " + FieldsData.GetType().Name + " to BytesRef");
-                }
-
-                if (Type.Indexed)
-                {
-                    throw new ArgumentException("cannot set a BytesRef value on an indexed field");
-                }
-                FieldsData = temp;
-            }
-        }
-
-        /// <summary>
-        /// Expert: change the value of this field. See
-        /// <seealso cref="#setStringValue(String)"/>.
         ///
         /// <p>NOTE: the provided BytesRef is not copied so be sure
         /// not to change it until you're done with this field.
@@ -954,13 +932,13 @@ namespace Lucene.Net.Documents
         }
 
         [Obsolete("Use StoredField instead.")]
-        public Field(String name, sbyte[] value)
+        public Field(String name, byte[] value)
             : this(name, value, TranslateFieldType(Store.YES, Index.NO, TermVector.NO))
         {
         }
 
         [Obsolete("Use StoredField instead.")]
-        public Field(String name, sbyte[] value, int offset, int length)
+        public Field(String name, byte[] value, int offset, int length)
             : this(name, value, offset, length, TranslateFieldType(Store.YES, Index.NO, TermVector.NO))
         {
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Document/StoredField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Document/StoredField.cs b/src/Lucene.Net.Core/Document/StoredField.cs
index 860a56a..c682d76 100644
--- a/src/Lucene.Net.Core/Document/StoredField.cs
+++ b/src/Lucene.Net.Core/Document/StoredField.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Documents
         /// <param name="name"> field name </param>
         /// <param name="value"> byte array pointing to binary content (not copied) </param>
         /// <exception cref="IllegalArgumentException"> if the field name is null. </exception>
-        public StoredField(string name, sbyte[] value)
+        public StoredField(string name, byte[] value)
             : base(name, value, TYPE)
         {
         }
@@ -63,7 +63,7 @@ namespace Lucene.Net.Documents
         /// <param name="offset"> starting position of the byte array </param>
         /// <param name="length"> valid length of the byte array </param>
         /// <exception cref="IllegalArgumentException"> if the field name is null. </exception>
-        public StoredField(string name, sbyte[] value, int offset, int length)
+        public StoredField(string name, byte[] value, int offset, int length)
             : base(name, value, offset, length, TYPE)
         {
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs b/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
index e3cbd13..78da520 100644
--- a/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
+++ b/src/Lucene.Net.Core/Index/AutomatonTermsEnum.cs
@@ -186,10 +186,10 @@ namespace Lucene.Net.Index
                 int length = value + 1; // value + maxTransition
                 if (LinearUpperBound.Bytes.Length < length)
                 {
-                    LinearUpperBound.Bytes = new sbyte[length];
+                    LinearUpperBound.Bytes = new byte[length];
                 }
                 Array.Copy(SeekBytesRef.Bytes, 0, LinearUpperBound.Bytes, 0, value);
-                LinearUpperBound.Bytes[value] = (sbyte)maxInterval;
+                LinearUpperBound.Bytes[value] = (byte)maxInterval;
                 LinearUpperBound.Length = length;
 
                 Linear_Renamed = true;
@@ -318,7 +318,7 @@ namespace Lucene.Net.Index
                     // append either the next sequential char, or the minimum transition
                     SeekBytesRef.Grow(SeekBytesRef.Length + 1);
                     SeekBytesRef.Length++;
-                    SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (sbyte)nextChar;
+                    SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (byte)nextChar;
                     state = transition.Dest.Number;
                     /*
                      * as long as is possible, continue down the minimal path in
@@ -338,7 +338,7 @@ namespace Lucene.Net.Index
                         // append the minimum transition
                         SeekBytesRef.Grow(SeekBytesRef.Length + 1);
                         SeekBytesRef.Length++;
-                        SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (sbyte)transition.Min;
+                        SeekBytesRef.Bytes[SeekBytesRef.Length - 1] = (byte)transition.Min;
 
                         // we found a loop, record it for faster enumeration
                         if ((Finite == false) && !Linear_Renamed && Visited[state] == CurGen)
@@ -368,7 +368,7 @@ namespace Lucene.Net.Index
                 // because there is no higher character in binary sort order.
                 if (nextChar++ != 0xff)
                 {
-                    SeekBytesRef.Bytes[position] = (sbyte)nextChar;
+                    SeekBytesRef.Bytes[position] = (byte)nextChar;
                     SeekBytesRef.Length = position + 1;
                     return position;
                 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/ByteSliceReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/ByteSliceReader.cs b/src/Lucene.Net.Core/Index/ByteSliceReader.cs
index 410c20d..e432e93 100644
--- a/src/Lucene.Net.Core/Index/ByteSliceReader.cs
+++ b/src/Lucene.Net.Core/Index/ByteSliceReader.cs
@@ -35,7 +35,7 @@ namespace Lucene.Net.Index
     {
         internal ByteBlockPool Pool;
         internal int BufferUpto;
-        internal sbyte[] Buffer;
+        internal byte[] Buffer;
         public int Upto;
         internal int Limit;
         internal int Level;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/ByteSliceWriter.cs b/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
index 283d93d..a6adbab 100644
--- a/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
+++ b/src/Lucene.Net.Core/Index/ByteSliceWriter.cs
@@ -30,7 +30,7 @@ namespace Lucene.Net.Index
 
     public sealed class ByteSliceWriter : DataOutput
     {
-        private sbyte[] Slice;
+        private byte[] Slice;
         private int Upto;
         private readonly ByteBlockPool Pool;
 
@@ -65,7 +65,7 @@ namespace Lucene.Net.Index
                 Offset0 = Pool.ByteOffset;
                 Debug.Assert(Slice != null);
             }
-            Slice[Upto++] = (sbyte)b;
+            Slice[Upto++] = (byte)b;
             Debug.Assert(Upto != Slice.Length);
         }
 
@@ -82,7 +82,7 @@ namespace Lucene.Net.Index
                     Offset0 = Pool.ByteOffset;
                 }
 
-                Slice[Upto++] = (sbyte)b[offset++];
+                Slice[Upto++] = (byte)b[offset++];
                 Debug.Assert(Upto != Slice.Length);
             }
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs b/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
index c1553d5..42cf537 100644
--- a/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
+++ b/src/Lucene.Net.Core/Index/FreqProxTermsWriterPerField.cs
@@ -615,7 +615,7 @@ namespace Lucene.Net.Index
                                     if (Payload == null)
                                     {
                                         Payload = new BytesRef();
-                                        Payload.Bytes = new sbyte[payloadLength];
+                                        Payload.Bytes = new byte[payloadLength];
                                     }
                                     else if (Payload.Bytes.Length < payloadLength)
                                     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs b/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
index 8b51089..6b0ec4c 100644
--- a/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
+++ b/src/Lucene.Net.Core/Index/SortedDocValuesTermsEnum.cs
@@ -51,7 +51,7 @@ namespace Lucene.Net.Index
                 // TODO: is there a cleaner way?
                 // term.bytes may be pointing to codec-private byte[]
                 // storage, so we must force new byte[] allocation:
-                Term_Renamed.Bytes = new sbyte[text.Length];
+                Term_Renamed.Bytes = new byte[text.Length];
                 Term_Renamed.CopyBytes(text);
                 return SeekStatus.FOUND;
             }
@@ -80,7 +80,7 @@ namespace Lucene.Net.Index
                 // TODO: is there a cleaner way?
                 // term.bytes may be pointing to codec-private byte[]
                 // storage, so we must force new byte[] allocation:
-                Term_Renamed.Bytes = new sbyte[text.Length];
+                Term_Renamed.Bytes = new byte[text.Length];
                 Term_Renamed.CopyBytes(text);
                 CurrentOrd = ord;
                 return true;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs b/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
index 6595e75..bdfdcb3 100644
--- a/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
+++ b/src/Lucene.Net.Core/Index/SortedSetDocValuesTermsEnum.cs
@@ -51,7 +51,7 @@ namespace Lucene.Net.Index
                 // TODO: is there a cleaner way?
                 // term.bytes may be pointing to codec-private byte[]
                 // storage, so we must force new byte[] allocation:
-                Term_Renamed.Bytes = new sbyte[text.Length];
+                Term_Renamed.Bytes = new byte[text.Length];
                 Term_Renamed.CopyBytes(text);
                 return SeekStatus.FOUND;
             }
@@ -80,7 +80,7 @@ namespace Lucene.Net.Index
                 // TODO: is there a cleaner way?
                 // term.bytes may be pointing to codec-private byte[]
                 // storage, so we must force new byte[] allocation:
-                Term_Renamed.Bytes = new sbyte[text.Length];
+                Term_Renamed.Bytes = new byte[text.Length];
                 Term_Renamed.CopyBytes(text);
                 CurrentOrd = ord;
                 return true;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs b/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
index 94aa53a..fce544c 100644
--- a/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
+++ b/src/Lucene.Net.Core/Index/StoredFieldVisitor.cs
@@ -49,7 +49,7 @@ namespace Lucene.Net.Index
         /// <summary>
         /// Process a binary field. </summary>
         /// <param name="value"> newly allocated byte array with the binary contents.  </param>
-        public virtual void BinaryField(FieldInfo fieldInfo, sbyte[] value)
+        public virtual void BinaryField(FieldInfo fieldInfo, byte[] value)
         {
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Index/TermsHashPerField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Index/TermsHashPerField.cs b/src/Lucene.Net.Core/Index/TermsHashPerField.cs
index edcf09a..76342ca 100644
--- a/src/Lucene.Net.Core/Index/TermsHashPerField.cs
+++ b/src/Lucene.Net.Core/Index/TermsHashPerField.cs
@@ -280,8 +280,13 @@ namespace Lucene.Net.Index
 
         internal void WriteByte(int stream, sbyte b)
         {
+            WriteByte(stream, (byte)b);
+        }
+
+        internal void WriteByte(int stream, byte b)
+        {
             int upto = IntUptos[IntUptoStart + stream];
-            sbyte[] bytes = BytePool.Buffers[upto >> ByteBlockPool.BYTE_BLOCK_SHIFT];
+            var bytes = BytePool.Buffers[upto >> ByteBlockPool.BYTE_BLOCK_SHIFT];
             Debug.Assert(bytes != null);
             int offset = upto & ByteBlockPool.BYTE_BLOCK_MASK;
             if (bytes[offset] != 0)
@@ -295,7 +300,7 @@ namespace Lucene.Net.Index
             (IntUptos[IntUptoStart + stream])++;
         }
 
-        public void WriteBytes(int stream, sbyte[] b, int offset, int len)
+        public void WriteBytes(int stream, byte[] b, int offset, int len)
         {
             // TODO: optimize
             int end = offset + len;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/FieldComparator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/FieldComparator.cs b/src/Lucene.Net.Core/Search/FieldComparator.cs
index 4f6a760..32bf9f0 100644
--- a/src/Lucene.Net.Core/Search/FieldComparator.cs
+++ b/src/Lucene.Net.Core/Search/FieldComparator.cs
@@ -1412,9 +1412,9 @@ namespace Lucene.Net.Search
         public sealed class TermValComparator : FieldComparator<BytesRef>
         {
             // sentinels, just used internally in this comparator
-            internal static readonly sbyte[] MISSING_BYTES = new sbyte[0];
+            internal static readonly byte[] MISSING_BYTES = new byte[0];
 
-            internal static readonly sbyte[] NON_MISSING_BYTES = new sbyte[0];
+            internal static readonly byte[] NON_MISSING_BYTES = new byte[0];
 
             internal BytesRef[] Values;
             internal BinaryDocValues DocTerms;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs b/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
index 081a19d..d87c277 100644
--- a/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
+++ b/src/Lucene.Net.Core/Search/Payloads/PayloadNearQuery.cs
@@ -224,23 +224,28 @@ namespace Lucene.Net.Search.Payloads
             // Get the payloads associated with all underlying subspans
             public virtual void GetPayloads(Spans[] subSpans)
             {
-                for (int i = 0; i < subSpans.Length; i++)
+                for (var i = 0; i < subSpans.Length; i++)
                 {
-                    if (subSpans[i] is NearSpansOrdered)
+                    var span = subSpans[i] as NearSpansOrdered;
+                    if (span != null)
                     {
-                        if (((NearSpansOrdered)subSpans[i]).PayloadAvailable)
+                        if (span.PayloadAvailable)
                         {
-                            ProcessPayloads(((NearSpansOrdered)subSpans[i]).Payload, subSpans[i].Start(), subSpans[i].End());
+                            ProcessPayloads(span.Payload, subSpans[i].Start(), subSpans[i].End());
                         }
-                        GetPayloads(((NearSpansOrdered)subSpans[i]).SubSpans);
+                        GetPayloads(span.SubSpans);
                     }
-                    else if (subSpans[i] is NearSpansUnordered)
+                    else
                     {
-                        if (((NearSpansUnordered)subSpans[i]).PayloadAvailable)
+                        var unordered = subSpans[i] as NearSpansUnordered;
+                        if (unordered != null)
                         {
-                            ProcessPayloads(((NearSpansUnordered)subSpans[i]).Payload, subSpans[i].Start(), subSpans[i].End());
+                            if (unordered.PayloadAvailable)
+                            {
+                                ProcessPayloads(unordered.Payload, subSpans[i].Start(), subSpans[i].End());
+                            }
+                            GetPayloads(unordered.SubSpans);
                         }
-                        GetPayloads(((NearSpansUnordered)subSpans[i]).SubSpans);
                     }
                 }
             }
@@ -257,9 +262,9 @@ namespace Lucene.Net.Search.Payloads
             /// <param name="end"> The end position of the span being scored
             /// </param>
             /// <seealso cref= Spans </seealso>
-            protected internal virtual void ProcessPayloads(ICollection<sbyte[]> payLoads, int start, int end)
+            protected internal virtual void ProcessPayloads(ICollection<byte[]> payLoads, int start, int end)
             {
-                foreach (sbyte[] thePayload in payLoads)
+                foreach (var thePayload in payLoads)
                 {
                     Scratch.Bytes = thePayload;
                     Scratch.Offset = 0;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs b/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
index 3772a1d..8d7a4e5 100644
--- a/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
+++ b/src/Lucene.Net.Core/Search/Payloads/PayloadSpanUtil.cs
@@ -1,4 +1,5 @@
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
 
 namespace Lucene.Net.Search.Payloads
@@ -59,14 +60,14 @@ namespace Lucene.Net.Search.Payloads
         /// <param name="query"> rewritten query </param>
         /// <returns> payloads Collection </returns>
         /// <exception cref="IOException"> if there is a low-level I/O error </exception>
-        public virtual ICollection<sbyte[]> GetPayloadsForQuery(Query query)
+        public virtual ICollection<byte[]> GetPayloadsForQuery(Query query)
         {
-            ICollection<sbyte[]> payloads = new List<sbyte[]>();
+            var payloads = new List<byte[]>();
             QueryToSpanQuery(query, payloads);
             return payloads;
         }
 
-        private void QueryToSpanQuery(Query query, ICollection<sbyte[]> payloads)
+        private void QueryToSpanQuery(Query query, ICollection<byte[]> payloads)
         {
             if (query is BooleanQuery)
             {
@@ -183,10 +184,10 @@ namespace Lucene.Net.Search.Payloads
             }
         }
 
-        private void GetPayloads(ICollection<sbyte[]> payloads, SpanQuery query)
+        private void GetPayloads(ICollection<byte[]> payloads, SpanQuery query)
         {
             IDictionary<Term, TermContext> termContexts = new Dictionary<Term, TermContext>();
-            SortedSet<Term> terms = new SortedSet<Term>();
+            var terms = new SortedSet<Term>();
             query.ExtractTerms(terms);
             foreach (Term term in terms)
             {
@@ -199,8 +200,8 @@ namespace Lucene.Net.Search.Payloads
                 {
                     if (spans.PayloadAvailable)
                     {
-                        ICollection<sbyte[]> payload = spans.Payload;
-                        foreach (sbyte[] bytes in payload)
+                        var payload = spans.Payload;
+                        foreach (var bytes in payload)
                         {
                             payloads.Add(bytes);
                         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs b/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
index 76110e5..6089a20 100644
--- a/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
+++ b/src/Lucene.Net.Core/Search/Spans/NearSpansOrdered.cs
@@ -70,7 +70,7 @@ namespace Lucene.Net.Search.Spans
         private int MatchDoc = -1;
         private int MatchStart = -1;
         private int MatchEnd = -1;
-        private List<sbyte[]> MatchPayload;
+        private List<byte[]> MatchPayload;
 
         private readonly Spans[] SubSpansByDoc;
 
@@ -80,7 +80,7 @@ namespace Lucene.Net.Search.Spans
 
         private class InPlaceMergeSorterAnonymousInnerClassHelper : InPlaceMergeSorter
         {
-            private NearSpansOrdered OuterInstance;
+            private readonly NearSpansOrdered OuterInstance;
 
             public InPlaceMergeSorterAnonymousInnerClassHelper(NearSpansOrdered outerInstance)
             {
@@ -117,7 +117,7 @@ namespace Lucene.Net.Search.Spans
             AllowedSlop = spanNearQuery.Slop;
             SpanQuery[] clauses = spanNearQuery.Clauses;
             subSpans = new Spans[clauses.Length];
-            MatchPayload = new List<sbyte[]>();
+            MatchPayload = new List<byte[]>();
             SubSpansByDoc = new Spans[clauses.Length];
             for (int i = 0; i < clauses.Length; i++)
             {
@@ -155,7 +155,7 @@ namespace Lucene.Net.Search.Spans
 
         // TODO: Remove warning after API has been finalized
         // TODO: Would be nice to be able to lazy load payloads
-        public override ICollection<sbyte[]> Payload
+        public override ICollection<byte[]> Payload
         {
             get
             {
@@ -344,14 +344,14 @@ namespace Lucene.Net.Search.Spans
         {
             MatchStart = subSpans[subSpans.Length - 1].Start();
             MatchEnd = subSpans[subSpans.Length - 1].End();
-            HashSet<sbyte[]> possibleMatchPayloads = new HashSet<sbyte[]>();
+            var possibleMatchPayloads = new HashSet<byte[]>();
             if (subSpans[subSpans.Length - 1].PayloadAvailable)
             {
                 //LUCENE TO-DO UnionWith or AddAll(Set<>, IEnumerable<>)
                 possibleMatchPayloads.UnionWith(subSpans[subSpans.Length - 1].Payload);
             }
 
-            IList<sbyte[]> possiblePayload = null;
+            IList<byte[]> possiblePayload = null;
 
             int matchSlop = 0;
             int lastStart = MatchStart;
@@ -361,8 +361,8 @@ namespace Lucene.Net.Search.Spans
                 Spans prevSpans = subSpans[i];
                 if (CollectPayloads && prevSpans.PayloadAvailable)
                 {
-                    ICollection<sbyte[]> payload = prevSpans.Payload;
-                    possiblePayload = new List<sbyte[]>(payload.Count);
+                    var payload = prevSpans.Payload;
+                    possiblePayload = new List<byte[]>(payload.Count);
                     possiblePayload.AddRange(payload);
                 }
 
@@ -395,8 +395,8 @@ namespace Lucene.Net.Search.Spans
                             prevEnd = ppEnd;
                             if (CollectPayloads && prevSpans.PayloadAvailable)
                             {
-                                ICollection<sbyte[]> payload = prevSpans.Payload;
-                                possiblePayload = new List<sbyte[]>(payload.Count);
+                                var payload = prevSpans.Payload;
+                                possiblePayload = new List<byte[]>(payload.Count);
                                 possiblePayload.AddRange(payload);
                             }
                         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs b/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
index 7a63670..12905a4 100644
--- a/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
+++ b/src/Lucene.Net.Core/Search/Spans/NearSpansUnordered.cs
@@ -140,11 +140,11 @@ namespace Lucene.Net.Search.Spans
                 return Spans.End();
             }
 
-            public override ICollection<sbyte[]> Payload
+            public override ICollection<byte[]> Payload
             {
                 get
                 {
-                    return new List<sbyte[]>(Spans.Payload);
+                    return new List<byte[]>(Spans.Payload);
                 }
             }
 
@@ -315,12 +315,12 @@ namespace Lucene.Net.Search.Spans
             return Max.End();
         }
 
-        public override ICollection<sbyte[]> Payload
+        public override ICollection<byte[]> Payload
         {
             get
             {
-                HashSet<sbyte[]> matchPayload = new HashSet<sbyte[]>();
-                for (SpansCell cell = First; cell != null; cell = cell.Next_Renamed)
+                var matchPayload = new HashSet<byte[]>();
+                for (var cell = First; cell != null; cell = cell.Next_Renamed)
                 {
                     if (cell.PayloadAvailable)
                     {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs b/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
index bbaa8cc..47251dc 100644
--- a/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
+++ b/src/Lucene.Net.Core/Search/Spans/SpanNearPayloadCheckQuery.cs
@@ -32,11 +32,11 @@ namespace Lucene.Net.Search.Spans
     /// </summary>
     public class SpanNearPayloadCheckQuery : SpanPositionCheckQuery
     {
-        protected internal readonly ICollection<sbyte[]> PayloadToMatch;
+        protected internal readonly ICollection<byte[]> PayloadToMatch;
 
         /// <param name="match">          The underlying <seealso cref="SpanQuery"/> to check </param>
         /// <param name="payloadToMatch"> The <seealso cref="java.util.Collection"/> of payloads to match </param>
-        public SpanNearPayloadCheckQuery(SpanNearQuery match, ICollection<sbyte[]> payloadToMatch)
+        public SpanNearPayloadCheckQuery(SpanNearQuery match, ICollection<byte[]> payloadToMatch)
             : base(match)
         {
             this.PayloadToMatch = payloadToMatch;
@@ -47,16 +47,16 @@ namespace Lucene.Net.Search.Spans
             bool result = spans.PayloadAvailable;
             if (result == true)
             {
-                ICollection<sbyte[]> candidate = spans.Payload;
+                var candidate = spans.Payload;
                 if (candidate.Count == PayloadToMatch.Count)
                 {
                     //TODO: check the byte arrays are the same
                     //hmm, can't rely on order here
                     int matches = 0;
-                    foreach (sbyte[] candBytes in candidate)
+                    foreach (var candBytes in candidate)
                     {
                         //Unfortunately, we can't rely on order, so we need to compare all
-                        foreach (sbyte[] payBytes in PayloadToMatch)
+                        foreach (var payBytes in PayloadToMatch)
                         {
                             if (Arrays.Equals(candBytes, payBytes) == true)
                             {
@@ -89,7 +89,7 @@ namespace Lucene.Net.Search.Spans
             buffer.Append("spanPayCheck(");
             buffer.Append(match.ToString(field));
             buffer.Append(", payloadRef: ");
-            foreach (sbyte[] bytes in PayloadToMatch)
+            foreach (var bytes in PayloadToMatch)
             {
                 ToStringUtils.ByteArray(buffer, bytes);
                 buffer.Append(';');


[2/5] lucenenet git commit: Getting rid of most sbyte usage in public API

Posted by sy...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs b/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs
index 16e524a..9e49efa 100644
--- a/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs
+++ b/src/Lucene.Net.Core/Util/Packed/BulkOperationPackedSingleBlock.cs
@@ -55,9 +55,12 @@ namespace Lucene.Net.Util.Packed
             return ValueCount;
         }
 
-        private static long ReadLong(sbyte[] blocks, int blocksOffset)
+        private static long ReadLong(byte[] blocks, int blocksOffset)
         {
-            return (blocks[blocksOffset++] & 0xFFL) << 56 | (blocks[blocksOffset++] & 0xFFL) << 48 | (blocks[blocksOffset++] & 0xFFL) << 40 | (blocks[blocksOffset++] & 0xFFL) << 32 | (blocks[blocksOffset++] & 0xFFL) << 24 | (blocks[blocksOffset++] & 0xFFL) << 16 | (blocks[blocksOffset++] & 0xFFL) << 8 | blocks[blocksOffset++] & 0xFFL;
+            return (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 56 | (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 48 | 
+                (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 40 | (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 32 |
+                (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 24 | (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 16 |
+                (((sbyte)blocks[blocksOffset++]) & 0xFFL) << 8 | ((sbyte)blocks[blocksOffset++]) & 0xFFL;
         }
 
         private int Decode(long block, long[] values, int valuesOffset)
@@ -111,7 +114,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -134,7 +137,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
+        public override void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations)
         {
             if (BitsPerValue > 32)
             {
@@ -166,7 +169,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Encode(long[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations)
+        public override void Encode(long[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {
@@ -176,7 +179,7 @@ namespace Lucene.Net.Util.Packed
             }
         }
 
-        public override void Encode(int[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations)
+        public override void Encode(int[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations)
         {
             for (int i = 0; i < iterations; ++i)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/PackedInts.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/PackedInts.cs b/src/Lucene.Net.Core/Util/Packed/PackedInts.cs
index 5b6d90d..dd365b7 100644
--- a/src/Lucene.Net.Core/Util/Packed/PackedInts.cs
+++ b/src/Lucene.Net.Core/Util/Packed/PackedInts.cs
@@ -491,7 +491,7 @@ namespace Lucene.Net.Util.Packed
             /// <param name="values">       the values buffer </param>
             /// <param name="valuesOffset"> the offset where to start writing values </param>
             /// <param name="iterations">   controls how much data to decode </param>
-            void Decode(sbyte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations);
+            void Decode(byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations);
 
             /// <summary>
             /// Read <code>iterations * blockCount()</code> blocks from <code>blocks</code>,
@@ -515,7 +515,7 @@ namespace Lucene.Net.Util.Packed
             /// <param name="values">       the values buffer </param>
             /// <param name="valuesOffset"> the offset where to start writing values </param>
             /// <param name="iterations">   controls how much data to decode </param>
-            void Decode(sbyte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations);
+            void Decode(byte[] blocks, int blocksOffset, int[] values, int valuesOffset, int iterations);
         }
 
         /// <summary>
@@ -569,7 +569,7 @@ namespace Lucene.Net.Util.Packed
             /// <param name="values">       the values buffer </param>
             /// <param name="valuesOffset"> the offset where to start reading values </param>
             /// <param name="iterations">   controls how much data to encode </param>
-            void Encode(long[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations);
+            void Encode(long[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations);
 
             /// <summary>
             /// Read <code>iterations * valueCount()</code> values from <code>values</code>,
@@ -593,7 +593,7 @@ namespace Lucene.Net.Util.Packed
             /// <param name="values">       the values buffer </param>
             /// <param name="valuesOffset"> the offset where to start reading values </param>
             /// <param name="iterations">   controls how much data to encode </param>
-            void Encode(int[] values, int valuesOffset, sbyte[] blocks, int blocksOffset, int iterations);
+            void Encode(int[] values, int valuesOffset, byte[] blocks, int blocksOffset, int iterations);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/PackedReaderIterator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/PackedReaderIterator.cs b/src/Lucene.Net.Core/Util/Packed/PackedReaderIterator.cs
index 68f9fcb..eaa27a0 100644
--- a/src/Lucene.Net.Core/Util/Packed/PackedReaderIterator.cs
+++ b/src/Lucene.Net.Core/Util/Packed/PackedReaderIterator.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Util.Packed
         internal readonly int PackedIntsVersion;
         internal readonly PackedInts.Format Format;
         internal readonly BulkOperation BulkOperation;
-        internal readonly sbyte[] NextBlocks;
+        internal readonly byte[] NextBlocks;
         internal readonly LongsRef NextValues;
         internal readonly int Iterations_Renamed;
         internal int Position;
@@ -42,7 +42,7 @@ namespace Lucene.Net.Util.Packed
             BulkOperation = BulkOperation.Of(format, bitsPerValue);
             Iterations_Renamed = Iterations(mem);
             Debug.Assert(valueCount == 0 || Iterations_Renamed > 0);
-            NextBlocks = new sbyte[Iterations_Renamed * BulkOperation.ByteBlockCount()];
+            NextBlocks = new byte[Iterations_Renamed * BulkOperation.ByteBlockCount()];
             NextValues = new LongsRef(new long[Iterations_Renamed * BulkOperation.ByteValueCount()], 0, 0);
             NextValues.Offset = NextValues.Longs.Length;
             Position = -1;
@@ -81,7 +81,7 @@ namespace Lucene.Net.Util.Packed
                 @in.ReadBytes(NextBlocks, 0, blocksToRead);
                 if (blocksToRead < NextBlocks.Length)
                 {
-                    Arrays.Fill(NextBlocks, blocksToRead, NextBlocks.Length, (sbyte)0);
+                    Arrays.Fill(NextBlocks, blocksToRead, NextBlocks.Length, (byte)0);
                 }
 
                 BulkOperation.Decode(NextBlocks, 0, NextValues.Longs, 0, Iterations_Renamed);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/Packed/PackedWriter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Packed/PackedWriter.cs b/src/Lucene.Net.Core/Util/Packed/PackedWriter.cs
index fa41e38..68e0c8c 100644
--- a/src/Lucene.Net.Core/Util/Packed/PackedWriter.cs
+++ b/src/Lucene.Net.Core/Util/Packed/PackedWriter.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Util.Packed
         internal bool Finished;
         internal readonly PackedInts.Format Format_Renamed;
         internal readonly BulkOperation Encoder;
-        internal readonly sbyte[] NextBlocks;
+        internal readonly byte[] NextBlocks;
         internal readonly long[] NextValues;
         internal readonly int Iterations;
         internal int Off;
@@ -43,7 +43,7 @@ namespace Lucene.Net.Util.Packed
             this.Format_Renamed = format;
             Encoder = BulkOperation.Of(format, bitsPerValue);
             Iterations = Encoder.ComputeIterations(valueCount, mem);
-            NextBlocks = new sbyte[Iterations * Encoder.ByteBlockCount()];
+            NextBlocks = new byte[Iterations * Encoder.ByteBlockCount()];
             NextValues = new long[Iterations * Encoder.ByteValueCount()];
             Off = 0;
             Written = 0;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/PagedBytes.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/PagedBytes.cs b/src/Lucene.Net.Core/Util/PagedBytes.cs
index 348754c..c806ebb 100644
--- a/src/Lucene.Net.Core/Util/PagedBytes.cs
+++ b/src/Lucene.Net.Core/Util/PagedBytes.cs
@@ -38,7 +38,7 @@ namespace Lucene.Net.Util
     // other "shift/mask big arrays". there are too many of these classes!
     public sealed class PagedBytes
     {
-        private readonly IList<sbyte[]> Blocks = new List<sbyte[]>();
+        private readonly IList<byte[]> Blocks = new List<byte[]>();
 
         // TODO: these are unused?
         private readonly IList<int> BlockEnd = new List<int>();
@@ -49,10 +49,10 @@ namespace Lucene.Net.Util
         private bool DidSkipBytes;
         private bool Frozen;
         private int Upto;
-        private sbyte[] CurrentBlock;
+        private byte[] CurrentBlock;
         private readonly long BytesUsedPerBlock;
 
-        private static readonly sbyte[] EMPTY_BYTES = new sbyte[0];
+        private static readonly byte[] EMPTY_BYTES = new byte[0];
 
         /// <summary>
         /// Provides methods to read BytesRefs from a frozen
@@ -61,7 +61,7 @@ namespace Lucene.Net.Util
         /// <seealso cref= #freeze  </seealso>
         public sealed class Reader
         {
-            internal readonly sbyte[][] Blocks;
+            internal readonly byte[][] Blocks;
             internal readonly int[] BlockEnds;
             internal readonly int BlockBits;
             internal readonly int BlockMask;
@@ -69,8 +69,8 @@ namespace Lucene.Net.Util
 
             internal Reader(PagedBytes pagedBytes)
             {
-                Blocks = new sbyte[pagedBytes.Blocks.Count][];
-                for (int i = 0; i < Blocks.Length; i++)
+                Blocks = new byte[pagedBytes.Blocks.Count][];
+                for (var i = 0; i < Blocks.Length; i++)
                 {
                     Blocks[i] = pagedBytes.Blocks[i];
                 }
@@ -103,8 +103,8 @@ namespace Lucene.Net.Util
                 {
                     return;
                 }
-                int index = (int)(start >> BlockBits);
-                int offset = (int)(start & BlockMask);
+                var index = (int)(start >> BlockBits);
+                var offset = (int)(start & BlockMask);
                 if (BlockSize - offset >= length)
                 {
                     // Within block
@@ -114,7 +114,7 @@ namespace Lucene.Net.Util
                 else
                 {
                     // Split
-                    b.Bytes = new sbyte[length];
+                    b.Bytes = new byte[length];
                     b.Offset = 0;
                     Array.Copy(Blocks[index], offset, b.Bytes, 0, BlockSize - offset);
                     Array.Copy(Blocks[1 + index], 0, b.Bytes, BlockSize - offset, length - (BlockSize - offset));
@@ -134,9 +134,9 @@ namespace Lucene.Net.Util
             // TODO: this really needs to be refactored into fieldcacheimpl
             public void Fill(BytesRef b, long start)
             {
-                int index = (int)(start >> BlockBits);
-                int offset = (int)(start & BlockMask);
-                sbyte[] block = b.Bytes = Blocks[index];
+                var index = (int)(start >> BlockBits);
+                var offset = (int)(start & BlockMask);
+                var block = b.Bytes = Blocks[index];
 
                 if ((block[offset] & 128) == 0)
                 {
@@ -187,7 +187,7 @@ namespace Lucene.Net.Util
                         Blocks.Add(CurrentBlock);
                         BlockEnd.Add(Upto);
                     }
-                    CurrentBlock = new sbyte[BlockSize];
+                    CurrentBlock = new byte[BlockSize];
                     Upto = 0;
                     left = BlockSize;
                 }
@@ -222,7 +222,7 @@ namespace Lucene.Net.Util
                     BlockEnd.Add(Upto);
                     DidSkipBytes = true;
                 }
-                CurrentBlock = new sbyte[BlockSize];
+                CurrentBlock = new byte[BlockSize];
                 Upto = 0;
                 left = BlockSize;
                 Debug.Assert(bytes.Length <= BlockSize);
@@ -251,7 +251,7 @@ namespace Lucene.Net.Util
             }
             if (trim && Upto < BlockSize)
             {
-                sbyte[] newBlock = new sbyte[Upto];
+                var newBlock = new byte[Upto];
                 Array.Copy(CurrentBlock, 0, newBlock, 0, Upto);
                 CurrentBlock = newBlock;
             }
@@ -311,7 +311,7 @@ namespace Lucene.Net.Util
                     Blocks.Add(CurrentBlock);
                     BlockEnd.Add(Upto);
                 }
-                CurrentBlock = new sbyte[BlockSize];
+                CurrentBlock = new byte[BlockSize];
                 Upto = 0;
             }
 
@@ -319,12 +319,12 @@ namespace Lucene.Net.Util
 
             if (bytes.Length < 128)
             {
-                CurrentBlock[Upto++] = (sbyte)bytes.Length;
+                CurrentBlock[Upto++] = (byte)bytes.Length;
             }
             else
             {
-                CurrentBlock[Upto++] = unchecked((sbyte)(0x80 | (bytes.Length >> 8)));
-                CurrentBlock[Upto++] = unchecked((sbyte)(bytes.Length & 0xff));
+                CurrentBlock[Upto++] = unchecked((byte)(0x80 | (bytes.Length >> 8)));
+                CurrentBlock[Upto++] = unchecked((byte)(bytes.Length & 0xff));
             }
             Array.Copy(bytes.Bytes, bytes.Offset, CurrentBlock, Upto, bytes.Length);
             Upto += bytes.Length;
@@ -338,7 +338,7 @@ namespace Lucene.Net.Util
 
             internal int CurrentBlockIndex;
             internal int CurrentBlockUpto;
-            internal sbyte[] CurrentBlock;
+            internal byte[] CurrentBlock;
 
             internal PagedBytesDataInput(PagedBytes outerInstance)
             {
@@ -428,10 +428,10 @@ namespace Lucene.Net.Util
                         OuterInstance.Blocks.Add(OuterInstance.CurrentBlock);
                         OuterInstance.BlockEnd.Add(OuterInstance.Upto);
                     }
-                    OuterInstance.CurrentBlock = new sbyte[OuterInstance.BlockSize];
+                    OuterInstance.CurrentBlock = new byte[OuterInstance.BlockSize];
                     OuterInstance.Upto = 0;
                 }
-                OuterInstance.CurrentBlock[OuterInstance.Upto++] = (sbyte)b;
+                OuterInstance.CurrentBlock[OuterInstance.Upto++] = (byte)b;
             }
 
             public override void WriteBytes(byte[] b, int offset, int length)
@@ -449,7 +449,7 @@ namespace Lucene.Net.Util
                         OuterInstance.Blocks.Add(OuterInstance.CurrentBlock);
                         OuterInstance.BlockEnd.Add(OuterInstance.Upto);
                     }
-                    OuterInstance.CurrentBlock = new sbyte[OuterInstance.BlockSize];
+                    OuterInstance.CurrentBlock = new byte[OuterInstance.BlockSize];
                     OuterInstance.Upto = 0;
                 }
 
@@ -463,7 +463,7 @@ namespace Lucene.Net.Util
                         System.Buffer.BlockCopy(b, offset, OuterInstance.CurrentBlock, OuterInstance.Upto, blockLeft);
                         OuterInstance.Blocks.Add(OuterInstance.CurrentBlock);
                         OuterInstance.BlockEnd.Add(OuterInstance.BlockSize);
-                        OuterInstance.CurrentBlock = new sbyte[OuterInstance.BlockSize];
+                        OuterInstance.CurrentBlock = new byte[OuterInstance.BlockSize];
                         OuterInstance.Upto = 0;
                         offset += blockLeft;
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/RecyclingByteBlockAllocator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/RecyclingByteBlockAllocator.cs b/src/Lucene.Net.Core/Util/RecyclingByteBlockAllocator.cs
index f099580..aaefe07 100644
--- a/src/Lucene.Net.Core/Util/RecyclingByteBlockAllocator.cs
+++ b/src/Lucene.Net.Core/Util/RecyclingByteBlockAllocator.cs
@@ -33,7 +33,7 @@ namespace Lucene.Net.Util
     /// </summary>
     public sealed class RecyclingByteBlockAllocator : ByteBlockPool.Allocator
     {
-        private sbyte[][] FreeByteBlocks;
+        private byte[][] FreeByteBlocks;
         private readonly int MaxBufferedBlocks_Renamed;
         private int FreeBlocks_Renamed = 0;
         private readonly Counter BytesUsed_Renamed;
@@ -51,7 +51,7 @@ namespace Lucene.Net.Util
         public RecyclingByteBlockAllocator(int blockSize, int maxBufferedBlocks, Counter bytesUsed)
             : base(blockSize)
         {
-            FreeByteBlocks = new sbyte[maxBufferedBlocks][];
+            FreeByteBlocks = new byte[maxBufferedBlocks][];
             this.MaxBufferedBlocks_Renamed = maxBufferedBlocks;
             this.BytesUsed_Renamed = bytesUsed;
         }
@@ -79,28 +79,28 @@ namespace Lucene.Net.Util
         {
         }
 
-        public override sbyte[] ByteBlock
+        public override byte[] ByteBlock
         {
             get
             {
                 if (FreeBlocks_Renamed == 0)
                 {
                     BytesUsed_Renamed.AddAndGet(BlockSize);
-                    return new sbyte[BlockSize];
+                    return new byte[BlockSize];
                 }
-                sbyte[] b = FreeByteBlocks[--FreeBlocks_Renamed];
+                var b = FreeByteBlocks[--FreeBlocks_Renamed];
                 FreeByteBlocks[FreeBlocks_Renamed] = null;
                 return b;
             }
         }
 
-        public override void RecycleByteBlocks(sbyte[][] blocks, int start, int end)
+        public override void RecycleByteBlocks(byte[][] blocks, int start, int end)
         {
             int numBlocks = Math.Min(MaxBufferedBlocks_Renamed - FreeBlocks_Renamed, end - start);
             int size = FreeBlocks_Renamed + numBlocks;
             if (size >= FreeByteBlocks.Length)
             {
-                sbyte[][] newBlocks = new sbyte[ArrayUtil.Oversize(size, RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
+                var newBlocks = new byte[ArrayUtil.Oversize(size, RamUsageEstimator.NUM_BYTES_OBJECT_REF)][];
                 Array.Copy(FreeByteBlocks, 0, newBlocks, 0, FreeBlocks_Renamed);
                 FreeByteBlocks = newBlocks;
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/StringHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/StringHelper.cs b/src/Lucene.Net.Core/Util/StringHelper.cs
index 506f28d..fee7def 100644
--- a/src/Lucene.Net.Core/Util/StringHelper.cs
+++ b/src/Lucene.Net.Core/Util/StringHelper.cs
@@ -38,9 +38,9 @@ namespace Lucene.Net.Util
         public static int BytesDifference(BytesRef left, BytesRef right)
         {
             int len = left.Length < right.Length ? left.Length : right.Length;
-            sbyte[] bytesLeft = left.Bytes;
+            var bytesLeft = left.Bytes;
             int offLeft = left.Offset;
-            sbyte[] bytesRight = right.Bytes;
+            var bytesRight = right.Bytes;
             int offRight = right.Offset;
             for (int i = 0; i < len; i++)
             {
@@ -213,7 +213,7 @@ namespace Lucene.Net.Util
         /// Returns the MurmurHash3_x86_32 hash.
         /// Original source/tests at https://github.com/yonik/java_util/
         /// </summary>
-        public static int Murmurhash3_x86_32(sbyte[] data, int offset, int len, int seed)
+        public static int Murmurhash3_x86_32(byte[] data, int offset, int len, int seed)
         {
             const int c1 = unchecked((int)0xcc9e2d51);
             const int c2 = 0x1b873593;
@@ -224,7 +224,7 @@ namespace Lucene.Net.Util
             for (int i = offset; i < roundedEnd; i += 4)
             {
                 // little endian load order
-                int k1 = (data[i] & 0xff) | ((data[i + 1] & 0xff) << 8) | ((data[i + 2] & 0xff) << 16) | (data[i + 3] << 24);
+                int k1 = (((sbyte)data[i]) & 0xff) | ((((sbyte)data[i + 1]) & 0xff) << 8) | ((((sbyte)data[i + 2]) & 0xff) << 16) | (((sbyte)data[i + 3]) << 24);
                 k1 *= c1;
                 k1 = Number.RotateLeft(k1, 15);
                 k1 *= c2;
@@ -240,15 +240,15 @@ namespace Lucene.Net.Util
             switch (len & 0x03)
             {
                 case 3:
-                    k2 = (data[roundedEnd + 2] & 0xff) << 16;
+                    k2 = (((sbyte)data[roundedEnd + 2]) & 0xff) << 16;
                     // fallthrough
                     goto case 2;
                 case 2:
-                    k2 |= (data[roundedEnd + 1] & 0xff) << 8;
+                    k2 |= (((sbyte)data[roundedEnd + 1]) & 0xff) << 8;
                     // fallthrough
                     goto case 1;
                 case 1:
-                    k2 |= (data[roundedEnd] & 0xff);
+                    k2 |= (((sbyte)data[roundedEnd]) & 0xff);
                     k2 *= c1;
                     k2 = Number.RotateLeft(k2, 15);
                     k2 *= c2;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/ToStringUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/ToStringUtils.cs b/src/Lucene.Net.Core/Util/ToStringUtils.cs
index 12d2f69..d3d97c4 100644
--- a/src/Lucene.Net.Core/Util/ToStringUtils.cs
+++ b/src/Lucene.Net.Core/Util/ToStringUtils.cs
@@ -44,7 +44,7 @@ namespace Lucene.Net.Util
             }
         }
 
-        public static void ByteArray(StringBuilder buffer, sbyte[] bytes)
+        public static void ByteArray(StringBuilder buffer, byte[] bytes)
         {
             for (int i = 0; i < bytes.Length; i++)
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Core/Util/UnicodeUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/UnicodeUtil.cs b/src/Lucene.Net.Core/Util/UnicodeUtil.cs
index aa7604e..931142f 100644
--- a/src/Lucene.Net.Core/Util/UnicodeUtil.cs
+++ b/src/Lucene.Net.Core/Util/UnicodeUtil.cs
@@ -105,7 +105,7 @@ namespace Lucene.Net.Util
         ///  WARNING: this is not a valid UTF8 Term
         ///
         /// </summary>
-        public static readonly BytesRef BIG_TERM = new BytesRef(new sbyte[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }); // TODO this is unrelated here find a better place for it
+        public static readonly BytesRef BIG_TERM = new BytesRef(new byte[] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }); // TODO this is unrelated here find a better place for it
 
         public const int UNI_SUR_HIGH_START = 0xD800;
         public const int UNI_SUR_HIGH_END = 0xDBFF;
@@ -131,12 +131,12 @@ namespace Lucene.Net.Util
             int upto = 0;
             int i = offset;
             int end = offset + length;
-            sbyte[] @out = result.Bytes;
+            var @out = result.Bytes;
             // Pre-allocate for worst case 4-for-1
             int maxLen = length * 4;
             if (@out.Length < maxLen)
             {
-                @out = result.Bytes = new sbyte[maxLen];
+                @out = result.Bytes = new byte[maxLen];
             }
             result.Offset = 0;
 
@@ -146,18 +146,18 @@ namespace Lucene.Net.Util
 
                 if (code < 0x80)
                 {
-                    @out[upto++] = (sbyte)code;
+                    @out[upto++] = (byte)code;
                 }
                 else if (code < 0x800)
                 {
-                    @out[upto++] = (sbyte)(0xC0 | (code >> 6));
-                    @out[upto++] = (sbyte)(0x80 | (code & 0x3F));
+                    @out[upto++] = (byte)(0xC0 | (code >> 6));
+                    @out[upto++] = (byte)(0x80 | (code & 0x3F));
                 }
                 else if (code < 0xD800 || code > 0xDFFF)
                 {
-                    @out[upto++] = (sbyte)(0xE0 | (code >> 12));
-                    @out[upto++] = (sbyte)(0x80 | ((code >> 6) & 0x3F));
-                    @out[upto++] = (sbyte)(0x80 | (code & 0x3F));
+                    @out[upto++] = (byte)(0xE0 | (code >> 12));
+                    @out[upto++] = (byte)(0x80 | ((code >> 6) & 0x3F));
+                    @out[upto++] = (byte)(0x80 | (code & 0x3F));
                 }
                 else
                 {
@@ -171,18 +171,18 @@ namespace Lucene.Net.Util
                         {
                             utf32 = (code << 10) + utf32 + SURROGATE_OFFSET;
                             i++;
-                            @out[upto++] = (sbyte)(0xF0 | (utf32 >> 18));
-                            @out[upto++] = (sbyte)(0x80 | ((utf32 >> 12) & 0x3F));
-                            @out[upto++] = (sbyte)(0x80 | ((utf32 >> 6) & 0x3F));
-                            @out[upto++] = (sbyte)(0x80 | (utf32 & 0x3F));
+                            @out[upto++] = (byte)(0xF0 | (utf32 >> 18));
+                            @out[upto++] = (byte)(0x80 | ((utf32 >> 12) & 0x3F));
+                            @out[upto++] = (byte)(0x80 | ((utf32 >> 6) & 0x3F));
+                            @out[upto++] = (byte)(0x80 | (utf32 & 0x3F));
                             continue;
                         }
                     }
                     // replace unpaired surrogate or out-of-order low surrogate
                     // with substitution character
-                    @out[upto++] = unchecked((sbyte)0xEF);
-                    @out[upto++] = unchecked((sbyte)0xBF);
-                    @out[upto++] = unchecked((sbyte)0xBD);
+                    @out[upto++] = unchecked((byte)0xEF);
+                    @out[upto++] = unchecked((byte)0xBF);
+                    @out[upto++] = unchecked((byte)0xBD);
                 }
             }
             //assert matches(source, offset, length, out, upto);
@@ -198,34 +198,33 @@ namespace Lucene.Net.Util
         {
             int end = offset + length;
 
-            sbyte[] @out = result.Bytes;
+            var @out = result.Bytes;
             result.Offset = 0;
             // Pre-allocate for worst case 4-for-1
             int maxLen = length * 4;
             if (@out.Length < maxLen)
             {
-                @out = result.Bytes = new sbyte[maxLen];
+                @out = result.Bytes = new byte[maxLen];
             }
 
             int upto = 0;
             for (int i = offset; i < end; i++)
             {
-                int code = (int)s[i];
-
+                var code = (int)s[i];
                 if (code < 0x80)
                 {
-                    @out[upto++] = (sbyte)code;
+                    @out[upto++] = (byte)code;
                 }
                 else if (code < 0x800)
                 {
-                    @out[upto++] = (sbyte)(0xC0 | (code >> 6));
-                    @out[upto++] = (sbyte)(0x80 | (code & 0x3F));
+                    @out[upto++] = (byte)(0xC0 | (code >> 6));
+                    @out[upto++] = (byte)(0x80 | (code & 0x3F));
                 }
                 else if (code < 0xD800 || code > 0xDFFF)
                 {
-                    @out[upto++] = (sbyte)(0xE0 | (code >> 12));
-                    @out[upto++] = (sbyte)(0x80 | ((code >> 6) & 0x3F));
-                    @out[upto++] = (sbyte)(0x80 | (code & 0x3F));
+                    @out[upto++] = (byte)(0xE0 | (code >> 12));
+                    @out[upto++] = (byte)(0x80 | ((code >> 6) & 0x3F));
+                    @out[upto++] = (byte)(0x80 | (code & 0x3F));
                 }
                 else
                 {
@@ -239,18 +238,18 @@ namespace Lucene.Net.Util
                         {
                             utf32 = (code << 10) + utf32 + SURROGATE_OFFSET;
                             i++;
-                            @out[upto++] = (sbyte)(0xF0 | (utf32 >> 18));
-                            @out[upto++] = (sbyte)(0x80 | ((utf32 >> 12) & 0x3F));
-                            @out[upto++] = (sbyte)(0x80 | ((utf32 >> 6) & 0x3F));
-                            @out[upto++] = (sbyte)(0x80 | (utf32 & 0x3F));
+                            @out[upto++] = (byte)(0xF0 | (utf32 >> 18));
+                            @out[upto++] = (byte)(0x80 | ((utf32 >> 12) & 0x3F));
+                            @out[upto++] = (byte)(0x80 | ((utf32 >> 6) & 0x3F));
+                            @out[upto++] = (byte)(0x80 | (utf32 & 0x3F));
                             continue;
                         }
                     }
                     // replace unpaired surrogate or out-of-order low surrogate
                     // with substitution character
-                    @out[upto++] = unchecked((sbyte)0xEF);
-                    @out[upto++] = unchecked((sbyte)0xBF);
-                    @out[upto++] = unchecked((sbyte)0xBD);
+                    @out[upto++] = unchecked((byte)0xEF);
+                    @out[upto++] = unchecked((byte)0xBF);
+                    @out[upto++] = unchecked((byte)0xBD);
                 }
             }
             //assert matches(s, offset, length, out, upto);
@@ -416,7 +415,7 @@ namespace Lucene.Net.Util
         {
             int pos = utf8.Offset;
             int limit = pos + utf8.Length;
-            sbyte[] bytes = utf8.Bytes;
+            var bytes = utf8.Bytes;
 
             int codePointCount = 0;
             for (; pos < limit; codePointCount++)
@@ -461,7 +460,7 @@ namespace Lucene.Net.Util
             int utf32Count = 0;
             int utf8Upto = utf8.Offset;
             int[] ints = utf32.Ints;
-            sbyte[] bytes = utf8.Bytes;
+            var bytes = utf8.Bytes;
             int utf8Limit = utf8.Offset + utf8.Length;
             while (utf8Upto < utf8Limit)
             {
@@ -584,7 +583,7 @@ namespace Lucene.Net.Util
         // for debugging
         public static string ToHexString(string s)
         {
-            StringBuilder sb = new StringBuilder();
+            var sb = new StringBuilder();
             for (int i = 0; i < s.Length; i++)
             {
                 char ch = s[i];
@@ -633,14 +632,14 @@ namespace Lucene.Net.Util
         /// Explicit checks for valid UTF-8 are not performed.
         /// </summary>
         // TODO: broken if chars.offset != 0
-        public static void UTF8toUTF16(sbyte[] utf8, int offset, int length, CharsRef chars)
+        public static void UTF8toUTF16(byte[] utf8, int offset, int length, CharsRef chars)
         {
             int out_offset = chars.Offset = 0;
             char[] @out = chars.Chars = ArrayUtil.Grow(chars.Chars, length);
             int limit = offset + length;
             while (offset < limit)
             {
-                int b = utf8[offset++] & 0xff;
+                int b = ((sbyte)utf8[offset++]) & 0xff;
                 if (b < 0xc0)
                 {
                     Debug.Assert(b < 0x80);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Queries/TermsFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Queries/TermsFilter.cs b/src/Lucene.Net.Queries/TermsFilter.cs
index 5731ec1..8355d58 100644
--- a/src/Lucene.Net.Queries/TermsFilter.cs
+++ b/src/Lucene.Net.Queries/TermsFilter.cs
@@ -47,7 +47,7 @@ namespace Lucene.Net.Queries
          * be efficient for GC and cache-lookups
          */
         private readonly int[] offsets;
-        private readonly sbyte[] termsBytes;
+        private readonly byte[] termsBytes;
         private readonly TermsAndField[] termsAndFields;
         private readonly int hashCode_Renamed; // cached hashcode for fast cache lookups
         private const int PRIME = 31;
@@ -154,7 +154,7 @@ namespace Lucene.Net.Queries
             // an automaton an call intersect on the termsenum if the density is high
 
             int hash = 9;
-            sbyte[] serializedTerms = new sbyte[0];
+            var serializedTerms = new byte[0];
             this.offsets = new int[length + 1];
             int lastEndOffset = 0;
             int index = 0;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Analysis/MockFixedLengthPayloadFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/MockFixedLengthPayloadFilter.cs b/src/Lucene.Net.TestFramework/Analysis/MockFixedLengthPayloadFilter.cs
index d4a6646..95c8db9 100644
--- a/src/Lucene.Net.TestFramework/Analysis/MockFixedLengthPayloadFilter.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/MockFixedLengthPayloadFilter.cs
@@ -29,7 +29,7 @@ namespace Lucene.Net.Analysis
     {
         private readonly IPayloadAttribute PayloadAtt;
         private readonly Random Random;
-        private readonly sbyte[] Bytes;
+        private readonly byte[] Bytes;
         private readonly BytesRef Payload;
 
         public MockFixedLengthPayloadFilter(Random random, TokenStream @in, int length)
@@ -40,7 +40,7 @@ namespace Lucene.Net.Analysis
                 throw new System.ArgumentException("length must be >= 0");
             }
             this.Random = random;
-            this.Bytes = new sbyte[length];
+            this.Bytes = new byte[length];
             this.Payload = new BytesRef(Bytes);
             this.PayloadAtt = AddAttribute<IPayloadAttribute>();
         }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Analysis/MockUTF16TermAttributeImpl.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/MockUTF16TermAttributeImpl.cs b/src/Lucene.Net.TestFramework/Analysis/MockUTF16TermAttributeImpl.cs
index 5716f1c..1f637eb 100644
--- a/src/Lucene.Net.TestFramework/Analysis/MockUTF16TermAttributeImpl.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/MockUTF16TermAttributeImpl.cs
@@ -35,7 +35,7 @@ namespace Lucene.Net.Analysis
         public override void FillBytesRef()
         {
             BytesRef bytes = BytesRef;
-            sbyte[] utf16 = (sbyte[])(Array)Charset.GetBytes(Charset.ToString());
+            var utf16 = Charset.GetBytes(Charset.ToString());
             bytes.Bytes = utf16;
             bytes.Offset = 0;
             bytes.Length = utf16.Length;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Analysis/MockVariableLengthPayloadFilter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Analysis/MockVariableLengthPayloadFilter.cs b/src/Lucene.Net.TestFramework/Analysis/MockVariableLengthPayloadFilter.cs
index 07631bf..99e4201 100644
--- a/src/Lucene.Net.TestFramework/Analysis/MockVariableLengthPayloadFilter.cs
+++ b/src/Lucene.Net.TestFramework/Analysis/MockVariableLengthPayloadFilter.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Analysis
 
         private readonly IPayloadAttribute PayloadAtt;
         private readonly Random Random;
-        private readonly sbyte[] Bytes = new sbyte[MAXLENGTH];
+        private readonly byte[] Bytes = new byte[MAXLENGTH];
         private readonly BytesRef Payload;
 
         public MockVariableLengthPayloadFilter(Random random, TokenStream @in)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Codecs/compressing/dummy/DummyCompressingCodec.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/compressing/dummy/DummyCompressingCodec.cs b/src/Lucene.Net.TestFramework/Codecs/compressing/dummy/DummyCompressingCodec.cs
index c17a20d..e2b415b 100644
--- a/src/Lucene.Net.TestFramework/Codecs/compressing/dummy/DummyCompressingCodec.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/compressing/dummy/DummyCompressingCodec.cs
@@ -68,7 +68,7 @@ namespace Lucene.Net.Codecs.Compressing.dummy
                 Debug.Assert(offset + length <= originalLength);
                 if (bytes.Bytes.Length < originalLength)
                 {
-                    bytes.Bytes = new sbyte[ArrayUtil.Oversize(originalLength, 1)];
+                    bytes.Bytes = new byte[ArrayUtil.Oversize(originalLength, 1)];
                 }
                 @in.ReadBytes(bytes.Bytes, 0, offset + length);
                 bytes.Offset = offset;
@@ -89,7 +89,7 @@ namespace Lucene.Net.Codecs.Compressing.dummy
             {
             }
 
-            public override void Compress(sbyte[] bytes, int off, int len, DataOutput @out)
+            public override void Compress(byte[] bytes, int off, int len, DataOutput @out)
             {
                 @out.WriteBytes(bytes, off, len);
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Codecs/lucene42/Lucene42DocValuesConsumer.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/lucene42/Lucene42DocValuesConsumer.cs b/src/Lucene.Net.TestFramework/Codecs/lucene42/Lucene42DocValuesConsumer.cs
index 772927a..3ef3cbf 100644
--- a/src/Lucene.Net.TestFramework/Codecs/lucene42/Lucene42DocValuesConsumer.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/lucene42/Lucene42DocValuesConsumer.cs
@@ -388,7 +388,7 @@ namespace Lucene.Net.Codecs.Lucene42
         // per-document vint-encoded byte[]
         internal class SortedSetIterator : IEnumerator<BytesRef>
         {
-            internal sbyte[] Buffer = new sbyte[10];
+            internal byte[] Buffer = new byte[10];
             internal ByteArrayDataOutput @out = new ByteArrayDataOutput();
             internal BytesRef @ref = new BytesRef();
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Codecs/ramonly/RAMOnlyPostingsFormat.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Codecs/ramonly/RAMOnlyPostingsFormat.cs b/src/Lucene.Net.TestFramework/Codecs/ramonly/RAMOnlyPostingsFormat.cs
index 455e8dc..eaa0a58 100644
--- a/src/Lucene.Net.TestFramework/Codecs/ramonly/RAMOnlyPostingsFormat.cs
+++ b/src/Lucene.Net.TestFramework/Codecs/ramonly/RAMOnlyPostingsFormat.cs
@@ -62,8 +62,8 @@ namespace Lucene.Net.Codecs.ramonly
 
             public virtual int Compare(BytesRef t1, BytesRef t2)
             {
-                sbyte[] b1 = t1.Bytes;
-                sbyte[] b2 = t2.Bytes;
+                var b1 = t1.Bytes;
+                var b2 = t2.Bytes;
                 int b1Stop;
                 int b1Upto = t1.Offset;
                 int b2Upto = t2.Offset;
@@ -258,7 +258,7 @@ namespace Lucene.Net.Codecs.ramonly
         {
             internal readonly int DocID;
             internal readonly int[] Positions;
-            internal sbyte[][] Payloads;
+            internal byte[][] Payloads;
 
             public RAMDoc(int docID, int freq)
             {
@@ -275,7 +275,7 @@ namespace Lucene.Net.Codecs.ramonly
 
                 if (Payloads != null)
                 {
-                    foreach (sbyte[] payload in Payloads)
+                    foreach (var payload in Payloads)
                     {
                         sizeInBytes += (payload != null) ? RamUsageEstimator.SizeOf(payload) : 0;
                     }
@@ -383,9 +383,9 @@ namespace Lucene.Net.Codecs.ramonly
                 {
                     if (Current.Payloads == null)
                     {
-                        Current.Payloads = new sbyte[Current.Positions.Length][];
+                        Current.Payloads = new byte[Current.Positions.Length][];
                     }
-                    sbyte[] bytes = Current.Payloads[PosUpto] = new sbyte[payload.Length];
+                    var bytes = Current.Payloads[PosUpto] = new byte[payload.Length];
                     Array.Copy(payload.Bytes, payload.Offset, bytes, 0, payload.Length);
                 }
                 PosUpto++;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/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 0bdbdbf..4e940ee 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseDocValuesFormatTestCase.cs
@@ -990,7 +990,7 @@ namespace Lucene.Net.Index
             conf.SetMergePolicy(NewLogMergePolicy());
             RandomIndexWriter iwriter = new RandomIndexWriter(Random(), directory, conf);
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[32766];
+            var bytes = new byte[32766];
             BytesRef b = new BytesRef(bytes);
             Random().NextBytes((byte[])(Array)bytes);
             doc.Add(new BinaryDocValuesField("dv", b));
@@ -1019,9 +1019,9 @@ namespace Lucene.Net.Index
             conf.SetMergePolicy(NewLogMergePolicy());
             RandomIndexWriter iwriter = new RandomIndexWriter(Random(), directory, conf);
             Document doc = new Document();
-            sbyte[] bytes = new sbyte[32766];
+            var bytes = new byte[32766];
             BytesRef b = new BytesRef(bytes);
-            Random().NextBytes((byte[])(Array)bytes);
+            Random().NextBytes(bytes);
             doc.Add(new SortedDocValuesField("dv", b));
             iwriter.AddDocument(doc);
             iwriter.Dispose();
@@ -1055,7 +1055,7 @@ namespace Lucene.Net.Index
             IndexReader ireader = DirectoryReader.Open(directory); // read-only=true
             Debug.Assert(ireader.Leaves.Count == 1);
             BinaryDocValues dv = ((AtomicReader)ireader.Leaves[0].Reader).GetBinaryDocValues("dv");
-            sbyte[] mybytes = new sbyte[20];
+            var mybytes = new byte[20];
             BytesRef scratch = new BytesRef(mybytes);
             dv.Get(0, scratch);
             Assert.AreEqual("boo!", scratch.Utf8ToString());
@@ -1083,7 +1083,7 @@ namespace Lucene.Net.Index
             IndexReader ireader = DirectoryReader.Open(directory); // read-only=true
             Debug.Assert(ireader.Leaves.Count == 1);
             BinaryDocValues dv = ((AtomicReader)ireader.Leaves[0].Reader).GetSortedDocValues("dv");
-            sbyte[] mybytes = new sbyte[20];
+            var mybytes = new byte[20];
             BytesRef scratch = new BytesRef(mybytes);
             dv.Get(0, scratch);
             Assert.AreEqual("boo!", scratch.Utf8ToString());
@@ -1585,7 +1585,7 @@ namespace Lucene.Net.Index
             RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, conf);
             Document doc = new Document();
             Field idField = new StringField("id", "", Field.Store.NO);
-            Field storedField = new StoredField("stored", new sbyte[0]);
+            Field storedField = new StoredField("stored", new byte[0]);
             Field dvField = new BinaryDocValuesField("dv", new BytesRef());
             doc.Add(idField);
             doc.Add(storedField);
@@ -1605,8 +1605,8 @@ namespace Lucene.Net.Index
                 {
                     length = TestUtil.NextInt(Random(), minLength, maxLength);
                 }
-                sbyte[] buffer = new sbyte[length];
-                Random().NextBytes((byte[])(Array)buffer);
+                var buffer = new byte[length];
+                Random().NextBytes(buffer);
                 storedField.BytesValue = new BytesRef(buffer);
                 dvField.BytesValue = new BytesRef(buffer);
                 writer.AddDocument(doc);
@@ -1671,7 +1671,7 @@ namespace Lucene.Net.Index
             RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, conf);
             Document doc = new Document();
             Field idField = new StringField("id", "", Field.Store.NO);
-            Field storedField = new StoredField("stored", new sbyte[0]);
+            Field storedField = new StoredField("stored", new byte[0]);
             Field dvField = new SortedDocValuesField("dv", new BytesRef());
             doc.Add(idField);
             doc.Add(storedField);
@@ -1691,8 +1691,8 @@ namespace Lucene.Net.Index
                 {
                     length = TestUtil.NextInt(Random(), minLength, maxLength);
                 }
-                sbyte[] buffer = new sbyte[length];
-                Random().NextBytes((byte[])(Array)buffer);
+                var buffer = new byte[length];
+                Random().NextBytes(buffer);
                 storedField.BytesValue = new BytesRef(buffer);
                 dvField.BytesValue = new BytesRef(buffer);
                 writer.AddDocument(doc);
@@ -2971,7 +2971,7 @@ namespace Lucene.Net.Index
                 numDocs = TestUtil.NextInt(Random(), 100, 200);
             }
             IndexWriter w = new IndexWriter(d, NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
-            IList<sbyte[]> docBytes = new List<sbyte[]>();
+            var docBytes = new List<byte[]>();
             long totalBytes = 0;
             for (int docID = 0; docID < numDocs; docID++)
             {
@@ -2998,8 +2998,8 @@ namespace Lucene.Net.Index
                 {
                     break;
                 }
-                sbyte[] bytes = new sbyte[numBytes];
-                Random().NextBytes((byte[])(Array)bytes);
+                var bytes = new byte[numBytes];
+                Random().NextBytes(bytes);
                 docBytes.Add(bytes);
                 Document doc = new Document();
                 BytesRef b = new BytesRef(bytes);
@@ -3058,7 +3058,7 @@ namespace Lucene.Net.Index
                 Document doc = ar.Document(docID);
                 BytesRef bytes = new BytesRef();
                 s.Get(docID, bytes);
-                sbyte[] expected = docBytes[Convert.ToInt32(doc.Get("id"))];
+                var expected = docBytes[Convert.ToInt32(doc.Get("id"))];
                 Assert.AreEqual(expected.Length, bytes.Length);
                 Assert.AreEqual(new BytesRef(expected), bytes);
             }
@@ -3094,7 +3094,7 @@ namespace Lucene.Net.Index
                 numDocs = TestUtil.NextInt(Random(), 100, 200);
             }
             IndexWriter w = new IndexWriter(d, NewIndexWriterConfig(TEST_VERSION_CURRENT, analyzer));
-            IList<sbyte[]> docBytes = new List<sbyte[]>();
+            var docBytes = new List<byte[]>();
             long totalBytes = 0;
             for (int docID = 0; docID < numDocs; docID++)
             {
@@ -3121,8 +3121,8 @@ namespace Lucene.Net.Index
                 {
                     break;
                 }
-                sbyte[] bytes = new sbyte[numBytes];
-                Random().NextBytes((byte[])(Array)bytes);
+                var bytes = new byte[numBytes];
+                Random().NextBytes(bytes);
                 docBytes.Add(bytes);
                 Document doc = new Document();
                 BytesRef b = new BytesRef(bytes);
@@ -3143,7 +3143,7 @@ namespace Lucene.Net.Index
                 Document doc = ar.Document(docID);
                 BytesRef bytes = new BytesRef();
                 s.Get(docID, bytes);
-                sbyte[] expected = docBytes[Convert.ToInt32(doc.Get("id"))];
+                var expected = docBytes[Convert.ToInt32(doc.Get("id"))];
                 Assert.AreEqual(expected.Length, bytes.Length);
                 Assert.AreEqual(new BytesRef(expected), bytes);
             }
@@ -3163,7 +3163,7 @@ namespace Lucene.Net.Index
             RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, conf);
             Document doc = new Document();
             Field idField = new StringField("id", "", Field.Store.NO);
-            Field storedBinField = new StoredField("storedBin", new sbyte[0]);
+            Field storedBinField = new StoredField("storedBin", new byte[0]);
             Field dvBinField = new BinaryDocValuesField("dvBin", new BytesRef());
             Field dvSortedField = new SortedDocValuesField("dvSorted", new BytesRef());
             Field storedNumericField = new StoredField("storedNum", "");
@@ -3181,8 +3181,8 @@ namespace Lucene.Net.Index
             {
                 idField.StringValue = Convert.ToString(i);
                 int length = TestUtil.NextInt(Random(), 0, 8);
-                sbyte[] buffer = new sbyte[length];
-                Random().NextBytes((byte[])(Array)buffer);
+                var buffer = new byte[length];
+                Random().NextBytes(buffer);
                 storedBinField.BytesValue = new BytesRef(buffer);
                 dvBinField.BytesValue = new BytesRef(buffer);
                 dvSortedField.BytesValue = new BytesRef(buffer);
@@ -3283,7 +3283,7 @@ namespace Lucene.Net.Index
             IndexWriterConfig conf = NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random()));
             RandomIndexWriter writer = new RandomIndexWriter(Random(), dir, conf);
             Field idField = new StringField("id", "", Field.Store.NO);
-            Field storedBinField = new StoredField("storedBin", new sbyte[0]);
+            Field storedBinField = new StoredField("storedBin", new byte[0]);
             Field dvBinField = new BinaryDocValuesField("dvBin", new BytesRef());
             Field dvSortedField = new SortedDocValuesField("dvSorted", new BytesRef());
             Field storedNumericField = new StoredField("storedNum", "");
@@ -3295,8 +3295,8 @@ namespace Lucene.Net.Index
             {
                 idField.StringValue = Convert.ToString(i);
                 int length = TestUtil.NextInt(Random(), 0, 8);
-                sbyte[] buffer = new sbyte[length];
-                Random().NextBytes((byte[])(Array)buffer);
+                var buffer = new byte[length];
+                Random().NextBytes(buffer);
                 storedBinField.BytesValue = new BytesRef(buffer);
                 dvBinField.BytesValue = new BytesRef(buffer);
                 dvSortedField.BytesValue = new BytesRef(buffer);
@@ -3478,7 +3478,7 @@ namespace Lucene.Net.Index
                 Directory dir = NewDirectory();
                 RandomIndexWriter w = new RandomIndexWriter(Random(), dir);
                 BytesRef bytes = new BytesRef();
-                bytes.Bytes = new sbyte[1 << i];
+                bytes.Bytes = new byte[1 << i];
                 bytes.Length = 1 << i;
                 for (int j = 0; j < 4; j++)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Index/BasePostingsFormatTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/BasePostingsFormatTestCase.cs b/src/Lucene.Net.TestFramework/Index/BasePostingsFormatTestCase.cs
index 1fa531e..202be43 100644
--- a/src/Lucene.Net.TestFramework/Index/BasePostingsFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BasePostingsFormatTestCase.cs
@@ -154,7 +154,7 @@ namespace Lucene.Net.Index
                 }
 
                 FixedPayloads = Random.NextBoolean();
-                sbyte[] payloadBytes = new sbyte[PayloadSize];
+                var payloadBytes = new byte[PayloadSize];
                 Payload_Renamed = new BytesRef(payloadBytes);
                 this.Options = options;
                 DoPositions = FieldInfo.IndexOptions.DOCS_AND_FREQS_AND_POSITIONS.CompareTo(options) <= 0;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/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 9eef7af..c885649 100644
--- a/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Index/BaseStoredFieldsFormatTestCase.cs
@@ -231,15 +231,15 @@ 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();
             Field f = new StoredField("binary", b, 10, 17);
-            sbyte[] bx = f.BinaryValue().Bytes;
+            var bx = f.BinaryValue().Bytes;
             Assert.IsTrue(bx != null);
             Assert.AreEqual(50, bx.Length);
             Assert.AreEqual(10, f.BinaryValue().Offset);
@@ -375,7 +375,7 @@ namespace Lucene.Net.Index
             ft.Freeze();
 
             string @string = TestUtil.RandomSimpleString(Random(), 50);
-            sbyte[] bytes = @string.GetBytes(IOUtils.CHARSET_UTF_8);
+            var bytes = @string.GetBytes(IOUtils.CHARSET_UTF_8);
             long l = Random().NextBoolean() ? Random().Next(42) : Random().NextLong();
             int i = Random().NextBoolean() ? Random().Next(42) : Random().Next();
             float f = Random().NextFloat();
@@ -554,12 +554,12 @@ namespace Lucene.Net.Index
             }
         }
 
-        private static sbyte[] RandomByteArray(int length, int max)
+        private static byte[] RandomByteArray(int length, int max)
         {
-            var result = new sbyte[length];
+            var result = new byte[length];
             for (int i = 0; i < length; ++i)
             {
-                result[i] = (sbyte)Random().Next(max);
+                result[i] = (byte)Random().Next(max);
             }
             return result;
         }
@@ -583,11 +583,11 @@ namespace Lucene.Net.Index
             RandomIndexWriter iw = new RandomIndexWriter(Random(), dir, (IndexWriterConfig)iwConf.Clone());
 
             int docCount = AtLeast(200);
-            sbyte[][][] data = new sbyte[docCount][][];
+            var data = new byte[docCount][][];
             for (int i = 0; i < docCount; ++i)
             {
                 int fieldCount = Rarely() ? RandomInts.NextIntBetween(Random(), 1, 500) : RandomInts.NextIntBetween(Random(), 1, 5);
-                data[i] = new sbyte[fieldCount][];
+                data[i] = new byte[fieldCount][];
                 for (int j = 0; j < fieldCount; ++j)
                 {
                     int length = Rarely() ? Random().Next(1000) : Random().Next(10);
@@ -653,9 +653,9 @@ namespace Lucene.Net.Index
                 Assert.AreEqual(data[docId].Length + 1, doc.Fields.Count);
                 for (int j = 0; j < data[docId].Length; ++j)
                 {
-                    sbyte[] arr = data[docId][j];
+                    var arr = data[docId][j];
                     BytesRef arr2Ref = doc.GetBinaryValue("bytes" + j);
-                    sbyte[] arr2 = Arrays.CopyOfRange(arr2Ref.Bytes, arr2Ref.Offset, arr2Ref.Offset + arr2Ref.Length);
+                    var arr2 = Arrays.CopyOfRange(arr2Ref.Bytes, arr2Ref.Offset, arr2Ref.Offset + arr2Ref.Length);
                     Assert.AreEqual(arr, arr2);
                 }
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/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 483d174..986de18 100644
--- a/src/Lucene.Net.TestFramework/Index/DocHelper.cs
+++ b/src/Lucene.Net.TestFramework/Index/DocHelper.cs
@@ -87,7 +87,7 @@ namespace Lucene.Net.Index
         public static Field UnStoredField2;
 
         public const string LAZY_FIELD_BINARY_KEY = "lazyFieldBinary";
-        public static sbyte[] LAZY_FIELD_BINARY_BYTES;
+        public static byte[] LAZY_FIELD_BINARY_BYTES;
         public static Field LazyFieldBinary;
 
         public const string LAZY_FIELD_KEY = "lazyField";

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Index/FieldFilterAtomicReader.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Index/FieldFilterAtomicReader.cs b/src/Lucene.Net.TestFramework/Index/FieldFilterAtomicReader.cs
index 9965297..ccd5ade 100644
--- a/src/Lucene.Net.TestFramework/Index/FieldFilterAtomicReader.cs
+++ b/src/Lucene.Net.TestFramework/Index/FieldFilterAtomicReader.cs
@@ -86,7 +86,7 @@ namespace Lucene.Net.Index
         {
             private readonly FieldFilterAtomicReader OuterInstance;
 
-            private StoredFieldVisitor Visitor;
+            private readonly StoredFieldVisitor Visitor;
 
             public StoredFieldVisitorAnonymousInnerClassHelper(FieldFilterAtomicReader outerInstance, StoredFieldVisitor visitor)
             {
@@ -94,7 +94,7 @@ namespace Lucene.Net.Index
                 this.Visitor = visitor;
             }
 
-            public override void BinaryField(FieldInfo fieldInfo, sbyte[] value)
+            public override void BinaryField(FieldInfo fieldInfo, byte[] value)
             {
                 Visitor.BinaryField(fieldInfo, value);
             }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index 4139f9d..b706748 100644
--- a/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/src/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -2107,7 +2107,7 @@ namespace Lucene.Net.Util
                     else if (code == 2)
                     {
                         // term, but ensure a non-zero offset
-                        sbyte[] newbytes = new sbyte[term.Length + 5];
+                        var newbytes = new byte[term.Length + 5];
                         Array.Copy(term.Bytes, term.Offset, newbytes, 5, term.Length);
                         tests.Add(new BytesRef(newbytes, 5, term.Length));
                     }
@@ -2120,7 +2120,7 @@ namespace Lucene.Net.Util
                                 break;
 
                             case 1:
-                                tests.Add(new BytesRef(new sbyte[] { unchecked((sbyte)0xFF), unchecked((sbyte)0xFF) })); // past the last term
+                                tests.Add(new BytesRef(new byte[] { unchecked((byte)0xFF), unchecked((byte)0xFF) })); // past the last term
                                 break;
 
                             case 2:

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs b/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
index 3800ec9..df1ce35 100644
--- a/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
+++ b/src/Lucene.Net.TestFramework/Util/fst/FSTTester.cs
@@ -84,7 +84,7 @@ namespace Lucene.Net.Util.Fst
             {
                 int x = ir.Ints[ir.Offset + i];
                 Debug.Assert(x >= 0 && x <= 255);
-                br.Bytes[i] = (sbyte)x;
+                br.Bytes[i] = (byte)x;
             }
             br.Length = ir.Length;
             return br;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Analysis/TestToken.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Analysis/TestToken.cs b/src/Lucene.Net.Tests/core/Analysis/TestToken.cs
index d0a1930..0cd67b4 100644
--- a/src/Lucene.Net.Tests/core/Analysis/TestToken.cs
+++ b/src/Lucene.Net.Tests/core/Analysis/TestToken.cs
@@ -197,7 +197,7 @@ namespace Lucene.Net.Analysis
             Assert.AreEqual(t.ToString(), copy.ToString());
             Assert.AreNotSame(buf, copy.Buffer());
 
-            BytesRef pl = new BytesRef(new sbyte[] { 1, 2, 3, 4 });
+            BytesRef pl = new BytesRef(new byte[] { 1, 2, 3, 4 });
             t.Payload = pl;
             copy = AssertCloneIsEqual(t);
             Assert.AreEqual(pl, copy.Payload);
@@ -220,7 +220,7 @@ namespace Lucene.Net.Analysis
             Assert.AreEqual(t.ToString(), copy.ToString());
             Assert.AreNotSame(buf, copy.Buffer());
 
-            BytesRef pl = new BytesRef(new sbyte[] { 1, 2, 3, 4 });
+            BytesRef pl = new BytesRef(new byte[] { 1, 2, 3, 4 });
             t.Payload = pl;
             copy = AssertCopyIsEqual(t);
             Assert.AreEqual(pl, copy.Payload);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestCompressionMode.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestCompressionMode.cs b/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestCompressionMode.cs
index 4a5902d..d1f08ce 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestCompressionMode.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestCompressionMode.cs
@@ -34,56 +34,56 @@ namespace Lucene.Net.Codecs.Compressing
     {
         internal CompressionMode Mode;
 
-        internal static sbyte[] RandomArray()
+        internal static byte[] RandomArray()
         {
             int max = Random().NextBoolean() ? Random().Next(4) : Random().Next(256);
             int length = Random().NextBoolean() ? Random().Next(20) : Random().Next(192 * 1024);
             return RandomArray(length, max);
         }
 
-        internal static sbyte[] RandomArray(int length, int max)
+        internal static byte[] RandomArray(int length, int max)
         {
-            sbyte[] arr = new sbyte[length];
+            var arr = new byte[length];
             for (int i = 0; i < arr.Length; ++i)
             {
-                arr[i] = (sbyte)RandomInts.NextIntBetween(Random(), 0, max);
+                arr[i] = (byte)RandomInts.NextIntBetween(Random(), 0, max);
             }
             return arr;
         }
 
-        internal virtual sbyte[] Compress(sbyte[] decompressed, int off, int len)
+        internal virtual byte[] Compress(byte[] decompressed, int off, int len)
         {
             Compressor compressor = Mode.NewCompressor();
             return Compress(compressor, decompressed, off, len);
         }
 
-        internal static sbyte[] Compress(Compressor compressor, sbyte[] decompressed, int off, int len)
+        internal static byte[] Compress(Compressor compressor, byte[] decompressed, int off, int len)
         {
-            sbyte[] compressed = new sbyte[len * 2 + 16]; // should be enough
-            ByteArrayDataOutput @out = new ByteArrayDataOutput((byte[])(Array)compressed);
+            var compressed = new byte[len * 2 + 16]; // should be enough
+            ByteArrayDataOutput @out = new ByteArrayDataOutput(compressed);
             compressor.Compress(decompressed, off, len, @out);
             int compressedLen = @out.Position;
             return Arrays.CopyOf(compressed, compressedLen);
         }
 
-        internal virtual sbyte[] Decompress(sbyte[] compressed, int originalLength)
+        internal virtual byte[] Decompress(byte[] compressed, int originalLength)
         {
             Decompressor decompressor = Mode.NewDecompressor();
             return Decompress(decompressor, compressed, originalLength);
         }
 
-        internal static sbyte[] Decompress(Decompressor decompressor, sbyte[] compressed, int originalLength)
+        internal static byte[] Decompress(Decompressor decompressor, byte[] compressed, int originalLength)
         {
             BytesRef bytes = new BytesRef();
-            decompressor.Decompress(new ByteArrayDataInput((byte[])(Array)compressed), originalLength, 0, originalLength, bytes);
+            decompressor.Decompress(new ByteArrayDataInput(compressed), originalLength, 0, originalLength, bytes);
             return Arrays.CopyOfRange(bytes.Bytes, bytes.Offset, bytes.Offset + bytes.Length);
         }
 
-        internal virtual sbyte[] Decompress(sbyte[] compressed, int originalLength, int offset, int length)
+        internal virtual byte[] Decompress(byte[] compressed, int originalLength, int offset, int length)
         {
             Decompressor decompressor = Mode.NewDecompressor();
             BytesRef bytes = new BytesRef();
-            decompressor.Decompress(new ByteArrayDataInput((byte[])(Array)compressed), originalLength, offset, length, bytes);
+            decompressor.Decompress(new ByteArrayDataInput(compressed), originalLength, offset, length, bytes);
             return Arrays.CopyOfRange(bytes.Bytes, bytes.Offset, bytes.Offset + bytes.Length);
         }
 
@@ -93,11 +93,11 @@ namespace Lucene.Net.Codecs.Compressing
             int iterations = AtLeast(10);
             for (int i = 0; i < iterations; ++i)
             {
-                sbyte[] decompressed = RandomArray();
+                var decompressed = RandomArray();
                 int off = Random().NextBoolean() ? 0 : TestUtil.NextInt(Random(), 0, decompressed.Length);
                 int len = Random().NextBoolean() ? decompressed.Length - off : TestUtil.NextInt(Random(), 0, decompressed.Length - off);
-                sbyte[] compressed = Compress(decompressed, off, len);
-                sbyte[] restored = Decompress(compressed, len);
+                var compressed = Compress(decompressed, off, len);
+                var restored = Decompress(compressed, len);
                 Assert.AreEqual(Arrays.CopyOfRange(decompressed, off, off + len), restored);//was AssertArrayEquals
             }
         }
@@ -108,8 +108,8 @@ namespace Lucene.Net.Codecs.Compressing
             int iterations = AtLeast(10);
             for (int i = 0; i < iterations; ++i)
             {
-                sbyte[] decompressed = RandomArray();
-                sbyte[] compressed = Compress(decompressed, 0, decompressed.Length);
+                var decompressed = RandomArray();
+                var compressed = Compress(decompressed, 0, decompressed.Length);
                 int offset, length;
                 if (decompressed.Length == 0)
                 {
@@ -120,20 +120,20 @@ namespace Lucene.Net.Codecs.Compressing
                     offset = Random().Next(decompressed.Length);
                     length = Random().Next(decompressed.Length - offset);
                 }
-                sbyte[] restored = Decompress(compressed, decompressed.Length, offset, length);
+                var restored = Decompress(compressed, decompressed.Length, offset, length);
                 Assert.AreEqual(Arrays.CopyOfRange(decompressed, offset, offset + length), restored); //was AssertArrayEquals
             }
         }
 
-        public virtual sbyte[] Test(sbyte[] decompressed)
+        public virtual byte[] Test(byte[] decompressed)
         {
             return Test(decompressed, 0, decompressed.Length);
         }
 
-        public virtual sbyte[] Test(sbyte[] decompressed, int off, int len)
+        public virtual byte[] Test(byte[] decompressed, int off, int len)
         {
-            sbyte[] compressed = Compress(decompressed, off, len);
-            sbyte[] restored = Decompress(compressed, len);
+            var compressed = Compress(decompressed, off, len);
+            var restored = Decompress(compressed, len);
             Assert.AreEqual(len, restored.Length);
             return compressed;
         }
@@ -141,22 +141,22 @@ namespace Lucene.Net.Codecs.Compressing
         [Test]
         public virtual void TestEmptySequence()
         {
-            Test(new sbyte[0]);
+            Test(new byte[0]);
         }
 
         [Test]
         public virtual void TestShortSequence()
         {
-            Test(new sbyte[] { (sbyte)Random().Next(256) });
+            Test(new[] { (byte)Random().Next(256) });
         }
 
         [Test]
         public virtual void TestIncompressible()
         {
-            sbyte[] decompressed = new sbyte[RandomInts.NextIntBetween(Random(), 20, 256)];
+            var decompressed = new byte[RandomInts.NextIntBetween(Random(), 20, 256)];
             for (int i = 0; i < decompressed.Length; ++i)
             {
-                decompressed[i] = (sbyte)i;
+                decompressed[i] = (byte)i;
             }
             Test(decompressed);
         }
@@ -164,8 +164,8 @@ namespace Lucene.Net.Codecs.Compressing
         [Test]
         public virtual void TestConstant()
         {
-            sbyte[] decompressed = new sbyte[TestUtil.NextInt(Random(), 1, 10000)];
-            Arrays.Fill(decompressed, (sbyte)Random().Next());
+            var decompressed = new byte[TestUtil.NextInt(Random(), 1, 10000)];
+            Arrays.Fill(decompressed, (byte)Random().Next());
             Test(decompressed);
         }
 
@@ -173,7 +173,7 @@ namespace Lucene.Net.Codecs.Compressing
         public virtual void TestLUCENE5201()
         {
             sbyte[] data = { 14, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 72, 14, 72, 14, 85, 3, 72, 14, 72, 14, 72, 14, 72, 14, 72, 14, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 85, 3, 72, 14, 50, 64, 0, 46, -1, 0, 0, 0, 29, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 50, 64, 0, 47, -105, 0, 0, 0, 30, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, -97, 6, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68
 , -113, 0, 120, 64, 0, 48, 4, 0, 0, 0, 31, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 39, 24, 32, 34, 124, 0, 120, 64, 0, 48, 80, 0, 0, 0, 31, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 
 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 7
 2, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 72, 34, 72, 29, 72, 37, 72, 35, 72, 45, 72, 23, 72, 46, 72, 20, 72, 40, 72, 33, 72, 25, 72, 39, 72, 38, 72, 26, 72, 28, 72, 42, 72, 24, 72, 27, 72, 36, 72, 41, 72, 32, 72, 18, 72, 30, 72, 22, 72, 31, 72, 43, 72, 19, 50, 64, 0, 49, 20, 0, 0, 0, 32, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 50, 64, 0, 50, 53, 0, 0, 0, 34, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0
 , 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 50, 64, 0, 51, 85, 0, 0, 0, 36, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, -97, 5, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 50, -64, 0, 51, -45, 0, 0, 0, 37, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, -9
 7, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -113, 0, 2, 3, -97, 6, 0, 68, -113, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 2, 3, 85, 8, -113, 0, 68, -97, 3, 0, 120, 64, 0, 52, -88, 0, 0, 0, 39, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 72, 13, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13, 72, 13, 85, 5, 72, 13, -19, -24, -101, -35 };
-            Test(data, 9, data.Length - 9);
+            Test((byte[])(Array)data, 9, data.Length - 9);
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestLZ4CompressionMode.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestLZ4CompressionMode.cs b/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestLZ4CompressionMode.cs
index 35b3ce5..8add739 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestLZ4CompressionMode.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Compressing/AbstractTestLZ4CompressionMode.cs
@@ -28,9 +28,9 @@ namespace Lucene.Net.Codecs.Compressing
     {
         private LZ4 lz4;
 
-        public override sbyte[] Test(sbyte[] decompressed)
+        public override byte[] Test(byte[] decompressed)
         {
-            sbyte[] compressed = base.Test(decompressed);
+            var compressed = base.Test(decompressed);
             int off = 0;
             int decompressedOff = 0;
             for (; ; )
@@ -94,7 +94,7 @@ namespace Lucene.Net.Codecs.Compressing
         public virtual void TestShortLiteralsAndMatchs()
         {
             // literals and matchs lengths <= 15
-            sbyte[] decompressed = "1234562345673456745678910123".GetBytes(Encoding.UTF8);
+            var decompressed = "1234562345673456745678910123".GetBytes(Encoding.UTF8);
             Test(decompressed);
         }
 
@@ -102,10 +102,10 @@ namespace Lucene.Net.Codecs.Compressing
         public virtual void TestLongMatchs()
         {
             // match length >= 20
-            sbyte[] decompressed = new sbyte[RandomInts.NextIntBetween(Random(), 300, 1024)];
+            var decompressed = new byte[RandomInts.NextIntBetween(Random(), 300, 1024)];
             for (int i = 0; i < decompressed.Length; ++i)
             {
-                decompressed[i] = (sbyte)i;
+                decompressed[i] = (byte)i;
             }
             Test(decompressed);
         }
@@ -114,7 +114,7 @@ namespace Lucene.Net.Codecs.Compressing
         public virtual void TestLongLiterals()
         {
             // long literals (length >= 16) which are not the last literals
-            sbyte[] decompressed = RandomArray(RandomInts.NextIntBetween(Random(), 400, 1024), 256);
+            var decompressed = RandomArray(RandomInts.NextIntBetween(Random(), 400, 1024), 256);
             int matchRef = Random().Next(30);
             int matchOff = RandomInts.NextIntBetween(Random(), decompressed.Length - 40, decompressed.Length - 20);
             int matchLength = RandomInts.NextIntBetween(Random(), 4, 10);
@@ -125,7 +125,7 @@ namespace Lucene.Net.Codecs.Compressing
         [Test]
         public virtual void TestMatchRightBeforeLastLiterals()
         {
-            Test(new sbyte[] { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5 });
+            Test(new byte[] { 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 5 });
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Codecs/Compressing/TestFastDecompressionMode.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Compressing/TestFastDecompressionMode.cs b/src/Lucene.Net.Tests/core/Codecs/Compressing/TestFastDecompressionMode.cs
index bdcbb95..d7fc0b0 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Compressing/TestFastDecompressionMode.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Compressing/TestFastDecompressionMode.cs
@@ -29,10 +29,10 @@ namespace Lucene.Net.Codecs.Compressing
             Mode = CompressionMode.FAST_DECOMPRESSION;
         }
 
-        public override sbyte[] Test(sbyte[] decompressed, int off, int len)
+        public override byte[] Test(byte[] decompressed, int off, int len)
         {
-            sbyte[] compressed = base.Test(decompressed, off, len);
-            sbyte[] compressed2 = Compress(CompressionMode.FAST.NewCompressor(), decompressed, off, len);
+            var compressed = base.Test(decompressed, off, len);
+            var compressed2 = Compress(CompressionMode.FAST.NewCompressor(), decompressed, off, len);
             // because of the way this compression mode works, its output is necessarily
             // smaller than the output of CompressionMode.FAST
             Assert.IsTrue(compressed.Length <= compressed2.Length);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestBlockPostingsFormat3.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestBlockPostingsFormat3.cs b/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestBlockPostingsFormat3.cs
index 138d941..a519b86 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestBlockPostingsFormat3.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestBlockPostingsFormat3.cs
@@ -261,7 +261,7 @@ namespace Lucene.Net.Codecs.Lucene41
                     else if (code == 2)
                     {
                         // term, but ensure a non-zero offset
-                        sbyte[] newbytes = new sbyte[term.Length + 5];
+                        var newbytes = new byte[term.Length + 5];
                         Array.Copy(term.Bytes, term.Offset, newbytes, 5, term.Length);
                         tests.Add(new BytesRef(newbytes, 5, term.Length));
                     }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestForUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestForUtil.cs b/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestForUtil.cs
index 8139c6e..944e57f 100644
--- a/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestForUtil.cs
+++ b/src/Lucene.Net.Tests/core/Codecs/Lucene41/TestForUtil.cs
@@ -68,7 +68,7 @@ namespace Lucene.Net.Codecs.Lucene41
 
                 for (int i = 0; i < iterations; ++i)
                 {
-                    forUtil.WriteBlock(Arrays.CopyOfRange(values, i * Lucene41PostingsFormat.BLOCK_SIZE, values.Length), new sbyte[Lucene41.ForUtil.MAX_ENCODED_SIZE], @out);
+                    forUtil.WriteBlock(Arrays.CopyOfRange(values, i * Lucene41PostingsFormat.BLOCK_SIZE, values.Length), new byte[Lucene41.ForUtil.MAX_ENCODED_SIZE], @out);
                 }
                 endPointer = @out.FilePointer;
                 @out.Dispose();
@@ -86,7 +86,7 @@ namespace Lucene.Net.Codecs.Lucene41
                         continue;
                     }
                     int[] restored = new int[Lucene41.ForUtil.MAX_DATA_SIZE];
-                    forUtil.ReadBlock(@in, new sbyte[Lucene41.ForUtil.MAX_ENCODED_SIZE], restored);
+                    forUtil.ReadBlock(@in, new byte[Lucene41.ForUtil.MAX_ENCODED_SIZE], restored);
                     Assert.AreEqual(Arrays.CopyOfRange(values, i * Lucene41PostingsFormat.BLOCK_SIZE, (i + 1) * Lucene41PostingsFormat.BLOCK_SIZE), Arrays.CopyOf(restored, Lucene41PostingsFormat.BLOCK_SIZE));
                 }
                 Assert.AreEqual(endPointer, @in.FilePointer);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Document/TestBinaryDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Document/TestBinaryDocument.cs b/src/Lucene.Net.Tests/core/Document/TestBinaryDocument.cs
index d50d055..74d3e93 100644
--- a/src/Lucene.Net.Tests/core/Document/TestBinaryDocument.cs
+++ b/src/Lucene.Net.Tests/core/Document/TestBinaryDocument.cs
@@ -44,7 +44,7 @@ namespace Lucene.Net.Document
         {
             FieldType ft = new FieldType();
             ft.Stored = true;
-            IndexableField binaryFldStored = new StoredField("binaryStored", (sbyte[])(Array)System.Text.UTF8Encoding.UTF8.GetBytes(BinaryValStored));
+            IndexableField binaryFldStored = new StoredField("binaryStored", System.Text.UTF8Encoding.UTF8.GetBytes(BinaryValStored));
             IndexableField stringFldStored = new Field("stringStored", BinaryValStored, ft);
 
             Documents.Document doc = new Documents.Document();
@@ -92,8 +92,8 @@ namespace Lucene.Net.Document
         [Test]
         public virtual void TestCompressionTools()
         {
-            IndexableField binaryFldCompressed = new StoredField("binaryCompressed", (sbyte[])(Array)CompressionTools.Compress(BinaryValCompressed.GetBytes(Encoding.UTF8)));
-            IndexableField stringFldCompressed = new StoredField("stringCompressed", (sbyte[])(Array)CompressionTools.CompressString(BinaryValCompressed));
+            IndexableField binaryFldCompressed = new StoredField("binaryCompressed", CompressionTools.Compress(BinaryValCompressed.GetBytes(Encoding.UTF8)));
+            IndexableField stringFldCompressed = new StoredField("stringCompressed", CompressionTools.CompressString(BinaryValCompressed));
 
             var doc = new Documents.Document {binaryFldCompressed, stringFldCompressed};
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Document/TestDocument.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Document/TestDocument.cs b/src/Lucene.Net.Tests/core/Document/TestDocument.cs
index dba80cc..8d31bfc 100644
--- a/src/Lucene.Net.Tests/core/Document/TestDocument.cs
+++ b/src/Lucene.Net.Tests/core/Document/TestDocument.cs
@@ -376,7 +376,7 @@ namespace Lucene.Net.Document
             doc.Add(new Field("tokenized", "abc xyz", Field.Store.NO, Field.Index.ANALYZED));
             doc.Add(new Field("tokenized_reader", new StringReader("abc xyz")));
             doc.Add(new Field("tokenized_tokenstream", w.w.Analyzer.TokenStream("tokenized_tokenstream", new StringReader("abc xyz"))));
-            doc.Add(new Field("binary", new sbyte[10]));
+            doc.Add(new Field("binary", new byte[10]));
             doc.Add(new Field("tv", "abc xyz", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.YES));
             doc.Add(new Field("tv_pos", "abc xyz", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_POSITIONS));
             doc.Add(new Field("tv_off", "abc xyz", Field.Store.NO, Field.Index.ANALYZED, Field.TermVector.WITH_OFFSETS));

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/139ad812/src/Lucene.Net.Tests/core/Document/TestField.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Tests/core/Document/TestField.cs b/src/Lucene.Net.Tests/core/Document/TestField.cs
index 45bc0b2..8a0bde7 100644
--- a/src/Lucene.Net.Tests/core/Document/TestField.cs
+++ b/src/Lucene.Net.Tests/core/Document/TestField.cs
@@ -453,7 +453,7 @@ namespace Lucene.Net.Document
         {
             try
             {
-                f.BytesValue = new BytesRef(new sbyte[] { 5, 5 });
+                f.BytesValue = new BytesRef(new byte[] { 5, 5 });
                 Assert.Fail();
             }
             catch (System.ArgumentException expected)