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

[1/7] lucenenet git commit: adding array extension methods, refactoring unicode related classes to match recent changes, adding bytesrefbuilder.

Repository: lucenenet
Updated Branches:
  refs/heads/pcl b31804212 -> ecf03e102


adding array extension methods, refactoring unicode related classes to match recent changes, adding bytesrefbuilder.


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

Branch: refs/heads/pcl
Commit: 8e7e10437db4cc82ed46f9d5968f640cd94d66d0
Parents: b318042
Author: Michael Herndon <mh...@michaelherndon.com>
Authored: Wed Aug 20 21:20:29 2014 -0400
Committer: Michael Herndon <mh...@michaelherndon.com>
Committed: Wed Aug 20 21:20:29 2014 -0400

----------------------------------------------------------------------
 src/Lucene.Net.Core/Lucene.Net.Core.csproj      |   2 +
 .../Support/ArrayExtensionMethods.cs            |  21 ++
 src/Lucene.Net.Core/Util/ArrayUtil.cs           |  14 +-
 src/Lucene.Net.Core/Util/BytesRef.cs            |  67 ++++-
 src/Lucene.Net.Core/Util/BytesRefArray.cs       |  28 +-
 src/Lucene.Net.Core/Util/BytesRefBuilder.cs     | 263 +++++++++++++++++++
 src/Lucene.Net.Core/Util/CharsRef.cs            |  23 +-
 src/Lucene.Net.Core/Util/CharsRefBuilder.cs     |   6 +-
 src/Lucene.Net.Core/Util/UnicodeUtil.cs         | 231 ++++++++++------
 .../Support/TestNumberExtensionMethods.cs       |  21 +-
 .../Util/TestByteArrayRef.cs                    |  14 +-
 test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs |  12 +-
 12 files changed, 559 insertions(+), 143 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/src/Lucene.Net.Core/Lucene.Net.Core.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.Core.csproj b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
index 9265b37..5ad93e0 100644
--- a/src/Lucene.Net.Core/Lucene.Net.Core.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
@@ -58,6 +58,7 @@
   <ItemGroup>
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Check.cs" />
+    <Compile Include="Support\ArrayExtensionMethods.cs" />
     <Compile Include="Support\AtomicReferenceArray.cs" />
     <Compile Include="Support\DeepCloneNotSupportedException.cs" />
     <Compile Include="Support\EnumUtil.cs" />
@@ -75,6 +76,7 @@
     <Compile Include="Util\BitUtil.cs" />
     <Compile Include="Util\BroadWord.cs" />
     <Compile Include="Util\ByteBlockPool.cs" />
+    <Compile Include="Util\BytesRefBuilder.cs" />
     <Compile Include="Util\BytesRef.cs" />
     <Compile Include="Util\BytesRefArray.cs" />
     <Compile Include="Util\CharsRefBuilder.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs b/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs
new file mode 100644
index 0000000..d7cc737
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs
@@ -0,0 +1,21 @@
+
+
+namespace Lucene.Net.Support
+{
+    using System;
+    using System.Runtime.InteropServices.ComTypes;
+
+    public static class ArrayExtensionMethods
+    {
+
+        public static T[] Copy<T>(this T[] array, int length = -1)
+        {
+            if (length == -1)
+                length = array.Length;
+
+            var result = new T[length];
+            Array.Copy(array, result, length);
+            return result;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/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 078aaf3..cd3d7cc 100644
--- a/src/Lucene.Net.Core/Util/ArrayUtil.cs
+++ b/src/Lucene.Net.Core/Util/ArrayUtil.cs
@@ -37,19 +37,19 @@ namespace Lucene.Net.Util
         /// </summary>
         /// <typeparam name="T">The element type for the array.</typeparam>
         /// <param name="array">The array to base the resize on.</param>
-        /// <param name="minSize">The minimum size to grow the array.</param>
+        /// <param name="capacity">The minimum size to grow the array.</param>
         /// <returns>The resized array.</returns>
-        /// <exception cref="System.ArgumentException">Throws when <paramref name="minSize"/> is less than zero.</exception>
-        public static T[] Grow<T>(this T[] array, int minSize = 1)
+        /// <exception cref="System.ArgumentException">Throws when <paramref name="capacity"/> is less than zero.</exception>
+        public static T[] Grow<T>(this T[] array, int capacity = 1)
         {
             Debug.Assert(typeof(T).GetTypeInfo().IsPrimitive, "Type T must be primitive");
-            Debug.Assert(minSize >= 0, "targetSize must be positive");
+            Debug.Assert(capacity >= 0, "targetSize must be positive");
 
-            if (array.Length >= minSize) 
+            if (array.Length >= capacity) 
                 return array;
             
-            var capacity = Oversize(minSize, RamUsageEstimator.PRIMITIVE_SIZES[typeof(T)]);
-            var oversizedArray = new T[capacity];
+            var length = Oversize(capacity, RamUsageEstimator.PRIMITIVE_SIZES[typeof(T)]);
+            var oversizedArray = new T[length];
             Array.Copy(array, 0, oversizedArray, 0, array.Length);
 
             return oversizedArray;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/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 5631a7e..18dbf9f 100644
--- a/src/Lucene.Net.Core/Util/BytesRef.cs
+++ b/src/Lucene.Net.Core/Util/BytesRef.cs
@@ -20,6 +20,7 @@ namespace Lucene.Net.Util
     using System;
     using System.Collections.Generic;
     using System.Diagnostics;
+    using System.Linq;
     using System.Text;
 
     /// <summary>
@@ -45,6 +46,7 @@ namespace Lucene.Net.Util
         Support.ICloneable,
         IEnumerable<Byte>
     {
+        private int length;
         /// <summary>
         ///     An empty byte array for convenience
         /// </summary>
@@ -63,7 +65,16 @@ namespace Lucene.Net.Util
         /// <summary>
         ///     Length of used bytes.
         /// </summary>
-        public virtual int Length { get; internal protected set; }
+        public virtual int Length
+        {
+            get { return this.length; }
+            set
+            {
+                this.length = value; 
+                if(this.Bytes.Length < value)
+                    this.Grow(value);
+            }
+        }
 
         /// <summary>
         ///     Create a BytesRef with <seealso cref="EMPTY_BYTES" />
@@ -139,6 +150,36 @@ namespace Lucene.Net.Util
         }
 
         /// <summary>
+        ///     Initializes a new instance of <see cref="BytesRef" /> from the UTF8 bytes
+        ///     from the given <see cref="string" />.
+        /// </summary>
+        /// <param name="text">
+        ///     this must be well-formed
+        ///     unicode text, with no unpaired surrogates.
+        /// </param>
+        public BytesRef(char[] text)
+            : this()
+        {
+
+            CopyChars(text);
+        }
+
+
+        public void CopyChars(char[] text)
+        {
+            Debug.Assert(this.Offset == 0);
+            this.Grow(text.Length * UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR);
+            this.Length = UnicodeUtil.Utf16ToUtf8(text, 0, text.Length, this.Bytes);
+        }
+
+        public void CopyChars(IEnumerable<char> text)
+        {
+            Debug.Assert(this.Offset == 0);
+            var array = text as char[];
+            this.CopyChars(array ?? text.ToArray());
+        }
+
+        /// <summary>
         ///     Copies the UTF8 bytes for this string.
         /// </summary>
         /// <param name="text">
@@ -148,7 +189,8 @@ namespace Lucene.Net.Util
         public void CopyChars(CharsRef text)
         {
             Debug.Assert(this.Offset == 0);
-            UnicodeUtil.Utf16ToUtf8(text, 0, text.Length, this);
+            this.Grow(text.Length * UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR);
+            this.Length = UnicodeUtil.Utf16ToUtf8(text.Chars, 0, text.Length, this.Bytes);
         }
 
         /// <summary>
@@ -160,8 +202,7 @@ namespace Lucene.Net.Util
         /// </param>
         public void CopyChars(string text)
         {
-            Debug.Assert(this.Offset == 0);
-            UnicodeUtil.Utf16ToUtf8(text.ToCharArray(), 0, text.Length, this);
+            this.CopyChars(text.ToCharArray());
         }
 
         /// <summary>
@@ -233,11 +274,9 @@ namespace Lucene.Net.Util
             {
                 return false;
             }
-            if (other is BytesRef)
-            {
-                return this.BytesEquals((BytesRef) other);
-            }
-            return false;
+
+            var bytesRef = other as BytesRef;
+            return bytesRef != null && this.BytesEquals(bytesRef);
         }
 
         /// <summary>
@@ -246,9 +285,9 @@ namespace Lucene.Net.Util
         /// <returns>A utf16 string.</returns>
         public string Utf8ToString()
         {
-            var @ref = new CharsRef(Length);
-            UnicodeUtil.Utf8ToUtf16(this.Bytes, this.Offset, this.Length, @ref);
-            return @ref.ToString();
+            var charsRef = new CharsRef(this.Length);
+            charsRef.Length = UnicodeUtil.Utf8ToUtf16(this.Bytes, this.Offset, this.Length, charsRef.Chars);
+            return charsRef.ToString();
         }
 
         /// <summary>
@@ -318,10 +357,10 @@ namespace Lucene.Net.Util
         /// <summary>
         ///     Used to grow the reference array.
         /// </summary>
-        internal protected virtual void Grow(int newLength)
+        internal protected virtual void Grow(int capacity)
         {
             Debug.Assert(this.Offset == 0); // NOTE: senseless if offset != 0
-            this.Bytes = ArrayUtil.Grow(this.Bytes, newLength);
+            this.Bytes = ArrayUtil.Grow(this.Bytes, capacity);
         }
 
         /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/src/Lucene.Net.Core/Util/BytesRefArray.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRefArray.cs b/src/Lucene.Net.Core/Util/BytesRefArray.cs
index d6ebed8..10707b5 100644
--- a/src/Lucene.Net.Core/Util/BytesRefArray.cs
+++ b/src/Lucene.Net.Core/Util/BytesRefArray.cs
@@ -110,10 +110,10 @@ namespace Lucene.Net.Util
         /// <param name="spare"> a spare <seealso cref="BytesRef" /> instance </param>
         /// <param name="index"> the elements index to retrieve </param>
         /// <returns> the <i>n'th</i> element of this <seealso cref="BytesRefArray" /> </returns>
-        public BytesRef Retrieve(BytesRef spare, int index)
+        public BytesRef Retrieve(BytesRefBuilder spare, int index)
         {
             Debug.Assert(spare != null, "spare must never be null");
-            Debug.Assert(spare.Offset == 0);
+            //Debug.Assert(spare.Offset == 0);
 
             if (index > this.lastElement)
                 throw new IndexOutOfRangeException("index " + index + " must be less than the size: " +
@@ -121,10 +121,10 @@ namespace Lucene.Net.Util
             var offset = this.offsets[index];
             var length = index == this.lastElement - 1 ? this.currentOffset - offset : this.offsets[index + 1] - offset;
 
-            spare.Grow(length);
+      
             spare.Length = length;
-            this.pool.ReadBytes(offset, spare.Bytes, spare.Offset, spare.Length);
-            return spare;
+            this.pool.ReadBytes(offset, spare.Bytes, 0, spare.Length);
+            return spare.ToBytesRef();
         }
 
         /// <summary>
@@ -181,9 +181,9 @@ namespace Lucene.Net.Util
             private BytesRefArray bytesRefArray;
             private IComparer<BytesRef> comparer;
             private int[] orderedEntries;
-            private BytesRef pivot;
-            private BytesRef scratch1;
-            private BytesRef scratch2;
+            private BytesRefBuilder pivot;
+            private BytesRefBuilder scratch1;
+            private BytesRefBuilder scratch2;
 
             /// <summary>
             /// Initializes a new instance of the <see cref="ByteRefArraySorter"/> class.
@@ -196,9 +196,9 @@ namespace Lucene.Net.Util
                 this.bytesRefArray = outerInstance;
                 this.comparer = comp;
                 this.orderedEntries = orderedEntries;
-                pivot = new BytesRef();
-                scratch1 = new BytesRef();
-                scratch2 = new BytesRef();
+                pivot = new BytesRefBuilder();
+                scratch1 = new BytesRefBuilder();
+                scratch2 = new BytesRefBuilder();
             }
 
             /// <summary>
@@ -260,7 +260,7 @@ namespace Lucene.Net.Util
             protected internal override int ComparePivot(int j)
             {
                 var index = orderedEntries[j];
-                return this.comparer.Compare(this.pivot, bytesRefArray.Retrieve(this.scratch2, index));
+                return this.comparer.Compare(this.pivot.ToBytesRef(), bytesRefArray.Retrieve(this.scratch2, index));
             }
 
 
@@ -297,6 +297,7 @@ namespace Lucene.Net.Util
             private readonly int size;
             private BytesRefArray bytesRefArray;
             private int position;
+            private BytesRefBuilder builder;
 
             /// <summary>
             ///     Initializes a new instance of the <see cref="BytesRefEnumerator" /> class.
@@ -306,6 +307,7 @@ namespace Lucene.Net.Util
             /// <param name="indices">The indices.</param>
             public BytesRefEnumerator(BytesRefArray bytesRefArray,  int size, int[] indices)
             {
+                this.builder = new BytesRefBuilder();
                 this.bytesRefArray = bytesRefArray;
                 this.size = size;
                 this.indices = indices;
@@ -344,7 +346,7 @@ namespace Lucene.Net.Util
 
                 // return a new instance for each loop. 
                 var bytesRef = new BytesRef();
-                this.Current = bytesRefArray.Retrieve(bytesRef, indices == null ? position : indices[position]);
+                this.Current = bytesRefArray.Retrieve(this.builder, indices == null ? position : indices[position]);
                 return true;
             }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/src/Lucene.Net.Core/Util/BytesRefBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRefBuilder.cs b/src/Lucene.Net.Core/Util/BytesRefBuilder.cs
new file mode 100644
index 0000000..23ca12c
--- /dev/null
+++ b/src/Lucene.Net.Core/Util/BytesRefBuilder.cs
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Util
+{
+    using System;
+    using System.Linq;
+    using Support;
+    using System.Collections.Generic;
+    using System.Diagnostics.CodeAnalysis;
+
+
+    /// <summary>
+    /// Class ByteRefBuilder.
+    /// </summary>
+    //
+    // Notes
+    //
+    // ReSharper disable CSharpWarnings::CS1574
+    public class BytesRefBuilder
+    {
+        private readonly BytesRef bytesRef;
+
+        /// <summary>
+        /// Initializes a new instance of the <see cref="BytesRefBuilder"/> class.
+        /// </summary>
+        public BytesRefBuilder()
+        {
+            this.bytesRef = new BytesRef();
+        }
+
+        /// <summary>
+        /// Gets the bytes.
+        /// </summary>
+        /// <value>The bytes.</value>
+        public byte[] Bytes
+        {
+            get { return this.bytesRef.Bytes; }
+        }
+
+        /// <summary>
+        /// Gets or sets the length.
+        /// </summary>
+        /// <value>The length.</value>
+        public int Length
+        {
+            get { return this.bytesRef.Length; }
+            set
+            {
+                if(this.bytesRef.Bytes.Length < value)
+                    this.Grow(value);
+
+                this.bytesRef.Length = value;
+            }
+        }
+
+        /// <summary>
+        /// Appends the specified value.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        public void Append(byte value)
+        {
+            var next = this.bytesRef.Length + 1;
+            this.Length = next;
+            this.Bytes[next] = value;
+        }
+
+        /// <summary>
+        /// Appends the specified bytes.
+        /// </summary>
+        /// <param name="bytes">The bytes.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        public void Append(byte[] bytes, int offset, int length)
+        {
+            this.Length += length;
+            Array.Copy(bytes, offset, this.bytesRef.Bytes, this.bytesRef.Length, length);
+        }
+
+        /// <summary>
+        /// Appends the specified value.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        public void Append(BytesRef value)
+        {
+            this.Append(value.Bytes, value.Offset, value.Length);
+        }
+
+        /// <summary>
+        /// Appends the specified builder.
+        /// </summary>
+        /// <param name="builder">The builder.</param>
+        public void Append(BytesRefBuilder builder)
+        {
+            this.Append(builder.bytesRef);
+        }
+
+        /// <summary>
+        /// Bytes at.
+        /// </summary>
+        /// <param name="offset">The offset.</param>
+        /// <returns>System.Byte.</returns>
+        public byte ByteAt(int offset)
+        {
+            return this.Bytes[offset];
+        }
+
+        /// <summary>
+        /// Clears this instance.
+        /// </summary>
+        public void Clear()
+        {
+            this.Length = 0;
+        }
+
+        /// <summary>
+        /// Clears and replaces the internal bytes. Its a shorthand method for calling 
+        /// <see cref="Clear"/> and <see cref="Append(byte[],int, int)"/>.
+        /// </summary>
+        /// <param name="bytes">The bytes.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        public void CopyBytes(byte[] bytes, int offset, int length)
+        {
+            this.Clear();
+            this.Append(bytes, offset, length);
+        }
+
+        /// <summary>
+        /// Clears and replaces the internal bytes. Its a shorthand method for calling 
+        /// <see cref="Clear"/> and <see cref="Append(BytesRef)"/>.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        public void CopyBytes(BytesRef value)
+        {
+            this.Clear();
+            this.Append(value);
+        }
+
+        /// <summary>
+        /// Copies the bytes.
+        /// </summary>
+        /// <param name="builder">The builder.</param>
+        public void CopyBytes(BytesRefBuilder builder)
+        {
+            this.Clear();
+            this.Append(builder);
+        }
+
+        /// <summary>
+        /// Copies the chars.
+        /// </summary>
+        /// <param name="text">The text.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        public void CopyChars(ICharSequence text, int offset = 0, int length = -1)
+        {
+            if(length == -1)
+                length = text.Length;
+
+            this.Length = length * UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR;
+            this.Length = UnicodeUtil.Utf16ToUtf8(text, offset, length, this.bytesRef.Bytes);
+        }
+
+        /// <summary>
+        /// Copies the chars.
+        /// </summary>
+        /// <param name="text">The text.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        public void CopyChars(string text, int offset = 0, int length = -1)
+        {
+            if (length == -1)
+                length = text.Length;
+
+            this.Length = length * UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR;
+            this.Length = UnicodeUtil.Utf16ToUtf8(text.ToCharArray(), offset, length, this.bytesRef.Bytes);
+        }
+
+        /// <summary>
+        /// Copies the chars.
+        /// </summary>
+        /// <param name="text">The text.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        public void CopyChars(char[] text, int offset = 0, int length = -1)
+        {
+            if (length == -1)
+                length = text.Length;
+
+            this.Length = length * UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR;
+            this.Length = UnicodeUtil.Utf16ToUtf8(text, offset, length, this.bytesRef.Bytes);
+        }
+
+        /// <summary>
+        /// Copies the chars.
+        /// </summary>
+        /// <param name="text">The text.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        public void CopyChars(IEnumerable<char> text, int offset = 0, int length = -1)
+        {
+            // ReSharper disable PossibleMultipleEnumeration
+            if (length == -1)
+
+                length = text.Count();
+
+            this.Length = length * UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR;
+            this.Length = UnicodeUtil.Utf16ToUtf8(text, offset, length, this.bytesRef.Bytes);
+        }
+
+        /// <inherits />
+        /// <exception cref="NotSupportedException">Throws when called.</exception>
+        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Justification = "Java Port Consistency")]
+        public override bool Equals(object obj)
+        {
+            throw new NotSupportedException();
+        }
+
+          /// <inherits />
+        /// <exception cref="NotSupportedException">Throws when called.</exception>
+        [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Justification = "Java Port Consistency")]
+        public override int GetHashCode()
+        {
+            throw new NotSupportedException();
+        }
+
+        /// <summary>
+        /// Grows the specified capacity.
+        /// </summary>
+        /// <param name="capacity">The capacity.</param>
+        protected void Grow(int capacity)
+        {
+            this.bytesRef.Bytes = this.bytesRef.Bytes.Grow(capacity);
+        }
+
+
+
+        /// <summary>
+        /// To the bytes reference.
+        /// </summary>
+        /// <returns>BytesRef.</returns>
+        public BytesRef ToBytesRef()
+        {
+            var copy = this.Bytes.Copy(this.Length);
+            return new BytesRef(copy); 
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/src/Lucene.Net.Core/Util/CharsRef.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/CharsRef.cs b/src/Lucene.Net.Core/Util/CharsRef.cs
index 878bca1..aed89dc 100644
--- a/src/Lucene.Net.Core/Util/CharsRef.cs
+++ b/src/Lucene.Net.Core/Util/CharsRef.cs
@@ -20,6 +20,7 @@ namespace Lucene.Net.Util
     using System;
     using System.Collections.Generic;
     using System.Diagnostics;
+    using System.Linq;
     using Lucene.Net.Support;
     using ICloneable = Lucene.Net.Support.ICloneable; 
 
@@ -40,6 +41,8 @@ namespace Lucene.Net.Util
         ICloneable,
         IEnumerable<char>
     {
+        private int length;
+
         /// <summary>
         ///     An empty character array for convenience
         /// </summary>
@@ -58,7 +61,16 @@ namespace Lucene.Net.Util
         /// <summary>
         ///     Length of used characters.
         /// </summary>
-        public int Length { get; internal set; }
+        public int Length
+        {
+            get { return this.length; }
+            set
+            {
+                this.length = value;
+                if(this.Chars.Length < value)
+                    this.Grow(value);
+            }
+        }
 
 
         /// <summary>
@@ -77,6 +89,7 @@ namespace Lucene.Net.Util
         public CharsRef(int capacity)
         {
             this.Chars = new char[capacity];
+            
         }
 
         /// <summary>
@@ -227,13 +240,13 @@ namespace Lucene.Net.Util
         /// <summary>
         ///     Used to grow the reference array.
         /// </summary>
-        /// <param name="newLength">The minimum length to grow the internal array.</param>
-        internal void Grow(int newLength)
+        /// <param name="capacity">The minimum length to grow the internal array.</param>
+        internal void Grow(int capacity)
         {
             Debug.Assert(Offset == 0);
-            if (this.Chars.Length < newLength)
+            if (this.Chars.Length < capacity)
             {
-                this.Chars = ArrayUtil.Grow(this.Chars, newLength);
+                this.Chars = ArrayUtil.Grow(this.Chars, capacity);
             }
         }
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/src/Lucene.Net.Core/Util/CharsRefBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/CharsRefBuilder.cs b/src/Lucene.Net.Core/Util/CharsRefBuilder.cs
index 16a96aa..eef8922 100644
--- a/src/Lucene.Net.Core/Util/CharsRefBuilder.cs
+++ b/src/Lucene.Net.Core/Util/CharsRefBuilder.cs
@@ -188,7 +188,7 @@ namespace Lucene.Net.Util
 
             this.Grow(length);
 
-            this.charsRef.Length = UnicodeUtil.Utf8ToUtf16(bytes, offset, length, this.charsRef);
+            this.charsRef.Length = UnicodeUtil.Utf8ToUtf16(bytes, offset, length, this.Chars);
         }
 
         /// <inherits />
@@ -203,9 +203,9 @@ namespace Lucene.Net.Util
         /// Resizes and increases the length of the reference array.
         /// </summary>
         /// <param name="minimumSize">The minimum size to grow the array.</param>
-        public void Grow(int minimumSize)
+        public void Grow(int capacity)
         {
-            this.charsRef.Chars = ArrayUtil.Grow(this.charsRef.Chars, minimumSize);
+            this.charsRef.Chars = ArrayUtil.Grow(this.charsRef.Chars, capacity);
         }
 
         /// <inherits />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/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 4e46ef9..363232f 100644
--- a/src/Lucene.Net.Core/Util/UnicodeUtil.cs
+++ b/src/Lucene.Net.Core/Util/UnicodeUtil.cs
@@ -10,16 +10,18 @@
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * WITHbytes WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 namespace Lucene.Net.Util
 {
+    using System;
     using System.Collections.Generic;
     using System.Diagnostics;
     using System.Linq;
+    using Lucene.Net.Support;
 
     /// <summary>
     ///     Utility methods for dealing with unicode.
@@ -31,6 +33,7 @@ namespace Lucene.Net.Util
         public const int UNI_SUR_LOW_START = 0xDC00;
         public const int UNI_SUR_LOW_END = 0xDFFF;
         public const int UNI_REPLACEMENT_CHAR = 0xFFFD;
+        public const int MAX_UTF8_BYTES_PER_CHAR = 4;
         private const int MIN_SUPPLEMENTARY_CODE_POINT = 0x10000;
 
         private const long UNI_MAX_BMP = 0x0000FFFF;
@@ -39,89 +42,153 @@ namespace Lucene.Net.Util
         private const long HALF_MASK = 0x3FFL;
 
         private const int SURROGATE_OFFSET =
-            MIN_SUPPLEMENTARY_CODE_POINT - (UNI_SUR_HIGH_START << (int) HALF_SHIFT) - UNI_SUR_LOW_START;
+            MIN_SUPPLEMENTARY_CODE_POINT - (UNI_SUR_HIGH_START << (int)HALF_SHIFT) - UNI_SUR_LOW_START;
+
 
         /// <summary>
+        /// UTF16s to UTF8.
         /// </summary>
-        /// <param name="chars"></param>
-        /// <param name="offset"></param>
-        /// <param name="length"></param>
-        /// <param name="result"></param>
-        public static void Utf16ToUtf8(IEnumerable<char> chars, int offset, int length, BytesRef result)
+        /// <param name="sequence">The chars.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        /// <param name="bytes">The bytes.</param>
+        /// <returns>System.Int32.</returns>
+        public static int Utf16ToUtf8(ICharSequence sequence, int offset, int length, byte[] bytes)
         {
-            var end = offset + length;
+            int position = 0,
+                i = offset,
+                end = offset + length;
 
-            var @out = result.Bytes;
-            result.Offset = 0;
-            // Pre-allocate for worst case 4-for-1
-            var maxLen = length*4;
-            if (@out.Length < maxLen)
-            {
-                @out = result.Bytes = new byte[maxLen];
-            }
 
-            var currentOffset = 0;
+            // cast or convert. 
+            var source = sequence;
 
-            var move = offset < end;
+            if (bytes == null)
+                bytes = new byte[length];
 
-            if (move)
+            while (i < end)
             {
-                var list = chars.ToList();
-         
-                for (int i = offset; i < end; i++)
-                {
-                    var code = list[i];
-                    
+                int code = source.CharAt(i++);
 
-                    if (code < 0x80)
-                    {
-                        @out[currentOffset++] = (byte)code;
-                    }
-                    else if (code < 0x800)
-                    {
-                        @out[currentOffset++] = unchecked((byte)(0xC0 | (code >> 6)));
-                        @out[currentOffset++] = unchecked((byte)(0x80 | (code & 0x3F)));
-                    }
-                    else if (code < 0xD800 || code > 0xDFFF)
+                if (code < 0x80)
+                {
+                    bytes[position++] = (byte)code;
+                }
+                else if (code < 0x800)
+                {
+                    bytes[position++] = (byte)(0xC0 | (code >> 6));
+                    bytes[position++] = (byte)(0x80 | (code & 0x3F));
+                }
+                else if (code < 0xD800 || code > 0xDFFF)
+                {
+                    bytes[position++] = (byte)(0xE0 | (code >> 12));
+                    bytes[position++] = (byte)(0x80 | ((code >> 6) & 0x3F));
+                    bytes[position++] = (byte)(0x80 | (code & 0x3F));
+                }
+                else
+                {
+                    // surrogate pair
+                    // confirm valid high surrogate
+                    if (code < 0xDC00 && i < end)
                     {
-                        @out[currentOffset++] = unchecked((byte)(0xE0 | (code >> 12)));
-                        @out[currentOffset++] = unchecked((byte)(0x80 | ((code >> 6) & 0x3F)));
-                        @out[currentOffset++] = unchecked((byte)(0x80 | (code & 0x3F)));
+                        int utf32 = source.CharAt(i);
+                        // confirm valid low surrogate and write pair
+                        if (utf32 >= 0xDC00 && utf32 <= 0xDFFF)
+                        {
+                            utf32 = (code << 10) + utf32 + SURROGATE_OFFSET;
+                            i++;
+                            bytes[position++] = (byte)(0xF0 | (utf32 >> 18));
+                            bytes[position++] = (byte)(0x80 | ((utf32 >> 12) & 0x3F));
+                            bytes[position++] = (byte)(0x80 | ((utf32 >> 6) & 0x3F));
+                            bytes[position++] = (byte)(0x80 | (utf32 & 0x3F));
+                            continue;
+                        }
                     }
-                    else
+                    // replace unpaired surrogate or bytes-of-order low surrogate
+                    // with substitution character
+                    bytes[position++] = (byte)0xEF;
+                    bytes[position++] = (byte)0xBF;
+                    bytes[position++] = (byte)0xBD;
+                }
+            }
+            //assert matches(source, offset, length, bytes, position);
+            return position;
+        }
+
+        /// <summary>
+        /// UTF16s to UTF8.
+        /// </summary>
+        /// <param name="chars">The chars.</param>
+        /// <param name="offset">The offset.</param>
+        /// <param name="length">The length.</param>
+        /// <param name="bytes">The bytes.</param>
+        /// <returns>System.Int32.</returns>
+        public static int Utf16ToUtf8(IEnumerable<char> chars, int offset, int length, byte[] bytes)
+        {
+            int position = 0,
+                i = offset,
+                end = offset + length;
+
+
+            // cast or convert. 
+            var c = chars as char[];
+            var source = c ?? chars.ToArray();
+
+            if (bytes == null)
+                bytes = new byte[length];
+
+            while (i < end)
+            {
+                int code = source[i++];
+
+                if (code < 0x80)
+                {
+                    bytes[position++] = (byte)code;
+                }
+                else if (code < 0x800)
+                {
+                    bytes[position++] = (byte)(0xC0 | (code >> 6));
+                    bytes[position++] = (byte)(0x80 | (code & 0x3F));
+                }
+                else if (code < 0xD800 || code > 0xDFFF)
+                {
+                    bytes[position++] = (byte)(0xE0 | (code >> 12));
+                    bytes[position++] = (byte)(0x80 | ((code >> 6) & 0x3F));
+                    bytes[position++] = (byte)(0x80 | (code & 0x3F));
+                }
+                else
+                {
+                    // surrogate pair
+                    // confirm valid high surrogate
+                    if (code < 0xDC00 && i < end)
                     {
-                        // surrogate pair
-                        // confirm valid high surrogate
-                        if (code < 0xDC00 && (i < end - 1))
+                        int utf32 = (int)source[i];
+                        // confirm valid low surrogate and write pair
+                        if (utf32 >= 0xDC00 && utf32 <= 0xDFFF)
                         {
-                            int utf32 = list[i + 1];
-                            // confirm valid low surrogate and write pair
-                            if (utf32 >= 0xDC00 && utf32 <= 0xDFFF)
-                            {
-                                utf32 = (code << 10) + utf32 + SURROGATE_OFFSET;
-                                i++;
-                                @out[currentOffset++] = unchecked((byte)(0xF0 | (utf32 >> 18)));
-                                @out[currentOffset++] = unchecked((byte)(0x80 | ((utf32 >> 12) & 0x3F)));
-                                @out[currentOffset++] = unchecked((byte)(0x80 | ((utf32 >> 6) & 0x3F)));
-                                @out[currentOffset++] = unchecked((byte)(0x80 | (utf32 & 0x3F)));
-                                continue;
-                            }
+                            utf32 = (code << 10) + utf32 + SURROGATE_OFFSET;
+                            i++;
+                            bytes[position++] = (byte)(0xF0 | (utf32 >> 18));
+                            bytes[position++] = (byte)(0x80 | ((utf32 >> 12) & 0x3F));
+                            bytes[position++] = (byte)(0x80 | ((utf32 >> 6) & 0x3F));
+                            bytes[position++] = (byte)(0x80 | (utf32 & 0x3F));
+                            continue;
                         }
-                        // replace unpaired surrogate or out-of-order low surrogate
-                        // with substitution character
-                        @out[currentOffset++] = 0xEF;
-                        @out[currentOffset++] = 0xBF;
-                        @out[currentOffset++] = 0xBD;
                     }
+                    // replace unpaired surrogate or bytes-of-order low surrogate
+                    // with substitution character
+                    bytes[position++] = (byte)0xEF;
+                    bytes[position++] = (byte)0xBF;
+                    bytes[position++] = (byte)0xBD;
                 }
             }
-
-            
-            //assert matches(s, offset, length, out, otheroffset);
-            result.Length = currentOffset;
+            //assert matches(source, offset, length, bytes, position);
+            return position;
         }
 
 
+
+
         /// <summary>
         ///     Interprets the given byte array as UTF-8 and converts to UTF-16. The <seealso cref="CharsRef" /> will be extended
         ///     if
@@ -130,58 +197,54 @@ namespace Lucene.Net.Util
         /// <remarks>
         ///     <para>
         ///         NOTE: Full characters are read, even if this reads past the length passed (and
-        ///         can result in an ArrayOutOfBoundsException if invalid UTF-8 is passed).
+        ///         can result in an ArraybytesOfBoundsException if invalid UTF-8 is passed).
         ///         Explicit checks for valid UTF-8 are not performed.
         ///     </para>
         /// </remarks>
         // TODO: broken if chars.offset != 0
-        public static int Utf8ToUtf16(byte[] utf8, int offset, int length, CharsRef chars)
+        public static int Utf8ToUtf16(byte[] utf8Bytes, int offset, int length, char[] chars)
         {
-            int outOffset = chars.Offset = 0,
-                limit = offset + length;
-
-            var @out = chars.Chars = chars.Chars.Grow(length);
-
+            int charsOffset = 0,
+               limit = offset + length;
             while (offset < limit)
             {
-                var b = utf8[offset++] & 0xff;
+                int b = utf8Bytes[offset++] & 0xff;
                 if (b < 0xc0)
                 {
                     Debug.Assert(b < 0x80);
-                    @out[outOffset++] = (char) b;
+                    chars[charsOffset++] = (char)b;
                 }
                 else if (b < 0xe0)
                 {
-                    @out[outOffset++] = (char) (((b & 0x1f) << 6) + (utf8[offset++] & 0x3f));
+                    chars[charsOffset++] = (char)(((b & 0x1f) << 6) + (utf8Bytes[offset++] & 0x3f));
                 }
                 else if (b < 0xf0)
                 {
-                    @out[outOffset++] =
-                        (char) (((b & 0xf) << 12) + ((utf8[offset] & 0x3f) << 6) + (utf8[offset + 1] & 0x3f));
+                    chars[charsOffset++] = (char)(((b & 0xf) << 12) + ((utf8Bytes[offset] & 0x3f) << 6) + (utf8Bytes[offset + 1] & 0x3f));
                     offset += 2;
                 }
                 else
                 {
-                    Debug.Assert(b < 0xf8, "b = 0x" + b.ToString("x"));
+                    Debug.Assert(b < 0xf8, "b = 0x" + BitConverter.ToString(new[] { (byte)b }));
 
-                    var ch = ((b & 0x7) << 18) + ((utf8[offset] & 0x3f) << 12) + ((utf8[offset + 1] & 0x3f) << 6) +
-                             (utf8[offset + 2] & 0x3f);
+
+                    var ch = ((b & 0x7) << 18) + ((utf8Bytes[offset] & 0x3f) << 12) + ((utf8Bytes[offset + 1] & 0x3f) << 6) + (utf8Bytes[offset + 2] & 0x3f);
                     offset += 3;
                     if (ch < UNI_MAX_BMP)
                     {
-                        @out[outOffset++] = (char) ch;
+                        chars[charsOffset++] = (char)ch;
                     }
                     else
                     {
-                        var chHalf = ch - 0x0010000;
-                        @out[outOffset++] = (char) ((chHalf >> 10) + 0xD800);
-                        @out[outOffset++] = (char) ((chHalf & HALF_MASK) + 0xDC00);
+                        int chHalf = ch - 0x0010000;
+                        chars[charsOffset++] = (char)((chHalf >> 10) + 0xD800);
+                        chars[charsOffset++] = (char)((chHalf & HALF_MASK) + 0xDC00);
                     }
                 }
             }
-            chars.Length = outOffset - chars.Offset;
+            return charsOffset;
+
 
-            return chars.Length;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/test/Lucene.Net.Core.Tests/Support/TestNumberExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Support/TestNumberExtensionMethods.cs b/test/Lucene.Net.Core.Tests/Support/TestNumberExtensionMethods.cs
index d931fb0..86341e5 100644
--- a/test/Lucene.Net.Core.Tests/Support/TestNumberExtensionMethods.cs
+++ b/test/Lucene.Net.Core.Tests/Support/TestNumberExtensionMethods.cs
@@ -1,8 +1,19 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 namespace Lucene.Net.Support
 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs b/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
index 88993dc..f7b6897 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
@@ -39,27 +39,29 @@ namespace Lucene.Net.Util
                     stringList.Clear();
                 }
                 int entries = this.AtLeast(500);
-                BytesRef spare = new BytesRef();
+                var spare = new BytesRefBuilder();
                 int initSize = list.Length;
                 for (int i = 0; i < entries; i++)
                 {
                     string randomRealisticUnicodeString = random.RandomRealisticUnicodeString();
                     spare.CopyChars(randomRealisticUnicodeString);
-                    Equal(i + initSize, list.Append(spare));
+                    Equal(i + initSize, list.Append(spare.ToBytesRef()));
                     stringList.Add(randomRealisticUnicodeString);
                 }
                 for (int i = 0; i < entries; i++)
                 {
-                    NotNull(list.Retrieve(spare, i));
-                    Equal(stringList[i], spare.Utf8ToString(), "entry " + i + " doesn't match");
+                    var bytesRef = list.Retrieve(spare, i);
+                    NotNull(bytesRef);
+                    Equal(stringList[i], bytesRef.Utf8ToString(), "entry " + i + " doesn't match");
                 }
 
                 // check random
                 for (int i = 0; i < entries; i++)
                 {
                     int e = random.Next(entries);
-                    NotNull(list.Retrieve(spare, e));
-                    Equal(stringList[e], spare.Utf8ToString(), "entry " + i + " doesn't match");
+                    var bytesRef = list.Retrieve(spare, e);
+                    NotNull(bytesRef);
+                    Equal(stringList[e], bytesRef.Utf8ToString(), "entry " + i + " doesn't match");
                 }
                 for (int i = 0; i < 2; i++)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/8e7e1043/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs b/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
index 02f5b34..35b789c 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
@@ -29,11 +29,11 @@ namespace Lucene.Net.Util
     public class TestCharsRef : LuceneTestCase
     {
         [Test]
-        public void testUTF16InUTF8Order()
+        public void TestUtf16InUtf8Order()
         {
-            int iterations = this.AtLeast(1000);
-            BytesRef[] utf8 = new BytesRef[iterations];
-            CharsRef[] utf16 = new CharsRef[iterations];
+            var iterations = this.AtLeast(1000);
+            var utf8 = new BytesRef[iterations];
+            var utf16 = new CharsRef[iterations];
 
             iterations.Times((i) =>
             {
@@ -42,12 +42,12 @@ namespace Lucene.Net.Util
                 utf16[i] = new CharsRef(s);
             });
 
-            Array.Sort(utf8);
+            Array.Sort(utf8, BytesRef.Utf8SortedAsUnicodeComparer);
 #pragma warning disable 0612, 0618
             Array.Sort(utf16, CharsRef.Utf16SortedAsUtf8Comparer);
 #pragma warning restore 0612, 0618
 
-            iterations.Times((i) => Equal(utf8[i].Utf8ToString(), utf16[i].ToString()));
+            iterations.Times(i => Equal(utf8[i].Utf8ToString(), utf16[i].ToString()));
         }
 
 


[7/7] lucenenet git commit: updating readme

Posted by mh...@apache.org.
updating readme


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

Branch: refs/heads/pcl
Commit: ecf03e102d656e4a2c193d6ca2dc7333e32f3d21
Parents: d90ecf3
Author: Michael Herndon <mh...@michaelherndon.com>
Authored: Sun Nov 9 17:06:09 2014 -0500
Committer: Michael Herndon <mh...@michaelherndon.com>
Committed: Sun Nov 9 17:06:09 2014 -0500

----------------------------------------------------------------------
 README.md | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/ecf03e10/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 829d82a..acdeace 100644
--- a/README.md
+++ b/README.md
@@ -17,6 +17,10 @@ This branch is on hiatus as I'm currently working on extending Xunit.Net to have
 
 I've also started separate code that provides the same apis found in Java but .Net into a separate library in hopes that it will make it easier for others to port code from Java.  
 
+The Mettle Project can be found here: 
+* https://github.com/michaelherndon/xunit
+* https://github.com/michaelherndon/mettle
+
 - Michael
 
 ## Getting Started


[3/7] lucenenet git commit: creating new projects in order to separate out logic create to suppliment .NET with JAVA standard library functionality.

Posted by mh...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Util/LuceneTestCase.cs b/test/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
index f3428c6..c9a1803 100644
--- a/test/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/test/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -19,6 +19,7 @@ using System.Runtime.Serialization;
 
 namespace Lucene.Net.Util
 {
+    using Lucene.Net.Random;
 #if PORTABLE || K10
     using Lucene.Net.Support;
 #endif
@@ -28,7 +29,7 @@ namespace Lucene.Net.Util
     using System.Threading;
     using Xunit;
 
-    public class LuceneTestCase
+    public class LuceneTestCase : TestClass
     {
         /// <summary>
         ///  A random multiplier which you should use when writing random tests:
@@ -41,226 +42,14 @@ namespace Lucene.Net.Util
         /// </summary>
         public static bool TEST_NIGHTLY = SystemProps.Get<Boolean>("tests:nightly", false);
 
-        private static ThreadLocal<System.Random> random;
 
-        static LuceneTestCase()
+        public static int AtLeast(int minimumValue)
         {
-            random = new ThreadLocal<System.Random>(() => {
-
-              
-                return new System.Random((int) DateTime.Now.Ticks & 0x0000FFFF);
-            });
-        }
-
-        public LuceneTestCase()
-        {
-           
-        }
-
-        /// <summary>
-        /// Placeholder for random values.
-        /// </summary>
-        public System.Random Random
-        {
-            get { return random.Value; }  
-        }
-
-#if XUNIT
-
-        [Serializable]
-        public class LuceneAssertionException : Exception
-        {
-            //
-            // For guidelines regarding the creation of new exception types, see
-            //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
-            // and
-            //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
-            //
-
-            public LuceneAssertionException()
-            {
-            }
-
-            public LuceneAssertionException(string message) : base(message)
-            {
-            }
-
-            public LuceneAssertionException(string message, Exception inner) : base(message, inner)
-            {
-            }
-
-#if NET45
-            protected LuceneAssertionException(
-                System.Runtime.Serialization.SerializationInfo info,
-                StreamingContext context) : base(info, context)
-            {
-            }
-#endif
-        }
-
-        [DebuggerHidden]
-        public static void Null(object value, string message = null, params  object[] args)
-        {
-            try
-            {
-                Assert.Null(value);
-            }
-            catch (Exception ex)
-            {
-                var msg = message ?? "The value must be null.";
-                if (args != null && args.Length > 0)
-                    msg = string.Format(msg, args);
-
-                throw new LuceneAssertionException(msg, ex);
-            }
-        }
-
-        public static void NotNull(object value, string message = null, params object[] args)
-        {
-            try
-            {
-                Assert.NotNull(value);
-            }
-            catch (Exception ex)
-            {
-                var msg = message ?? "The value must not be null.";
-                if (args != null && args.Length > 0)
-                    msg = string.Format(msg, args);
-
-                throw new LuceneAssertionException(msg, ex);
-            }
-        }
-
-        /// <summary>
-        /// Asserts that two object are the same.
-        /// </summary>
-        /// <param name="expected">The expected value.</param>
-        /// <param name="actual">The actual value.</param>
-        [DebuggerHidden]
-        public static void Same(object expected, object actual)
-        {
-            Assert.Same(expected, actual);
-        }
-
-        /// <summary>
-        /// Assert that two objects are not the same.
-        /// </summary>
-        /// <param name="expected">The expected value.</param>
-        /// <param name="actual">The actual value.</param>
-        [DebuggerHidden]
-        public static void NotSame(object expected, object actual)
-        {
-            Assert.NotSame(expected, actual);
-        }
-
-        [DebuggerHidden]
-        public static void Equal(string expected, string actual, string message = null, params object[] args)
-        {
-            try
-            {
-                Assert.Equal(expected, actual);
-            }
-            catch (Exception ex)
-            {
-                if (message == null)
-                    throw;
-
-                var msg = message;
-                if (args != null && args.Length > 0)
-                    msg = string.Format(msg, args);
-
-                throw new LuceneAssertionException(msg, ex);
-            }
-        }
-
-        [DebuggerHidden]
-        public static void Equal<T>(T expected, T actual, string message = null, params object[] args)
-        {
-            try
-            {
-                Assert.Equal(expected, actual);
-            }
-            catch (Exception ex)
-            {
-                if (message == null)
-                    throw;
-
-                var msg = message;
-                if (args != null && args.Length > 0)
-                    msg = string.Format(msg, args);
-
-                throw new LuceneAssertionException(msg, ex);
-            }
-        }
-
-        [DebuggerHidden]
-        public static void Equal<T>(IEnumerable<T> expected, IEnumerable<T> actual, string message= null, params object[] args)
-        {
-            try
-            {
-                Assert.Equal(expected, actual);
-            }
-            catch (Exception ex)
-            {
-                if (message == null)
-                    throw;
-
-                var msg = message;
-                if (args != null && args.Length > 0)
-                    msg = string.Format(msg, args);
-
-                throw new LuceneAssertionException(msg, ex);
-            }
-        }
-
-        [DebuggerHidden]
-        public static void NotEqual<T>(T expected, T actual, string message = null, params object[] args)
-        {
-            try
-            {
-                Assert.NotEqual(expected, actual);
-            }
-            catch (Exception ex)
-            {
-                if (message == null)
-                    throw;
-
-                var msg = message;
-                if (args != null && args.Length > 0)
-                    msg = string.Format(msg, args);
-
-                throw new LuceneAssertionException(msg, ex);
-            }
-           
+            int min = (LuceneTestCase.TEST_NIGHTLY ? 2 * minimumValue : minimumValue) * LuceneTestCase.RANDOM_MULTIPLIER;
+            int max = min + (min / 2);
+            return Random.NextBetween(min, max);
         }
 
-
-        [DebuggerHidden]
-        public static void Ok(bool condition, string message = null, params object[] values)
-        {
-            if (!string.IsNullOrWhiteSpace(message))
-            {
-                var exceptionMessage = message;
-
-                if(values != null && values.Length > 0)
-                {
-                    exceptionMessage = String.Format(exceptionMessage, values);
-                }
-
-                Assert.True(condition, exceptionMessage);
-            }
-            else 
-            {
-                Assert.True(condition);    
-            }
-        }
-
-        [DebuggerHidden]
-        public static T Throws<T>(Action code) where T : Exception
-        {
-            return Assert.Throws<T>(code);
-        }
-        
-        #endif
+       
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Util/TestAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Util/TestAttribute.cs b/test/Lucene.Net.TestFramework/Util/TestAttribute.cs
deleted file mode 100644
index 158afa6..0000000
--- a/test/Lucene.Net.TestFramework/Util/TestAttribute.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Lucene.Net.Util
-{
-    using System;
-    using System.Collections.Generic;
-    using System.Linq;
-    using Xunit.Abstractions;
-    using Xunit.Sdk;
-
-    /// <summary>
-    /// Summary description for TestAttribute
-    /// </summary>
-    public class TestAttribute : Xunit.FactAttribute
-    {
-
-        public string JavaMethodName { get; set; }
-
-        public TestAttribute(string displayName, string javaMethodName = null, string skip = null)
-        {
-            this.DisplayName = displayName;
-            this.Skip = skip;
-            this.JavaMethodName = javaMethodName;
-        }
-
-	    public TestAttribute()
-	    {
-	    }
-    }
-
-    [TraitDiscoverer("TicketDiscoverer", "TraitExtensibility")]
-    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
-    public class TicketAttribute : System.Attribute, Xunit.Sdk.ITraitAttribute
-    {
-        public string Ticket { get; private set; }
-
-        public string Description { get; private set; }
-
-         public TicketAttribute(string ticket, string description)
-         {
-             this.Ticket = ticket;
-             this.Description = description;
-         }
-    }
-
-    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
-    public class PerfAttribute : CategoryAttribute
-    {
-
-        public PerfAttribute()
-            : base("Performance")
-        {
-
-        }
-    }
-
-    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
-    public class NightlyAttribute : CategoryAttribute
-    {
-
-        public NightlyAttribute()
-            : base("Nightly")
-        {
-
-        }
-    }
-
-    [TraitDiscoverer("CategoryDiscoverer", "TraitExtensibility")]
-    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
-    public class CategoryAttribute : System.Attribute, Xunit.Sdk.ITraitAttribute
-    {
-        public string Name { get; private set; }
-
-        public CategoryAttribute(string category)
-        {
-            this.Name = category;
-        }
-    }
-
-    /// <summary>
-    /// This class discovers all of the tests and test classes that have
-    /// applied the Category attribute
-    /// </summary>
-    public class TicketDiscoverer : ITraitDiscoverer
-    {
-        /// <summary>
-        /// Gets the trait values from the Category attribute.
-        /// </summary>
-        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
-        /// <returns>The trait values.</returns>
-        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
-        {
-            var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
-            var message = "";
-
-            if(ctorArgs.Count > 0)
-                message = ctorArgs[1].ToString();
-            
-              
-            yield return new KeyValuePair<string, string>("Ticket", ctorArgs[0].ToString());
-            yield return new KeyValuePair<string, string>("Ticket Description", message);
-        }
-    }
-
-    /// <summary>
-    /// This class discovers all of the tests and test classes that have
-    /// applied the Category attribute
-    /// </summary>
-    public class CategoryDiscoverer : ITraitDiscoverer
-    {
-        /// <summary>
-        /// Gets the trait values from the Category attribute.
-        /// </summary>
-        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
-        /// <returns>The trait values.</returns>
-        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
-        {
-            var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
-            yield return new KeyValuePair<string, string>("Category", ctorArgs[0].ToString());
-        }
-    }
-}
\ No newline at end of file


[6/7] lucenenet git commit: Separated Java Compatability code into its own project, updating the readme as this branch is on hiatus as I work on extending xunit.net to handle Junit TestRules and Carrot Search's randomization.

Posted by mh...@apache.org.
Separated Java Compatability code into its own project, updating the readme as this branch is on hiatus as I work on extending xunit.net to handle Junit TestRules and Carrot Search's randomization.


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

Branch: refs/heads/pcl
Commit: d90ecf3f6690fddd60f021a91b6cac30066c71a6
Parents: 4b4d4d9
Author: Michael Herndon <mh...@michaelherndon.com>
Authored: Sun Nov 9 17:03:45 2014 -0500
Committer: Michael Herndon <mh...@michaelherndon.com>
Committed: Sun Nov 9 17:03:45 2014 -0500

----------------------------------------------------------------------
 Lucene.vs2013.sln.GhostDoc.user.dic             |  2 +
 README.md                                       |  8 ++
 docs/sorting.md                                 |  2 +-
 src/Lucene.Net.Java/Lang/Long.cs                | 92 ++++++++++++++++++--
 src/Lucene.Net.Java/Lucene.Net.Java.csproj      | 11 +++
 src/Lucene.Net.Java/Util/DualPivotQuicksort.cs  | 40 +++++++++
 src/Lucene.Net.Java/Util/InsertionSort.cs       | 57 +++++++++++-
 test/Lucene.Net.Java.Tests/Lang/LongTests.cs    | 46 ++++++++++
 .../Lucene.Net.Java.Tests.csproj                |  1 +
 .../Lucene.Net.TestFramework.Core.csproj        |  9 ++
 10 files changed, 255 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/Lucene.vs2013.sln.GhostDoc.user.dic
----------------------------------------------------------------------
diff --git a/Lucene.vs2013.sln.GhostDoc.user.dic b/Lucene.vs2013.sln.GhostDoc.user.dic
index 7da4c3e..28ec1a0 100644
--- a/Lucene.vs2013.sln.GhostDoc.user.dic
+++ b/Lucene.vs2013.sln.GhostDoc.user.dic
@@ -1,3 +1,5 @@
+const
+csharp
 indices
 init
 Quicksort

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index d2ad9f4..829d82a 100644
--- a/README.md
+++ b/README.md
@@ -12,6 +12,13 @@ Apache Lucene.Net is compiled against Microsoft .NET Framework 4.0
 The Apache Lucene.Net web site is at:
   http://lucenenet.apache.org
 
+## NOTICE
+This branch is on hiatus as I'm currently working on extending Xunit.Net to have similar functionality to JUnit for TestRules and to enable randomization testing from carrot search.  I'm also working on making the story for running tests quickly from the command line.  
+
+I've also started separate code that provides the same apis found in Java but .Net into a separate library in hopes that it will make it easier for others to port code from Java.  
+
+- Michael
+
 ## Getting Started
 
 ### Windows Users
@@ -68,6 +75,7 @@ $ k test
  * Implement a ci server, possibly appveyor
  * Generate Code Documentation.
  * Port core, test-framework, and tests for core. 
+  * 
 
 ## Notes
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/docs/sorting.md
----------------------------------------------------------------------
diff --git a/docs/sorting.md b/docs/sorting.md
index 1b26773..7581a3b 100644
--- a/docs/sorting.md
+++ b/docs/sorting.md
@@ -4,7 +4,7 @@ The system libraries in Java and C# have differences in the default sorting mech
 
 [Array.Sort](http://msdn.microsoft.com/en-us/library/kwx6zbd4\(v=vs.110\).aspx)in C# uses [Quick Sort](http://algs4.cs.princeton.edu/23quicksort) as the default algorithm for soring.
 
-[Array.sort](http://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort(T\[\],%20java.util.Comparator) in in Java uses the [Tim Sort](http://svn.python.org/projects/python/trunk/Objects/listsort.txt) as the default sorting algorithm as of Java 7.
+[Array.sort](http://docs.oracle.com/javase/7/docs/api/java/util/Arrays.html#sort(T\[\],%20java.util.Comparator) in in Java uses the [Tim Sort](http://svn.python.org/projects/python/trunk/Objects/listsort.txt) as the default sorting algorithm as of Java 7 for Object arrays and using the Dual Pivot Quick Sort (unstable) for primitive typed arrays.
 
 The differences in sorting methods could account for the discrepencies between running ported tests for the various sorting algorithms in Lucene core.
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/src/Lucene.Net.Java/Lang/Long.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Lang/Long.cs b/src/Lucene.Net.Java/Lang/Long.cs
index c532c84..e0b261e 100644
--- a/src/Lucene.Net.Java/Lang/Long.cs
+++ b/src/Lucene.Net.Java/Lang/Long.cs
@@ -36,8 +36,12 @@ namespace Java.Lang
             public static int Position(long value)
             {
                 var v = value;
+                // TODO: find a better way of handling negative indices for DeBruijn64.Position
+                var index =  ((v & -v)*0x022fdd63cc95386d >> 58);
+                if (0 > index)
+                    index = 64 + index;
 
-                return POSITIONS[(v & -v) * 0x022fdd63cc95386d >> 58];
+                return POSITIONS[index]; 
             }
         }
 
@@ -46,20 +50,45 @@ namespace Java.Lang
 
 
         /// <summary>
-        /// Returns the leading zeros from the value.
+        /// Returns the leading zeros from the binary expression of the value.
         /// </summary>
+        /// <remarks>
+        ///     <para>
+        ///      A long is 64 bits. Each bit is either a one or a zero.
+        ///     <see cref="NumberOfLeadingZeros(long)"/> will count zeros from the left most bit towards the right
+        ///     till it reaches the first bit that has a value of one.  Binary is often
+        ///     written as 
+        ///     <a href="http://simple.wikipedia.org/wiki/Hexadecimal_numeral_system">hexadecimal literal or hex digit</a> in code.    
+        ///     </para>
+        ///     <example>
+        ///     <code lang="csharp"> 
+        ///     // The counting stops at the first bit that has a one value starting from the left side.
+        ///     // In the case below, the first bit with a value of one is in the 16th position.
+        ///     //
+        ///     // hex value, long value
+        ///     // 0x1F00F0f00F111L = (Long)545422443606289;
+        ///     //
+        ///     // this is the binary form of the long value being tested:
+        ///     // |                 | 15 zeros 
+        ///     // 0000 0000 0000 0001 1111 0000 0000 1111 0000 1111 0000 0000 1111 0001 0001 0001
+        ///     const long value2 = 0x1F00F0f00F111L;
+        ///     Assert.Equal(15, Long.NumberOfLeadingZeros(value2), "The number of leading zeros must be 15");
+        ///     </code>
+        ///     </example>
+        /// </remarks>
         /// <param name="value">The value.</param>
-        /// <returns>System.Int32.</returns>
+        /// <returns>The number of leading zeros.</returns>
         public static int NumberOfLeadingZeros(long value)
         {
             return (int)NumberOfLeadingZeros((ulong)value);
         }
 
         /// <summary>
-        /// Returns the leading zeros from the value.
+        /// Returns the leading zeros from the binary expression of the value.  
         /// </summary>
+        /// <seealso cref="NumberOfLeadingZeros(long)"/>
         /// <param name="value">The value.</param>
-        /// <returns>System.UInt32.</returns>
+        /// <returns>The number of leading zeros.</returns>
         [CLSCompliant(false)]
         public static uint NumberOfLeadingZeros(ulong value)
         {
@@ -105,18 +134,39 @@ namespace Java.Lang
 
         // ReSharper disable once CSharpWarnings::CS1584
         /// <summary>
-        /// Returns the number of trailing zeros. i.e 100 has two trailing zeros.
+        /// Returns the number of trailing zeros from the binary value.
         /// </summary>
         /// <param name="value">The value to be inspected for trailing zeros.</param>
         /// <remarks>
         ///     <para>
-        ///         We're using the De Bruijn sequences based upon the various bit twiddling hacks found in 
-
+        ///      A long is 64 bits. Each bit is either a one or a zero.
+        ///     <see cref="NumberOfTrailingZeros(long)"/> will count zeros from the right most bit towards the left
+        ///     till it reaches the first bit that has a value of one.  Binary is often
+        ///     written as 
+        ///     <a href="http://simple.wikipedia.org/wiki/Hexadecimal_numeral_system">hexadecimal literal or hex digit</a> in code.    
+        ///     </para>
+        ///     <example>
+        ///     <code lang="csharp"> 
+        ///     // The counting stops at the first bit that has a one value starting from the right side.
+        ///     // In the case below, the first bit with a value of one is in the 16th position.
+        ///     //
+        ///     // hex value, long value
+        ///     // 0x80000L = (Long) 524288;
+        ///     //
+        ///     // this is the binary form of the long value being tested:
+        ///     //                                                        |                      | 19 zeros 
+        ///     // 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 1000 0000 0000 0000 0000
+        ///     const long value3 = 0x80000L;
+        ///     Assert.Equal(19, Long.NumberOfTrailingZeros(value3), "The number of trailing zeros must be 19");
+        ///     </code>
+        ///     </example>
+        ///     <para>
+        ///         We're using the De Bruijn sequences based upon the various bit twiddling hacks found in
         ///         an online paper stanford <see href="https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup" />
         ///     </para>
         ///     <para>
         ///          It should be faster than Java's native 
-        ///          <see href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/lang/Integer.java#Integer.numberOfTrailingZeros%28int%29">
+        ///          <see href="http://docs.oracle.com/javase/7/docs/api/java/lang/Long.html#numberOfTrailingZeros(long)">
         ///          Long.numberOfTrailingZeros
         ///          </see> which uses the binary search method of finding trailing zeros.  
         ///     </para>
@@ -127,11 +177,23 @@ namespace Java.Lang
             return DeBruijn64.Position(value);
         }
 
+        /// <summary>
+        /// Rotates the left.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        /// <param name="shift">The shift.</param>
+        /// <returns>System.Int64.</returns>
         public static long RotateLeft(long value, int shift)
         {
             return (long)RotateLeft((ulong) value, shift);
         }
 
+        /// <summary>
+        /// Rotates the left.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        /// <param name="shift">The shift.</param>
+        /// <returns>System.UInt64.</returns>
         [CLSCompliant(false)]
         public static ulong RotateLeft(ulong value, int shift)
         {
@@ -139,11 +201,23 @@ namespace Java.Lang
         }
 
 
+        /// <summary>
+        /// Rotates the right.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        /// <param name="shift">The shift.</param>
+        /// <returns>System.Int64.</returns>
         public static long RotateRight(long value, int shift)
         {
             return (long)RotateRight((ulong) value, shift);
         }
 
+        /// <summary>
+        /// Rotates the right.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        /// <param name="shift">The shift.</param>
+        /// <returns>System.UInt64.</returns>
         [CLSCompliant(false)]
         public static ulong RotateRight(ulong value, int shift)
         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/src/Lucene.Net.Java/Lucene.Net.Java.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Lucene.Net.Java.csproj b/src/Lucene.Net.Java/Lucene.Net.Java.csproj
index 2a13128..c07d0ae 100644
--- a/src/Lucene.Net.Java/Lucene.Net.Java.csproj
+++ b/src/Lucene.Net.Java/Lucene.Net.Java.csproj
@@ -15,6 +15,8 @@
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -24,6 +26,7 @@
     <DefineConstants>DEBUG;TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <DocumentationFile>bin\Debug\Lucene.Net.Java.XML</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
@@ -32,6 +35,7 @@
     <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
+    <DocumentationFile>bin\Release\Lucene.Net.Java.XML</DocumentationFile>
   </PropertyGroup>
   <ItemGroup>
     <!-- A reference to the entire .NET Framework is automatically included -->
@@ -50,6 +54,13 @@
     <None Include="Readme.md" />
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
+  </Target>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs b/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs
index d880c1a..c08e169 100644
--- a/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs
+++ b/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs
@@ -732,6 +732,11 @@ namespace Java.Util
             PerformSort(array, less, great);
         }
 
+        /// <summary>
+        /// Sorts the specified array.
+        /// </summary>
+        /// <param name="array">The array.</param>
+        /// <returns>System.Int64[].</returns>
         public static long[] Sort(long[] array)
         {
             Check.NotNull("array", array);
@@ -739,6 +744,13 @@ namespace Java.Util
             return array;
         }
 
+        /// <summary>
+        /// Sorts the specified array.
+        /// </summary>
+        /// <param name="array">The array.</param>
+        /// <param name="start">The start.</param>
+        /// <param name="count">The count.</param>
+        /// <returns>System.Int64[].</returns>
         public static long[] Sort(long[] array, int start, int count)
         {
             Check.NotNull("array", array);
@@ -908,17 +920,37 @@ namespace Java.Util
             return left.CompareTo(right) < 0;
         }
 
+        /// <summary>
+        /// Greaters the than.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="left">The left.</param>
+        /// <param name="right">The right.</param>
+        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
         private static bool GreaterThan<T>(T left, T right) where T : IComparable<T>
         {
             return left.CompareTo(right) > 0;
         }
 
+        /// <summary>
+        /// Greaters the than or equal to.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="left">The left.</param>
+        /// <param name="right">The right.</param>
+        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
         private static bool GreaterThanOrEqualTo<T>(T left, T right) where T : IComparable<T>
         {
             var compare = left.CompareTo(right);
             return compare > 0 || compare == 0;
         }
 
+        /// <summary>
+        /// Sorts the specified list.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="list">The list.</param>
+        /// <returns>IList&lt;T&gt;.</returns>
         public static IList<T> Sort<T>(IList<T> list) where T: IComparable<T>
         {
             Check.NotNull("array", list);
@@ -927,6 +959,14 @@ namespace Java.Util
             return list;
         }
 
+        /// <summary>
+        /// Sorts the specified list.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="list">The list.</param>
+        /// <param name="start">The start.</param>
+        /// <param name="count">The count.</param>
+        /// <returns>IList&lt;T&gt;.</returns>
         public static IList<T> Sort<T>(IList<T> list, int start, int count)  where T: IComparable<T> 
         {
             Check.NotNull("array", list);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/src/Lucene.Net.Java/Util/InsertionSort.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Util/InsertionSort.cs b/src/Lucene.Net.Java/Util/InsertionSort.cs
index 5e27c58..5346d03 100644
--- a/src/Lucene.Net.Java/Util/InsertionSort.cs
+++ b/src/Lucene.Net.Java/Util/InsertionSort.cs
@@ -20,11 +20,20 @@ namespace Java.Util
     using System;
     using System.Collections.Generic;
 
+    // ReSharper disable CSharpWarnings::CS1574
+    /// <summary>
+    /// An efficient simple <strong>stable</strong> sort for really small data sets.
+    /// </summary>
     public static class InsertionSort
     {
 
-      
-
+        /// <summary>
+        /// Swaps the values for the left and right indices in the specified list.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="list">The list.</param>
+        /// <param name="left">The left.</param>
+        /// <param name="right">The right.</param>
         private static void Swap<T>(IList<T> list,int left , int right )
         {
             var reference = list[left];
@@ -35,6 +44,13 @@ namespace Java.Util
 
 
 
+        /// <summary>
+        /// Sorts the specified list.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="list">The list.</param>
+        /// <returns>The sorted <see cref="System.Collections.Generic.IList{T}"/>.</returns>
+        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="list"/> is null.</exception>
         public static IList<T> Sort<T>(IList<T> list) where T : IComparable<T>
         {
             Check.NotNull("list", list);
@@ -42,6 +58,20 @@ namespace Java.Util
             return PerformSort(list, 0, list.Count);
         }
 
+        /// <summary>
+        /// Sorts the specified list.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="list">The list.</param>
+        /// <param name="start">The start.</param>
+        /// <param name="count">The count.</param>
+        /// <returns>The sorted <see cref="System.Collections.Generic.IList{T}"/>.</returns>
+        /// <exception cref="ArgumentNullException">Thrown when the <paramref name="list"/> is null.</exception>
+        /// <exception cref="ArgumentOutOfRangeException">
+        ///     Thrown when the start is less than 0 or greater than length, count is less than 0 or greater than
+        ///     <c><paramref name="list"/>.Count</c>, or when the sum of start and count is greater than 
+        ///     <c><paramref name="list"/>.Count</c>.
+        /// </exception>
         public static IList<T> Sort<T>(IList<T> list, int start, int count)where T: IComparable<T>
         {
             Check.NotNull("list", list);
@@ -50,11 +80,18 @@ namespace Java.Util
             return PerformSort(list, start, count);
         }
 
+        /// <summary>
+        /// Performs the sort.
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="list">The list.</param>
+        /// <param name="start">The start.</param>
+        /// <param name="count">The count.</param>
+        /// <returns>The sorted <see cref="System.Collections.Generic.IList{T}"/></returns>
         internal static IList<T> PerformSort<T>(IList<T> list, int start, int count) where T: IComparable<T>
         {
             for (var i = start + 1; i < count; i++)
             {
-               
                 for (var j = i; j > start && list[j - 1].CompareTo(list[j]) >= 0; j--)
                 {
                     // swap
@@ -64,5 +101,19 @@ namespace Java.Util
 
             return list;
         }
+
+        internal static IList<T> PerformSort<T>(IList<T> list, int start, int count, Comparison<T> comparison)
+        {
+            for (var i = start + 1; i < count; i++)
+            {
+                for (var j = i; j > start && comparison(list[j - 1], list[j]) >= 0; j--)
+                {
+                    // swap
+                    Swap(list, j - 1, j);
+                }
+            }
+
+            return list;
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/test/Lucene.Net.Java.Tests/Lang/LongTests.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Lang/LongTests.cs b/test/Lucene.Net.Java.Tests/Lang/LongTests.cs
new file mode 100644
index 0000000..019797a
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Lang/LongTests.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.Java.Lang
+{
+    using global::Java.Lang;
+
+    public class LongTests : TestClass
+    {
+        [Test]
+        public void NumberOfLeadingZeros()
+        {
+            // 0x1FL = (Long) 31
+            // 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0001 1111
+            const long value1 = 0x1FL;
+            Equal(59, Long.NumberOfLeadingZeros(value1), "The number of leading zeros must be 59");
+
+            // 0x1F00F0f00F111L = (Long)545422443606289;
+            // 0000 0000 0000 0001 1111 0000 0000 1111 0000 1111 0000 0000 1111 0001 0001 0001
+            const long value2 = 0x1F00F0f00F111L;
+            Equal(15, Long.NumberOfLeadingZeros(value2), "The number of leading zeros must be 15");
+        }
+
+        [Test]
+        public void NumberOfTrailingZeros()
+        {
+            // 0x8000L = (Long) 32768;
+            // 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 1000 0000 0000 0000
+            const long value1 = 0x8000L;
+            Equal(15, Long.NumberOfTrailingZeros(value1), "The number of trailing zeros must be 15");
+
+            // 0x1F00F0F00F100L = (Long)545422443606272
+            // 0000 0000 0000 0001 1111 0000 0000 1111 0000 1111 0000 0000 1111 0001 0000 0000
+            const long value2 = 0x1F00F0F00F100L;
+            Equal(8, Long.NumberOfTrailingZeros(value2), "The number of trailing zeros must be 8");
+
+            // 0x80000L = (Long) 524288
+            // 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 1000 0000 0000 0000 0000
+            const long value3 = 0x80000L;
+            Equal(19, Long.NumberOfTrailingZeros(value3), "The number of trailing zeros must be 19");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj b/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
index f1114ce..812a7f7 100644
--- a/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
+++ b/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
@@ -40,6 +40,7 @@
     <None Include="packages.config" />
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="Lang\LongTests.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Util\InsertionSortTests.cs" />
     <Compile Include="Util\SortTestClass.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d90ecf3f/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj b/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
index 3e66773..569c3f8 100644
--- a/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
+++ b/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
@@ -15,6 +15,8 @@
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
     <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugSymbols>true</DebugSymbols>
@@ -61,6 +63,13 @@
     </Reference>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
+  </Target>
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
   <Target Name="BeforeBuild">


[5/7] lucenenet git commit: creating new projects in order to separate out logic create to suppliment .NET with JAVA standard library functionality.

Posted by mh...@apache.org.
creating new projects in order to separate out logic create to suppliment .NET with JAVA standard library functionality.


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

Branch: refs/heads/pcl
Commit: 4b4d4d93c9fcfadbd2afecd42d59150e87bdb962
Parents: d324216
Author: Michael Herndon <mh...@michaelherndon.com>
Authored: Sat Aug 23 02:00:50 2014 -0400
Committer: Michael Herndon <mh...@michaelherndon.com>
Committed: Sat Aug 23 02:00:50 2014 -0400

----------------------------------------------------------------------
 Lucene.vs2013.sln                               |   21 +
 Lucene.vs2013.sln.GhostDoc.user.dic             |    1 +
 src/Lucene.Net.Core/Lucene.Net.Core.csproj      |    3 +
 .../Support/BitArrayExtensions.cs               |    4 +
 src/Lucene.Net.Core/Support/BitSet.cs           |   17 +
 src/Lucene.Net.Core/Support/Class1.cs           |    8 +
 src/Lucene.Net.Core/Util/OpenBitSet.cs          |  138 ++-
 src/Lucene.Net.Java/Check.cs                    |   60 +
 src/Lucene.Net.Java/Lang/Int.cs                 |   24 +
 src/Lucene.Net.Java/Lang/Long.cs                |  153 +++
 src/Lucene.Net.Java/Lang/String.cs              |  123 ++
 src/Lucene.Net.Java/Lucene.Net.Java.csproj      |   60 +
 src/Lucene.Net.Java/Lucene.Net.Java.kproj       |   56 +
 src/Lucene.Net.Java/Properties/AssemblyInfo.cs  |   21 +
 src/Lucene.Net.Java/Readme.md                   |   16 +
 src/Lucene.Net.Java/Util/Arrays.cs              |   37 +
 src/Lucene.Net.Java/Util/DualPivotQuicksort.cs  | 1090 ++++++++++++++++++
 src/Lucene.Net.Java/Util/InsertionSort.cs       |   68 ++
 src/Lucene.Net.Java/default.ruleset             |   87 ++
 src/Lucene.Net.Java/packages.config             |    4 +
 src/Lucene.Net.Java/project.json                |   20 +
 .../Lucene.Net.Core.Tests.csproj                |   11 +-
 .../Util/BaseSorterTestCase.cs                  |    6 +-
 .../Lucene.Net.Core.Tests/Util/TestBroadWord.cs |   11 +-
 .../Util/TestByteArrayRef.cs                    |    8 +-
 .../Util/TestByteBlockPool.cs                   |   10 +-
 test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs |    2 +-
 test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs |   16 +-
 .../Util/TestOpenBitSet.cs                      |  439 +++++++
 .../Util/TestWeakIdentityMap.cs                 |    8 +-
 .../Lucene.Net.Java.Tests.csproj                |   83 ++
 .../Properties/AssemblyInfo.cs                  |   30 +
 .../Util/InsertionSortTests.cs                  |   71 ++
 .../Lucene.Net.Java.Tests/Util/SortTestClass.cs |   39 +
 test/Lucene.Net.Java.Tests/packages.config      |   27 +
 test/Lucene.Net.Java.Tests/project.json         |   37 +
 .../CategoryAttribute.cs                        |   44 +
 .../ExtensionMethods.cs                         |   40 +
 .../Lucene.Net.TestFramework.Core.csproj        |   71 ++
 .../NightlyAttribute.cs                         |   18 +
 .../PerformanceAttribute.cs                     |   17 +
 .../Properties/AssemblyInfo.cs                  |   30 +
 .../RandomExtensions.cs                         |   30 +
 test/Lucene.Net.TestFramework.Core/Settings.cs  |   16 +
 .../TestAttribute.cs                            |   30 +
 test/Lucene.Net.TestFramework.Core/TestClass.cs |  226 ++++
 .../TicketAttribute.cs                          |   52 +
 .../packages.config                             |   27 +
 test/Lucene.Net.TestFramework.Core/project.json |   34 +
 .../Lucene.Net.TestFramework.csproj             |   17 +-
 .../Random/RandomExtensions.cs                  |    7 +-
 .../Util/BaseDocIdSetTestCase.cs                |  226 ++++
 .../Util/ExtensionMethods.cs                    |   41 -
 .../Util/LuceneTestCase.cs                      |  225 +---
 .../Util/TestAttribute.cs                       |  137 ---
 55 files changed, 3593 insertions(+), 504 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/Lucene.vs2013.sln
----------------------------------------------------------------------
diff --git a/Lucene.vs2013.sln b/Lucene.vs2013.sln
index 9170178..f2c2d53 100644
--- a/Lucene.vs2013.sln
+++ b/Lucene.vs2013.sln
@@ -13,6 +13,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.TestFramework",
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Core.Tests", "test\Lucene.Net.Core.Tests\Lucene.Net.Core.Tests.csproj", "{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Java", "src\Lucene.Net.Java\Lucene.Net.Java.csproj", "{4AD3FE35-AA0A-4C3C-A043-12711625DF74}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.Java.Tests", "test\Lucene.Net.Java.Tests\Lucene.Net.Java.Tests.csproj", "{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lucene.Net.TestFramework.Core", "test\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj", "{438B8450-E93A-425F-9A9B-11D02E8896D5}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -31,6 +37,18 @@ Global
 		{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}.Release|Any CPU.Build.0 = Release|Any CPU
+		{4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{4AD3FE35-AA0A-4C3C-A043-12711625DF74}.Release|Any CPU.Build.0 = Release|Any CPU
+		{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}.Release|Any CPU.Build.0 = Release|Any CPU
+		{438B8450-E93A-425F-9A9B-11D02E8896D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{438B8450-E93A-425F-9A9B-11D02E8896D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{438B8450-E93A-425F-9A9B-11D02E8896D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{438B8450-E93A-425F-9A9B-11D02E8896D5}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -39,5 +57,8 @@ Global
 		{AD8901C0-209D-4132-80AA-257DBACEECB4} = {CD84C1EF-B845-4914-A9DD-D0F9ACC7DE6F}
 		{F0D68FEA-B118-43B6-B760-3FB75CDE766D} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B}
 		{C879C7A6-FBE5-4F22-B363-A4356C7B8E76} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B}
+		{4AD3FE35-AA0A-4C3C-A043-12711625DF74} = {CD84C1EF-B845-4914-A9DD-D0F9ACC7DE6F}
+		{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B}
+		{438B8450-E93A-425F-9A9B-11D02E8896D5} = {4B0484AA-03E4-47A5-9989-AC42DDE1E06B}
 	EndGlobalSection
 EndGlobal

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/Lucene.vs2013.sln.GhostDoc.user.dic
----------------------------------------------------------------------
diff --git a/Lucene.vs2013.sln.GhostDoc.user.dic b/Lucene.vs2013.sln.GhostDoc.user.dic
index 117fab3..7da4c3e 100644
--- a/Lucene.vs2013.sln.GhostDoc.user.dic
+++ b/Lucene.vs2013.sln.GhostDoc.user.dic
@@ -1,3 +1,4 @@
 indices
 init
+Quicksort
 Subword

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Lucene.Net.Core.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.Core.csproj b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
index 26f3b3b..3d235a3 100644
--- a/src/Lucene.Net.Core/Lucene.Net.Core.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
@@ -62,6 +62,9 @@
     <Compile Include="Check.cs" />
     <Compile Include="Support\ArrayExtensionMethods.cs" />
     <Compile Include="Support\AtomicReferenceArray.cs" />
+    <Compile Include="Support\BitArrayExtensions.cs" />
+    <Compile Include="Support\BitSet.cs" />
+    <Compile Include="Support\Class1.cs" />
     <Compile Include="Support\DeepCloneNotSupportedException.cs" />
     <Compile Include="Support\EnumUtil.cs" />
     <Compile Include="Support\HashMap.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Support/BitArrayExtensions.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/BitArrayExtensions.cs b/src/Lucene.Net.Core/Support/BitArrayExtensions.cs
new file mode 100644
index 0000000..0174a00
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/BitArrayExtensions.cs
@@ -0,0 +1,4 @@
+
+
+
+

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Support/BitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/BitSet.cs b/src/Lucene.Net.Core/Support/BitSet.cs
new file mode 100644
index 0000000..473ce48
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/BitSet.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.Support
+{
+    public class BitSet
+    {
+        private const int BITS_PER_WORD = 1 << 6;
+        private const ulong WORD_MASK = 0xffffffffffffffffL;
+
+
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Support/Class1.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/Class1.cs b/src/Lucene.Net.Core/Support/Class1.cs
new file mode 100644
index 0000000..37fc23b
--- /dev/null
+++ b/src/Lucene.Net.Core/Support/Class1.cs
@@ -0,0 +1,8 @@
+
+
+namespace Lucene.Net.Support
+{
+    class Class1
+    {
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Core/Util/OpenBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/OpenBitSet.cs b/src/Lucene.Net.Core/Util/OpenBitSet.cs
index 7a176e3..2a0bca0 100644
--- a/src/Lucene.Net.Core/Util/OpenBitSet.cs
+++ b/src/Lucene.Net.Core/Util/OpenBitSet.cs
@@ -131,11 +131,21 @@ namespace Lucene.Net.Util
             this.numBits = wordLength * 64;
         }
 
+        /// <summary>
+        /// Provides a <seealso cref="DocIdSetIterator" /> to access the set.
+        /// this implementation can return <code>null</code> if there
+        /// are no docs that match.
+        /// </summary>
+        /// <returns>DocIdSetIterator.</returns>
         public override DocIdSetIterator GetIterator()
         {
             return new OpenBitSetIterator(bits, this.wordLength);
         }
 
+        /// <summary>
+        /// Gets the bits.
+        /// </summary>
+        /// <returns>IBits.</returns>
         public override IBits GetBits()
         {
             return this;
@@ -233,8 +243,8 @@ namespace Lucene.Net.Util
             }
 
             int bit = index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            return (bits[i] & bitmask) != 0;
+            long bitMask = 1L << bit;
+            return (bits[i] & bitMask) != 0;
         }
 
         /// <summary>
@@ -248,8 +258,8 @@ namespace Lucene.Net.Util
             // signed shift will keep a negative index and force an
             // array-index-out-of-bounds-exception, removing the need for an explicit check.
             int bit = index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            return (bits[i] & bitmask) != 0;
+            long bitMask = 1L << bit;
+            return (bits[i] & bitMask) != 0;
         }
 
         /// <summary>
@@ -263,8 +273,8 @@ namespace Lucene.Net.Util
                 return false;
             }
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            return (bits[i] & bitmask) != 0;
+            long bitMask = 1L << bit;
+            return (bits[i] & bitMask) != 0;
         }
 
         /// <summary>
@@ -276,8 +286,8 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int i = (int)(index >> 6); // div 64
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            return (bits[i] & bitmask) != 0;
+            long bitMask = 1L << bit;
+            return (bits[i] & bitMask) != 0;
         }
 
         /*
@@ -288,7 +298,7 @@ namespace Lucene.Net.Util
           return ((bits[i]>>>bit) & 0x01) != 0;
           // this does a long shift and a bittest (on x86) vs
           // a long shift, and a long AND, (the test for zero is prob a no-op)
-          // testing on a P4 indicates this is slower than (bits[i] & bitmask) != 0;
+          // testing on a P4 indicates this is slower than (bits[i] & bitMask) != 0;
         }
         */
 
@@ -319,8 +329,8 @@ namespace Lucene.Net.Util
         {
             int wordNum = ExpandingWordNum(index);
             int bit = (int)index & 0x3f;
-            long bitmask = 1L << bit;
-            bits[wordNum] |= bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] |= bitMask;
         }
 
         /// <summary>
@@ -332,8 +342,8 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = index >> 6; // div 64
             int bit = index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] |= bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] |= bitMask;
         }
 
         /// <summary>
@@ -345,8 +355,8 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = (int)(index >> 6);
             int bit = (int)index & 0x3f;
-            long bitmask = 1L << bit;
-            bits[wordNum] |= bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] |= bitMask;
         }
 
         /// <summary>
@@ -367,18 +377,18 @@ namespace Lucene.Net.Util
             // word to be changed.
             int endWord = ExpandingWordNum(endIndex - 1);
 
-            long startmask = -1L << (int)startIndex;
-            long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long startMask = -1L << (int)startIndex;
+            long endMask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
 
             if (startWord == endWord)
             {
-                bits[startWord] |= (startmask & endmask);
+                bits[startWord] |= (startMask & endMask);
                 return;
             }
 
-            bits[startWord] |= startmask;
+            bits[startWord] |= startMask;
             bits.Fill(startWord + 1, endWord, -1L);
-            bits[endWord] |= endmask;
+            bits[endWord] |= endMask;
         }
 
         protected internal virtual int ExpandingWordNum(long index)
@@ -400,8 +410,8 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = index >> 6;
             int bit = index & 0x03f;
-            long bitmask = 1L << bit;
-            bits[wordNum] &= ~bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] &= ~bitMask;
             // hmmm, it takes one more instruction to clear than it does to set... any
             // way to work around this?  If there were only 63 bits per word, we could
             // use a right shift of 10111111...111 in binary to position the 0 in the
@@ -420,8 +430,8 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = (int)(index >> 6); // div 64
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] &= ~bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] &= ~bitMask;
         }
 
         /// <summary>
@@ -434,8 +444,8 @@ namespace Lucene.Net.Util
                 return;
             }
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] &= ~bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] &= ~bitMask;
         }
 
         /// <summary>
@@ -461,26 +471,26 @@ namespace Lucene.Net.Util
             int endWord = ((endIndex - 1) >> 6);
 
             //LUCENE TO-DO
-            long startmask = -1L << startIndex;
-            long endmask = -(int)((uint)1L >> -endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long startMask = -1L << startIndex;
+            long endMask = -(int)((uint)1L >> -endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
 
             // invert masks since we are clearing
-            startmask = ~startmask;
-            endmask = ~endmask;
+            startMask = ~startMask;
+            endMask = ~endMask;
 
             if (startWord == endWord)
             {
-                bits[startWord] &= (startmask | endmask);
+                bits[startWord] &= (startMask | endMask);
                 return;
             }
 
-            bits[startWord] &= startmask;
+            bits[startWord] &= startMask;
 
             int middle = Math.Min(wordLength, endWord);
             bits.Fill(startWord + 1, middle, 0L);
             if (endWord < wordLength)
             {
-                bits[endWord] &= endmask;
+                bits[endWord] &= endMask;
             }
         }
 
@@ -507,26 +517,26 @@ namespace Lucene.Net.Util
             int endWord = (int)((endIndex - 1) >> 6);
 
             //LUCENE TO-DO
-            long startmask = -1L << (int)startIndex;
-            long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long startMask = -1L << (int)startIndex;
+            long endMask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
 
             // invert masks since we are clearing
-            startmask = ~startmask;
-            endmask = ~endmask;
+            startMask = ~startMask;
+            endMask = ~endMask;
 
             if (startWord == endWord)
             {
-                bits[startWord] &= (startmask | endmask);
+                bits[startWord] &= (startMask | endMask);
                 return;
             }
 
-            bits[startWord] &= startmask;
+            bits[startWord] &= startMask;
 
             int middle = Math.Min(wordLength, endWord);
             bits.Fill(startWord + 1, middle, 0L);
             if (endWord < wordLength)
             {
-                bits[endWord] &= endmask;
+                bits[endWord] &= endMask;
             }
         }
 
@@ -539,9 +549,9 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = index >> 6; // div 64
             int bit = index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bool val = (bits[wordNum] & bitmask) != 0;
-            bits[wordNum] |= bitmask;
+            long bitMask = 1L << bit;
+            bool val = (bits[wordNum] & bitMask) != 0;
+            bits[wordNum] |= bitMask;
             return val;
         }
 
@@ -554,9 +564,9 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = (int)(index >> 6); // div 64
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bool val = (bits[wordNum] & bitmask) != 0;
-            bits[wordNum] |= bitmask;
+            long bitMask = 1L << bit;
+            bool val = (bits[wordNum] & bitMask) != 0;
+            bits[wordNum] |= bitMask;
             return val;
         }
 
@@ -569,8 +579,8 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = index >> 6; // div 64
             int bit = index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] ^= bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] ^= bitMask;
         }
 
         /// <summary>
@@ -582,8 +592,8 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = (int)(index >> 6); // div 64
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] ^= bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] ^= bitMask;
         }
 
         /// <summary>
@@ -592,8 +602,8 @@ namespace Lucene.Net.Util
         {
             int wordNum = ExpandingWordNum(index);
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] ^= bitmask;
+            long bitMask = 1L << bit;
+            bits[wordNum] ^= bitMask;
         }
 
         /// <summary>
@@ -605,9 +615,9 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = index >> 6; // div 64
             int bit = index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] ^= bitmask;
-            return (bits[wordNum] & bitmask) != 0;
+            long bitMask = 1L << bit;
+            bits[wordNum] ^= bitMask;
+            return (bits[wordNum] & bitMask) != 0;
         }
 
         /// <summary>
@@ -619,9 +629,9 @@ namespace Lucene.Net.Util
             Debug.Assert(index >= 0 && index < numBits);
             int wordNum = (int)(index >> 6); // div 64
             int bit = (int)index & 0x3f; // mod 64
-            long bitmask = 1L << bit;
-            bits[wordNum] ^= bitmask;
-            return (bits[wordNum] & bitmask) != 0;
+            long bitMask = 1L << bit;
+            bits[wordNum] ^= bitMask;
+            return (bits[wordNum] & bitMask) != 0;
         }
 
         /// <summary>
@@ -650,23 +660,23 @@ namespace Lucene.Net.Util
            
 
             //LUCENE TO-DO
-            long startmask = -1L << (int)startIndex;
-            long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+            long startMask = -1L << (int)startIndex;
+            long endMask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
 
             if (startWord == endWord)
             {
-                bits[startWord] ^= (startmask & endmask);
+                bits[startWord] ^= (startMask & endMask);
                 return;
             }
 
-            bits[startWord] ^= startmask;
+            bits[startWord] ^= startMask;
 
             for (int i = startWord + 1; i < endWord; i++)
             {
                 bits[i] = ~bits[i];
             }
 
-            bits[endWord] ^= endmask;
+            bits[endWord] ^= endMask;
         }
 
         /*
@@ -922,7 +932,7 @@ namespace Lucene.Net.Util
         public object Clone(bool deepCopy = true)
         {
             if (!deepCopy) 
-                return new OpenBitSet((long[])this.bits.Copy(), this.wordLength);
+                return new OpenBitSet(this.bits.Copy(), this.wordLength);
             
             try
             {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Check.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Check.cs b/src/Lucene.Net.Java/Check.cs
new file mode 100644
index 0000000..4439dac
--- /dev/null
+++ b/src/Lucene.Net.Java/Check.cs
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+namespace Java
+{
+    using System;
+    using System.Collections.Generic;
+
+    internal class Check
+    {
+
+        internal static void NotNull<T>(string argument, T value, string message = null, params  object[] args) where T : class 
+        {
+            if (value == null)
+            {
+                if (message == null)
+                    message = string.Format("The parameter, {0}, must not be null.", argument);
+
+                if (args != null && args.Length > 0)
+                    message = string.Format(message, args);
+
+
+                throw new ArgumentNullException(argument, message);
+            }
+        }
+
+        internal static void Range<T>(string argument, IList<T> value, int start, int count)
+        {
+            if(start < 0)
+                throw new ArgumentOutOfRangeException("start", "The parameter, start, must be 0 or greater.");
+
+            if(start >= value.Count)
+                throw new ArgumentOutOfRangeException("start", string.Format("The parameter, start, must not be equal or greater than {0}'s length.", argument));
+
+            if (count < 0)
+                throw new ArgumentOutOfRangeException("count", "The parameter, count, must be 0 or greater.");
+            
+            if (count > value.Count)
+                throw new ArgumentOutOfRangeException("count", string.Format("The parameter, count, must not be greater than {0}'s length.", argument));
+
+            if(start + count > value.Count)
+                throw new ArgumentOutOfRangeException("value,count", string.Format("The sum of start and count must not be greater than {0}'s length", argument));
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lang/Int.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Lang/Int.cs b/src/Lucene.Net.Java/Lang/Int.cs
new file mode 100644
index 0000000..abf5248
--- /dev/null
+++ b/src/Lucene.Net.Java/Lang/Int.cs
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Java.Lang
+{
+    public class Int
+    {
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lang/Long.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Lang/Long.cs b/src/Lucene.Net.Java/Lang/Long.cs
new file mode 100644
index 0000000..c532c84
--- /dev/null
+++ b/src/Lucene.Net.Java/Lang/Long.cs
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Java.Lang
+{
+    using System;
+
+    public class Long
+    {
+        public const int SIZE = 64;
+
+        private static class DeBruijn64
+        {
+            private static readonly int[] POSITIONS =
+            {
+                0, 1, 2, 53, 3, 7, 54, 27, 4, 38, 41, 8, 34, 55, 48, 28,
+                62, 5, 39, 46, 44, 42, 22, 9, 24, 35, 59, 56, 49, 18, 29, 11,
+                63, 52, 6, 26, 37, 40, 33, 47, 61, 45, 43, 21, 23, 58, 17, 10,
+                51, 25, 36, 32, 60, 20, 57, 16, 50, 31, 19, 15, 30, 14, 13, 12
+            };
+
+            public static int Position(long value)
+            {
+                var v = value;
+
+                return POSITIONS[(v & -v) * 0x022fdd63cc95386d >> 58];
+            }
+        }
+
+
+      
+
+
+        /// <summary>
+        /// Returns the leading zeros from the value.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        /// <returns>System.Int32.</returns>
+        public static int NumberOfLeadingZeros(long value)
+        {
+            return (int)NumberOfLeadingZeros((ulong)value);
+        }
+
+        /// <summary>
+        /// Returns the leading zeros from the value.
+        /// </summary>
+        /// <param name="value">The value.</param>
+        /// <returns>System.UInt32.</returns>
+        [CLSCompliant(false)]
+        public static uint NumberOfLeadingZeros(ulong value)
+        {
+            if (value == 0)
+                return 64;
+            uint number = 1;
+            var test = value >> 32;
+
+
+            if (test == 0)
+            {
+                number += 32;
+                test = (uint)value;
+            }
+
+            if (test >> 16 == 0)
+            {
+                number += 16;
+                test <<= 16;
+            }
+
+            if (test >> 24 == 0)
+            {
+                number += 8;
+                test <<= 8;
+            }
+
+            if (test >> 28 == 0)
+            {
+                number += 4;
+                test <<= 4;
+            }
+
+            if (test >> 30 == 0)
+            {
+                number += 2;
+                test <<= 2;
+            }
+            number -= (uint)test >> 31;
+
+            return number;
+        }
+
+        // ReSharper disable once CSharpWarnings::CS1584
+        /// <summary>
+        /// Returns the number of trailing zeros. i.e 100 has two trailing zeros.
+        /// </summary>
+        /// <param name="value">The value to be inspected for trailing zeros.</param>
+        /// <remarks>
+        ///     <para>
+        ///         We're using the De Bruijn sequences based upon the various bit twiddling hacks found in 
+
+        ///         an online paper stanford <see href="https://graphics.stanford.edu/~seander/bithacks.html#ZerosOnRightMultLookup" />
+        ///     </para>
+        ///     <para>
+        ///          It should be faster than Java's native 
+        ///          <see href="http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7u40-b43/java/lang/Integer.java#Integer.numberOfTrailingZeros%28int%29">
+        ///          Long.numberOfTrailingZeros
+        ///          </see> which uses the binary search method of finding trailing zeros.  
+        ///     </para>
+        /// </remarks>
+        /// <returns>The number of trailing zeros.</returns>
+        public static int NumberOfTrailingZeros(long value)
+        {
+            return DeBruijn64.Position(value);
+        }
+
+        public static long RotateLeft(long value, int shift)
+        {
+            return (long)RotateLeft((ulong) value, shift);
+        }
+
+        [CLSCompliant(false)]
+        public static ulong RotateLeft(ulong value, int shift)
+        {
+            return (value << shift) | (value >> -shift);
+        }
+
+
+        public static long RotateRight(long value, int shift)
+        {
+            return (long)RotateRight((ulong) value, shift);
+        }
+
+        [CLSCompliant(false)]
+        public static ulong RotateRight(ulong value, int shift)
+        {
+            return (value >> shift) | (value << -shift);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lang/String.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Lang/String.cs b/src/Lucene.Net.Java/Lang/String.cs
new file mode 100644
index 0000000..c27d07a
--- /dev/null
+++ b/src/Lucene.Net.Java/Lang/String.cs
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Java.Lang
+{
+    using System;
+    using System.Collections.Generic;
+
+    public class String : IEnumerable<char>
+    {
+        private readonly char[] value;
+
+
+        public String()
+        {
+            this.value = new char[0];
+        }
+
+        public String(string value)
+        {
+            this.value = value.ToCharArray();
+        }
+
+        public String(char[] value)
+        {
+            this.value = value;
+        }
+
+        public static explicit operator String(string value)
+        {
+            return new String(value);
+        }
+
+        public static explicit operator String(char[] value)
+        {
+            return new String(value);
+        }
+
+
+        public int Length
+        {
+            get { return this.value.Length; }
+        }
+
+        IEnumerator<char> IEnumerable<char>.GetEnumerator()
+        {
+            return new CharEnumerator(this.value);
+        }
+
+        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+        {
+            return new CharEnumerator(this.value);
+        }
+
+
+        private class CharEnumerator : IEnumerator<char>
+        {
+            private char[] values;
+            private int position;
+
+            public CharEnumerator(char[] values)
+            {
+                this.values = values;
+                this.position = -1;
+            }
+
+            public char Current
+            {
+                get { return this.values[this.position]; }
+            }
+
+            object System.Collections.IEnumerator.Current
+            {
+                get { return this.Current; }
+            }
+
+            public bool MoveNext()
+            {
+                return this.position++ < this.values.Length;
+
+            }
+
+            public void Reset()
+            {
+                this.position = -1;
+            }
+
+            public void Dispose()
+            {
+                GC.SuppressFinalize(this);
+                this.Dispose(true);
+            }
+
+            private void Dispose(bool disposing)
+            {
+                if(!disposing)
+                    return;
+
+                this.values = null;
+            }
+
+            ~CharEnumerator()
+            {
+                this.Dispose(false);
+            }
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lucene.Net.Java.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Lucene.Net.Java.csproj b/src/Lucene.Net.Java/Lucene.Net.Java.csproj
new file mode 100644
index 0000000..2a13128
--- /dev/null
+++ b/src/Lucene.Net.Java/Lucene.Net.Java.csproj
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{4AD3FE35-AA0A-4C3C-A043-12711625DF74}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Java</RootNamespace>
+    <AssemblyName>Lucene.Net.Java</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- A reference to the entire .NET Framework is automatically included -->
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Check.cs" />
+    <Compile Include="Lang\Int.cs" />
+    <Compile Include="Lang\Long.cs" />
+    <Compile Include="Lang\String.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Util\Arrays.cs" />
+    <Compile Include="Util\DualPivotQuicksort.cs" />
+    <Compile Include="Util\InsertionSort.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="Readme.md" />
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Lucene.Net.Java.kproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Lucene.Net.Java.kproj b/src/Lucene.Net.Java/Lucene.Net.Java.kproj
new file mode 100644
index 0000000..af2ce9d
--- /dev/null
+++ b/src/Lucene.Net.Java/Lucene.Net.Java.kproj
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup>
+    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
+    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
+  </PropertyGroup>
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+  </PropertyGroup>
+  <Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.Props" Condition="'$(VSToolsPath)' != ''" />
+  <PropertyGroup Label="Globals">
+    <ProjectGuid>caf32bea-5560-4e4a-a81f-11aa377f9929</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <RootNamespace>Java</RootNamespace>
+  </PropertyGroup>
+  <PropertyGroup Condition="$(OutputType) == 'Console'">
+    <DebuggerFlavor>ConsoleDebugger</DebuggerFlavor>
+  </PropertyGroup>
+  <PropertyGroup Condition="$(OutputType) == 'Web'">
+    <DebuggerFlavor>WebDebugger</DebuggerFlavor>
+  </PropertyGroup>
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" Label="Configuration">
+  </PropertyGroup>
+  <PropertyGroup>
+    <SchemaVersion>2.0</SchemaVersion>
+  </PropertyGroup>
+  <ItemGroup>
+    <Content Include="default.ruleset" />
+    <Content Include="packages.config" />
+    <Content Include="project.json" />
+  </ItemGroup>
+  <ItemGroup>
+  </ItemGroup>
+  <Import Project="$(VSToolsPath)\AspNet\Microsoft.Web.AspNet.targets" Condition="'$(VSToolsPath)' != ''" />
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Properties/AssemblyInfo.cs b/src/Lucene.Net.Java/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..42c05a0
--- /dev/null
+++ b/src/Lucene.Net.Java/Properties/AssemblyInfo.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+#if PORTABLE
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: AssemblyTitle("Lucene.Net.Java")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Lucene.Net.Java")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+#endif
+
+[assembly: CLSCompliant(true)]
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Readme.md
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Readme.md b/src/Lucene.Net.Java/Readme.md
new file mode 100644
index 0000000..c24d559
--- /dev/null
+++ b/src/Lucene.Net.Java/Readme.md
@@ -0,0 +1,16 @@
+# Lucene.Net.Java
+
+This project is a spin off of the <strong>Support</strong> folder of Lucene.Net. There is enough low level functionality
+that the standard Java library has that is not found in .NET to warrant a separate assembly.   
+
+Creating a separate project will let the .NET community leverage the functionality 
+without a required dependency to all of Lucene.Net. There is most likely similar 
+functionality in IVKM.NET, however, it's JDK falls under GPL v2 which is not compatible with 
+the Apache 2.0 License.  
+
+The root namespace of the projeect is <strong>Java</strong> and not <strong>Lucene.Net.Java</strong>, so 
+that its easier to convert code with the namespaces. 
+
+There will still be differences between this library and the Java implementation. The goal is to match the Java API 
+when possible while still using the correct .NET idioms.  There are also differences in runtimes that will allow for 
+a simplified API with generics.  [Comparing Generics Java and C#](http://www.jprl.com/Blog/archive/development/2007/Aug-31.html)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Util/Arrays.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Util/Arrays.cs b/src/Lucene.Net.Java/Util/Arrays.cs
new file mode 100644
index 0000000..083f6f0
--- /dev/null
+++ b/src/Lucene.Net.Java/Util/Arrays.cs
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Java.Util
+{
+    using System;
+    using System.Collections.Generic;
+
+    public static class Arrays
+    {
+
+        public static void Fill<T>(IList<T> list, Func<T> factory)
+        {
+            Fill(list, 0, list.Count, factory);
+        }
+
+        public static void Fill<T>(IList<T> list, int start, int count, Func<T> factory)
+        {
+            for (var i = start; i < count; i++)
+                list[i] = factory();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs b/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs
new file mode 100644
index 0000000..d880c1a
--- /dev/null
+++ b/src/Lucene.Net.Java/Util/DualPivotQuicksort.cs
@@ -0,0 +1,1090 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Java.Util
+{
+    using System;
+    using System.Collections.Generic;
+
+    // ReSharper disable CSharpWarnings::CS1574
+    /// <summary>
+    /// A .NET implementation of Valdimir Yaroslavskiy's Dual-Pivot Quicksort
+    /// </summary>
+    /// <remarks>
+    ///     <para>
+    ///         The overloaded methods are to avoid the extra compare operations for 
+    ///         known value types: <see cref="short" />,<see cref="int" />, <see cref="long"/>
+    ///         <see cref="byte" />, and <see cref="char" />.  
+    ///         <see cref="DualPivotQuicksort.Sort(IComparable{T})"/> can be used for all other types
+    ///         that implement <see cref="IComparable{T}"/>.
+    ///     </para>
+    /// </remarks>
+    // ReSharper disable FunctionRecursiveOnAllPaths
+    public class DualPivotQuicksort
+    {
+        private const int DIST_SIZE = 13;
+
+
+
+        private static void Swap<T>(IList<T> array, int left, int right)
+        {
+            var reference = array[left];
+            array[left] = array[right];
+            array[right] = reference;
+        }
+
+        public static IList<int> Sort(IList<int> list)
+        {
+            Check.NotNull("list", list);
+
+            PerformSort(list, 0, list.Count);
+
+            return list;
+        }
+
+        public static IList<int> Sort(IList<int> list, int start, int count)
+        {
+            Check.NotNull("list", list);
+            Check.Range("list", list, start, count);
+
+            PerformSort(list, start, count);
+
+            return list;
+        }
+
+        private static void PerformSort(IList<int> array, int left, int right)
+        {
+            int length = right - left,
+                x,
+                pivot1,
+                pivot2;
+
+           
+
+            int sixth = length/6,
+                m1 = left + sixth,
+                m2 = m1 + sixth,
+                m3 = m2 + sixth,
+                m4 = m3 + sixth,
+                m5 = m4 + sixth;
+
+            if (array[m1] > array[m2])
+                Swap(array, m1, m2);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            if (array[m1] > array[m3])
+                Swap(array, m1, m3);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m1] > array[m4])
+                Swap(array, m2, m4);
+
+            if (array[m3] > array[m4])
+                Swap(array, m3, m4);
+
+            if (array[m2] > array[m5])
+                Swap(array, m2, m5);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            pivot1 = array[m2];
+            pivot2 = array[m4];
+
+            var pivotsAreDifferent = pivot1 != pivot2;
+
+            array[m2] = array[left];
+            array[m4] = array[right];
+
+            int less = left + 1,
+                great = right - 1;
+
+            if (pivotsAreDifferent)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+            else
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                        continue;
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            array[left] = array[less - 1];
+            array[left - 1] = pivot1;
+
+            array[right] = array[great + 1];
+            array[great + 1] = pivot2;
+
+            PerformSort(array, left, less - 2);
+            PerformSort(array, great + 1, right);
+
+            if (!pivotsAreDifferent)
+                return;
+
+
+            if (great - less > length - DIST_SIZE)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x == pivot2)
+                    {
+                        array[k] = array[great];
+                        array[great--] = x;
+                        x = array[k];
+
+
+                        if (x != pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            PerformSort(array, less, great);
+        }
+
+
+        public static IList<char> Sort(IList<char> list)
+        {
+            Check.NotNull("list", list);
+
+            PerformSort(list, 0, list.Count);
+
+            return list;
+        }
+
+        public static IList<char> Sort(IList<char> list, int start, int count)
+        {
+            Check.NotNull("list", list);
+            Check.Range("list", list, start, count);
+
+            PerformSort(list, start, count);
+
+            return list;
+        }
+
+        private static void PerformSort(IList<char> array, int left, int right)
+        {
+            int length = right - left;
+            char x,
+                pivot1,
+                pivot2;
+
+          
+
+            int sixth = length/6,
+                m1 = left + sixth,
+                m2 = m1 + sixth,
+                m3 = m2 + sixth,
+                m4 = m3 + sixth,
+                m5 = m4 + sixth;
+
+            if (array[m1] > array[m2])
+                Swap(array, m1, m2);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            if (array[m1] > array[m3])
+                Swap(array, m1, m3);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m1] > array[m4])
+                Swap(array, m2, m4);
+
+            if (array[m3] > array[m4])
+                Swap(array, m3, m4);
+
+            if (array[m2] > array[m5])
+                Swap(array, m2, m5);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            pivot1 = array[m2];
+            pivot2 = array[m4];
+
+            bool pivotsAreDifferent = pivot1 != pivot2;
+
+            array[m2] = array[left];
+            array[m4] = array[right];
+
+            int less = left + 1,
+                great = right - 1;
+
+            if (pivotsAreDifferent)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+            else
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                        continue;
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            array[left] = array[less - 1];
+            array[left - 1] = pivot1;
+
+            array[right] = array[great + 1];
+            array[great + 1] = pivot2;
+
+            PerformSort(array, left, less - 2);
+            PerformSort(array, great + 1, right);
+
+            if (!pivotsAreDifferent)
+                return;
+
+
+            if (great - less > length - DIST_SIZE)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x == pivot2)
+                    {
+                        array[k] = array[great];
+                        array[great--] = x;
+                        x = array[k];
+
+
+                        if (x != pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            PerformSort(array, less, great);
+        }
+
+        public static IList<short> Sort(IList<short> list)
+        {
+            Check.NotNull("list", list);
+            PerformSort(list, 0, list.Count);
+            return list;
+        }
+
+        public static IList<short> Sort(IList<short> list, int start, int count)
+        {
+            Check.NotNull("list", list);
+            Check.Range("list", list, start, count);
+            PerformSort(list, start, count);
+            return list;
+        }
+
+        private static void PerformSort(IList<short> array, int left, int right)
+        {
+            var length = right - left;
+            short x,
+                pivot1,
+                pivot2;
+
+           
+
+            int sixth = length/6,
+                m1 = left + sixth,
+                m2 = m1 + sixth,
+                m3 = m2 + sixth,
+                m4 = m3 + sixth,
+                m5 = m4 + sixth;
+
+            if (array[m1] > array[m2])
+                Swap(array, m1, m2);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            if (array[m1] > array[m3])
+                Swap(array, m1, m3);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m1] > array[m4])
+                Swap(array, m2, m4);
+
+            if (array[m3] > array[m4])
+                Swap(array, m3, m4);
+
+            if (array[m2] > array[m5])
+                Swap(array, m2, m5);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            pivot1 = array[m2];
+            pivot2 = array[m4];
+
+            bool pivotsAreDifferent = pivot1 != pivot2;
+
+            array[m2] = array[left];
+            array[m4] = array[right];
+
+            int less = left + 1,
+                great = right - 1;
+
+            if (pivotsAreDifferent)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+            else
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                        continue;
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            array[left] = array[less - 1];
+            array[left - 1] = pivot1;
+
+            array[right] = array[great + 1];
+            array[great + 1] = pivot2;
+
+            PerformSort(array, left, less - 2);
+            PerformSort(array, great + 1, right);
+
+            if (!pivotsAreDifferent)
+                return;
+
+
+            if (great - less > length - DIST_SIZE)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x == pivot2)
+                    {
+                        array[k] = array[great];
+                        array[great--] = x;
+                        x = array[k];
+
+
+                        if (x != pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            PerformSort(array, less, great);
+        }
+
+
+        public static IList<byte> Sort(IList<byte> list, int start, int count)
+        {
+            Check.NotNull("list", list);
+            Check.Range("list", list, start, count);
+
+            PerformSort(list, start, count);
+
+            return list;
+        }
+
+        internal static void PerformSort(IList<byte> array, int left, int right)
+        {
+            int length = right - left;
+            byte x,
+                pivot1,
+                pivot2;
+
+            
+
+            int sixth = length/6,
+                m1 = left + sixth,
+                m2 = m1 + sixth,
+                m3 = m2 + sixth,
+                m4 = m3 + sixth,
+                m5 = m4 + sixth;
+
+            if (array[m1] > array[m2])
+                Swap(array, m1, m2);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            if (array[m1] > array[m3])
+                Swap(array, m1, m3);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m1] > array[m4])
+                Swap(array, m2, m4);
+
+            if (array[m3] > array[m4])
+                Swap(array, m3, m4);
+
+            if (array[m2] > array[m5])
+                Swap(array, m2, m5);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            pivot1 = array[m2];
+            pivot2 = array[m4];
+
+            bool pivotsAreDifferent = pivot1 != pivot2;
+
+            array[m2] = array[left];
+            array[m4] = array[right];
+
+            int less = left + 1,
+                great = right - 1;
+
+            if (pivotsAreDifferent)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+            else
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                        continue;
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            array[left] = array[less - 1];
+            array[left - 1] = pivot1;
+
+            array[right] = array[great + 1];
+            array[great + 1] = pivot2;
+
+            PerformSort(array, left, less - 2);
+            PerformSort(array, great + 1, right);
+
+            if (!pivotsAreDifferent)
+                return;
+
+
+            if (great - less > length - DIST_SIZE)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x == pivot2)
+                    {
+                        array[k] = array[great];
+                        array[great--] = x;
+                        x = array[k];
+
+
+                        if (x != pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            PerformSort(array, less, great);
+        }
+
+        public static long[] Sort(long[] array)
+        {
+            Check.NotNull("array", array);
+            PerformSort(array, 0, array.Length);
+            return array;
+        }
+
+        public static long[] Sort(long[] array, int start, int count)
+        {
+            Check.NotNull("array", array);
+            Check.Range("array", array, start, count);
+            PerformSort(array, start, count);
+            return array;
+        }
+
+
+        internal static void PerformSort(long[] array, int left, int right)
+        {
+            int length = right - left;
+            long x,
+                pivot1,
+                pivot2;
+
+           
+
+            int sixth = length/6,
+                m1 = left + sixth,
+                m2 = m1 + sixth,
+                m3 = m2 + sixth,
+                m4 = m3 + sixth,
+                m5 = m4 + sixth;
+
+            if (array[m1] > array[m2])
+                Swap(array, m1, m2);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            if (array[m1] > array[m3])
+                Swap(array, m1, m3);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m1] > array[m4])
+                Swap(array, m2, m4);
+
+            if (array[m3] > array[m4])
+                Swap(array, m3, m4);
+
+            if (array[m2] > array[m5])
+                Swap(array, m2, m5);
+
+            if (array[m2] > array[m3])
+                Swap(array, m2, m3);
+
+            if (array[m4] > array[m5])
+                Swap(array, m4, m5);
+
+            pivot1 = array[m2];
+            pivot2 = array[m4];
+
+            bool pivotsAreDifferent = pivot1 != pivot2;
+
+            array[m2] = array[left];
+            array[m4] = array[right];
+
+            int less = left + 1,
+                great = right - 1;
+
+            if (pivotsAreDifferent)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+            else
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                        continue;
+
+                    if (x < pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x > pivot2)
+                    {
+                        while (array[great] > pivot2 && k < great)
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (x >= pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            array[left] = array[less - 1];
+            array[left - 1] = pivot1;
+
+            array[right] = array[great + 1];
+            array[great + 1] = pivot2;
+
+            PerformSort(array, left, less - 2);
+            PerformSort(array, great + 1, right);
+
+            if (!pivotsAreDifferent)
+                return;
+
+
+            if (great - less > length - DIST_SIZE)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x == pivot1)
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x == pivot2)
+                    {
+                        array[k] = array[great];
+                        array[great--] = x;
+                        x = array[k];
+
+
+                        if (x != pivot1)
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            PerformSort(array, less, great);
+        }
+
+        private static bool LessThan<T>(T left, T right) where T : IComparable<T>
+        {
+            return left.CompareTo(right) < 0;
+        }
+
+        private static bool GreaterThan<T>(T left, T right) where T : IComparable<T>
+        {
+            return left.CompareTo(right) > 0;
+        }
+
+        private static bool GreaterThanOrEqualTo<T>(T left, T right) where T : IComparable<T>
+        {
+            var compare = left.CompareTo(right);
+            return compare > 0 || compare == 0;
+        }
+
+        public static IList<T> Sort<T>(IList<T> list) where T: IComparable<T>
+        {
+            Check.NotNull("array", list);
+            PerformSort(list, 0, list.Count);
+
+            return list;
+        }
+
+        public static IList<T> Sort<T>(IList<T> list, int start, int count)  where T: IComparable<T> 
+        {
+            Check.NotNull("array", list);
+            Check.Range("array", list, start, count);
+            PerformSort(list, start, count);
+
+            return list;
+        }
+
+
+        internal static void PerformSort<T>(IList<T> array, int left, int right) where T: IComparable<T> 
+        {
+            int length = right - left;
+            T x, pivot2, pivot1;
+
+            
+
+            int sixth = length / 6,
+                m1 = left + sixth,
+                m2 = m1 + sixth,
+                m3 = m2 + sixth,
+                m4 = m3 + sixth,
+                m5 = m4 + sixth;
+
+            if (GreaterThan(array[m1] , array[m2]))
+                Swap(array, m1, m2);
+
+            if (GreaterThan(array[m4] , array[m5]))
+                Swap(array, m4, m5);
+
+            if (GreaterThan(array[m1] , array[m3]))
+                Swap(array, m1, m3);
+
+            if (GreaterThan(array[m2], array[m3]))
+                Swap(array, m2, m3);
+
+            if (GreaterThan(array[m1], array[m4]))
+                Swap(array, m2, m4);
+
+            if (GreaterThan(array[m3], array[m4]))
+                Swap(array, m3, m4);
+
+            if (GreaterThan(array[m2], array[m5]))
+                Swap(array, m2, m5);
+
+            if (GreaterThan(array[m2],array[m3]))
+                Swap(array, m2, m3);
+
+            if (GreaterThan(array[m4], array[m5]))
+                Swap(array, m4, m5);
+
+            pivot1 = array[m2];
+            pivot2 = array[m4];
+
+            bool pivotsAreDifferent = !pivot1.Equals(pivot2);
+
+            array[m2] = array[left];
+            array[m4] = array[right];
+
+            int less = left + 1,
+                great = right - 1;
+
+            if (pivotsAreDifferent)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (LessThan(x , pivot1))
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (GreaterThan(x , pivot2))
+                    {
+                        while (GreaterThan(array[great] , pivot2) && LessThan(k , great))
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (GreaterThanOrEqualTo(x , pivot1))
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+            else
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (LessThan(x, pivot1))
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (GreaterThan(x, pivot2))
+                    {
+                        while (GreaterThan(array[great], pivot2) && LessThan(k, great))
+                        {
+                            great--;
+                        }
+                        Swap(array, k, great--);
+
+                        if (GreaterThanOrEqualTo(x, pivot1))
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            array[left] = array[less - 1];
+            array[left - 1] = pivot1;
+
+            array[right] = array[great + 1];
+            array[great + 1] = pivot2;
+
+            PerformSort(array, left, less - 2);
+            PerformSort(array, great + 1, right);
+
+            if (!pivotsAreDifferent)
+                return;
+
+
+            if (great - less > length - DIST_SIZE)
+            {
+                for (var k = less; k <= great; k++)
+                {
+                    x = array[k];
+
+                    if (x.Equals(pivot1))
+                    {
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                    else if (x.Equals(pivot2))
+                    {
+                        array[k] = array[great];
+                        array[great--] = x;
+                        x = array[k];
+
+
+                        if (! x.Equals(pivot1))
+                            continue;
+
+                        array[k] = array[less];
+                        array[less++] = x;
+                    }
+                }
+            }
+
+            PerformSort(array, less, great);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/Util/InsertionSort.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/Util/InsertionSort.cs b/src/Lucene.Net.Java/Util/InsertionSort.cs
new file mode 100644
index 0000000..5e27c58
--- /dev/null
+++ b/src/Lucene.Net.Java/Util/InsertionSort.cs
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Java.Util
+{
+    using System;
+    using System.Collections.Generic;
+
+    public static class InsertionSort
+    {
+
+      
+
+        private static void Swap<T>(IList<T> list,int left , int right )
+        {
+            var reference = list[left];
+            list[left] = list[right];
+            list[right] = reference;
+        }
+
+
+
+
+        public static IList<T> Sort<T>(IList<T> list) where T : IComparable<T>
+        {
+            Check.NotNull("list", list);
+
+            return PerformSort(list, 0, list.Count);
+        }
+
+        public static IList<T> Sort<T>(IList<T> list, int start, int count)where T: IComparable<T>
+        {
+            Check.NotNull("list", list);
+            Check.Range("list", list, start, count);
+
+            return PerformSort(list, start, count);
+        }
+
+        internal static IList<T> PerformSort<T>(IList<T> list, int start, int count) where T: IComparable<T>
+        {
+            for (var i = start + 1; i < count; i++)
+            {
+               
+                for (var j = i; j > start && list[j - 1].CompareTo(list[j]) >= 0; j--)
+                {
+                    // swap
+                    Swap(list, j - 1, j);
+                }
+            }
+
+            return list;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/default.ruleset
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/default.ruleset b/src/Lucene.Net.Java/default.ruleset
new file mode 100644
index 0000000..7770345
--- /dev/null
+++ b/src/Lucene.Net.Java/default.ruleset
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<RuleSet Name="Copy of Microsoft Managed Recommended Rules" Description="These rules focus on the most critical problems in your code, including potential security holes, application crashes, and other important logic and design errors. You should include this rule set in any custom rule set you create for your projects." ToolsVersion="14.0">
+  <Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
+    <Rule Id="CA1001" Action="Warning" />
+    <Rule Id="CA1009" Action="Warning" />
+    <Rule Id="CA1016" Action="Warning" />
+    <Rule Id="CA1033" Action="Warning" />
+    <Rule Id="CA1049" Action="Warning" />
+    <Rule Id="CA1060" Action="Warning" />
+    <Rule Id="CA1061" Action="Warning" />
+    <Rule Id="CA1063" Action="Warning" />
+    <Rule Id="CA1065" Action="Warning" />
+    <Rule Id="CA1301" Action="Warning" />
+    <Rule Id="CA1400" Action="Warning" />
+    <Rule Id="CA1401" Action="Warning" />
+    <Rule Id="CA1403" Action="Warning" />
+    <Rule Id="CA1404" Action="Warning" />
+    <Rule Id="CA1405" Action="Warning" />
+    <Rule Id="CA1410" Action="Warning" />
+    <Rule Id="CA1415" Action="Warning" />
+    <Rule Id="CA1821" Action="Warning" />
+    <Rule Id="CA1900" Action="Warning" />
+    <Rule Id="CA1901" Action="Warning" />
+    <Rule Id="CA2002" Action="Warning" />
+    <Rule Id="CA2100" Action="Warning" />
+    <Rule Id="CA2101" Action="Warning" />
+    <Rule Id="CA2108" Action="Warning" />
+    <Rule Id="CA2111" Action="Warning" />
+    <Rule Id="CA2112" Action="Warning" />
+    <Rule Id="CA2114" Action="Warning" />
+    <Rule Id="CA2116" Action="Warning" />
+    <Rule Id="CA2117" Action="Warning" />
+    <Rule Id="CA2122" Action="Warning" />
+    <Rule Id="CA2123" Action="Warning" />
+    <Rule Id="CA2124" Action="Warning" />
+    <Rule Id="CA2126" Action="Warning" />
+    <Rule Id="CA2131" Action="Warning" />
+    <Rule Id="CA2132" Action="Warning" />
+    <Rule Id="CA2133" Action="Warning" />
+    <Rule Id="CA2134" Action="Warning" />
+    <Rule Id="CA2137" Action="Warning" />
+    <Rule Id="CA2138" Action="Warning" />
+    <Rule Id="CA2140" Action="Warning" />
+    <Rule Id="CA2141" Action="Warning" />
+    <Rule Id="CA2146" Action="Warning" />
+    <Rule Id="CA2147" Action="Warning" />
+    <Rule Id="CA2149" Action="Warning" />
+    <Rule Id="CA2200" Action="Warning" />
+    <Rule Id="CA2202" Action="Warning" />
+    <Rule Id="CA2207" Action="Warning" />
+    <Rule Id="CA2212" Action="Warning" />
+    <Rule Id="CA2213" Action="Warning" />
+    <Rule Id="CA2214" Action="Warning" />
+    <Rule Id="CA2216" Action="Warning" />
+    <Rule Id="CA2220" Action="Warning" />
+    <Rule Id="CA2229" Action="Warning" />
+    <Rule Id="CA2231" Action="Warning" />
+    <Rule Id="CA2232" Action="Warning" />
+    <Rule Id="CA2235" Action="Warning" />
+    <Rule Id="CA2236" Action="Warning" />
+    <Rule Id="CA2237" Action="Warning" />
+    <Rule Id="CA2238" Action="Warning" />
+    <Rule Id="CA2240" Action="Warning" />
+    <Rule Id="CA2241" Action="Warning" />
+    <Rule Id="CA2242" Action="Warning" />
+  </Rules>
+</RuleSet>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/packages.config
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/packages.config b/src/Lucene.Net.Java/packages.config
new file mode 100644
index 0000000..786c80f
--- /dev/null
+++ b/src/Lucene.Net.Java/packages.config
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Microsoft.Framework.ConfigurationModel" version="1.0.0-alpha4-10193" targetFramework="portable-net451+win81+wpa81" requireReinstallation="True" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/src/Lucene.Net.Java/project.json
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Java/project.json b/src/Lucene.Net.Java/project.json
new file mode 100644
index 0000000..5a7cce8
--- /dev/null
+++ b/src/Lucene.Net.Java/project.json
@@ -0,0 +1,20 @@
+{
+    "licenses": [ "apache 2.0" ],
+    "version": "5.0.0.0",
+    "configurations" : {
+        "net451" : { 
+            "dependencies": {
+            }
+        },
+        "k10" : { 
+            "dependencies": {
+                "System.Linq": "",
+                "System.Reflection": "",
+                "System.Runtime": "",
+                "System.Reflection.Extensions": "",
+                "System.Text.RegularExpressions": "",
+                "System.Diagnostics.Debug": ""
+            }
+        }
+    }
+}


[2/7] lucenenet git commit: adding OpenBitSet, OpenBitSetIterator, DocIdSet, and DocIdSetIterator.

Posted by mh...@apache.org.
adding OpenBitSet, OpenBitSetIterator, DocIdSet, and DocIdSetIterator.


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

Branch: refs/heads/pcl
Commit: d3242166aa1e669a3ebf41ca0a4708ee91970836
Parents: 8e7e104
Author: Michael Herndon <mh...@michaelherndon.com>
Authored: Wed Aug 20 23:10:46 2014 -0400
Committer: Michael Herndon <mh...@michaelherndon.com>
Committed: Wed Aug 20 23:10:46 2014 -0400

----------------------------------------------------------------------
 src/Lucene.Net.Core/Lucene.Net.Core.csproj      |    4 +
 src/Lucene.Net.Core/Search/DocIdSet.cs          |   97 ++
 src/Lucene.Net.Core/Search/DocIdSetIterator.cs  |  285 +++++
 .../Support/ArrayExtensionMethods.cs            |   12 +
 src/Lucene.Net.Core/Util/BytesRefBuilder.cs     |    2 +-
 src/Lucene.Net.Core/Util/OpenBitSet.cs          | 1158 ++++++++++++++++++
 src/Lucene.Net.Core/Util/OpenBitSetIterator.cs  |  184 +++
 7 files changed, 1741 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d3242166/src/Lucene.Net.Core/Lucene.Net.Core.csproj
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Lucene.Net.Core.csproj b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
index 5ad93e0..26f3b3b 100644
--- a/src/Lucene.Net.Core/Lucene.Net.Core.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
@@ -56,6 +56,8 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
+    <Compile Include="Search\DocIdSet.cs" />
+    <Compile Include="Search\DocIdSetIterator.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Check.cs" />
     <Compile Include="Support\ArrayExtensionMethods.cs" />
@@ -89,6 +91,8 @@
     <Compile Include="Util\InPlaceMergeSorter.cs" />
     <Compile Include="Util\IntroSorter.cs" />
     <Compile Include="Util\IPurgeStrategy.cs" />
+    <Compile Include="Util\OpenBitSet.cs" />
+    <Compile Include="Util\OpenBitSetIterator.cs" />
     <Compile Include="Util\PclPurgeStrategy.cs" />
     <Compile Include="Util\RamUsageEstimator.cs" />
     <Compile Include="Util\SetOnce.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d3242166/src/Lucene.Net.Core/Search/DocIdSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/DocIdSet.cs b/src/Lucene.Net.Core/Search/DocIdSet.cs
new file mode 100644
index 0000000..ecee793
--- /dev/null
+++ b/src/Lucene.Net.Core/Search/DocIdSet.cs
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Search
+{
+    using System.Collections;
+    using System.Collections.Generic;
+    using IBits = Lucene.Net.Util.IBits;
+
+
+    // ReSharper disable CSharpWarnings::CS1584
+    // ReSharper disable CSharpWarnings::CS1574
+    /// <summary>
+    /// A DocIdSet contains a set of doc ids. Implementing classes must
+    /// only implement <seealso cref="IEnumerator"/> to provide access to the set.
+    /// </summary>
+
+    public abstract class DocIdSet : IEnumerable<int>
+    {
+        /// <summary>
+        /// Provides a <seealso cref="DocIdSetIterator"/> to access the set.
+        /// this implementation can return <code>null</code> if there
+        /// are no docs that match.
+        /// </summary>
+        public abstract DocIdSetIterator GetIterator();
+
+        // TODO: somehow this class should express the cost of
+        // iteration vs the cost of random access Bits; for
+        // expensive Filters (e.g. distance < 1 km) we should use
+        // bits() after all other Query/Filters have matched, but
+        // this is the opposite of what bits() is for now
+        // (down-low filtering using e.g. FixedBitSet)
+
+        /// <summary>
+        /// Optionally provides a <seealso cref="GetBits"/> interface for random access
+        /// to matching documents. </summary>
+        /// <remarks>
+        /// 
+        /// {@code null}, if this {@code DocIdSet} does not support random access.
+
+        /// In contrast to <seealso cref="IEnumerator()"/>, a return value of {@code null}
+        /// <b>does not</b> imply that no documents match the filter!
+        /// The default implementation does not provide random access, so you
+        /// only need to implement this method if your DocIdSet can
+        /// guarantee random access to every docid in O(1) time without
+        /// external disk access (as <seealso cref="GetBits"/> interface cannot throw
+        /// <seealso cref="IO.Exception"/>). this is generally true for bit sets
+        /// like <seealso cref="Lucene.Net.Util.FixedBitSet"/>, which return
+        /// itself if they are used as {@code DocIdSet}.
+        /// </remarks>
+        /// <returns>  </returns>
+        public virtual IBits GetBits()
+        {
+            return null;
+        }
+
+        /// <summary>
+
+        /// this method is a hint for <seealso cref="CachingWrapperFilter"/>, if this <code>DocIdSet</code>
+        /// should be cached without copying it. The default is to return
+        /// <code>false</code>. If you have an own <code>DocIdSet</code> implementation
+        /// that does its iteration very effective and fast without doing disk I/O,
+        /// override this method and return <code>true</code>.
+        /// </summary>
+        public virtual bool Cacheable
+        {
+            get
+            {
+                return false;
+            }
+        }
+
+        IEnumerator<int> IEnumerable<int>.GetEnumerator()
+        {
+            return this.GetIterator();
+        }
+
+        IEnumerator IEnumerable.GetEnumerator()
+        {
+            return this.GetIterator();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d3242166/src/Lucene.Net.Core/Search/DocIdSetIterator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Search/DocIdSetIterator.cs b/src/Lucene.Net.Core/Search/DocIdSetIterator.cs
new file mode 100644
index 0000000..85a7aa7
--- /dev/null
+++ b/src/Lucene.Net.Core/Search/DocIdSetIterator.cs
@@ -0,0 +1,285 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+namespace Lucene.Net.Search
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+
+
+    // ReSharper disable CSharpWarnings::CS1574
+    /// <summary>
+    /// The abstract class defines methods to iterate over a set of non-decreasing
+    /// doc ids. Note that this class assumes it iterates on doc Ids, and therefore
+    /// <seealso cref="NO_MORE_DOCS"/> is set to <see cref="NO_MORE_DOCS"/> in order to be used as
+    /// a sentinel object. Implementations of this class are expected to consider
+
+    /// <seealso cref="System.Int32.MAX_VALUE"/> as an invalid value.
+    /// </summary>
+    public abstract class DocIdSetIterator : IEnumerator<int>
+    {
+        /// <summary>
+        /// An empty <see cref="DocIdSetIterator"/> instance. 
+        /// </summary>
+        public static DocIdSetIterator Empty()
+        {
+            return new EmptyDocIdSetIterator();
+        }
+
+        /// <summary>
+        /// Class EmptyDocIdSetIterator.
+        /// </summary>
+        private class EmptyDocIdSetIterator : DocIdSetIterator
+        {
+            private bool exhausted;
+
+            /// <summary>
+            /// Advances to the first beyond the current whose document number is greater
+            /// than or equal to <i>target</i>, and returns the document number itself.
+            /// Exhausts the iterator and returns <seealso cref="DocIdSetIterator.NO_MORE_DOCS" /> if <i>target</i>
+            /// is greater than the highest document number in the set.
+            /// </summary>
+            /// <param name="target">The target.</param>
+            /// <returns>System.Int32.</returns>
+            /// <remarks><para>
+            /// The behavior of this method is <b>undefined</b> when called with
+            /// <c> target &lt; current</c>, or after the iterator has exhausted.
+            /// Both cases may result in unpredicted behavior.
+            /// </para>
+            /// <para>
+            /// When <code> target &gt; current</code> it behaves as if written:
+            /// </para>
+            /// <example>
+            ///   <code language="c#">
+            /// int advance(int target) {
+            /// int doc;
+            /// while ((doc = nextDoc()) &lt; target) {
+            /// }
+            /// return doc;
+            /// }
+            /// </code>
+            ///   <para>
+            /// Some implementations are considerably more efficient than that.
+            /// </para>
+            /// </example>
+            /// <para>
+            ///   <b>NOTE:</b> this method may be called with <seealso cref="DocIdSetIterator.NO_MORE_DOCS" /> for
+            /// efficiency by some Scorers. If your implementation cannot efficiently
+            /// determine that it should exhaust, it is recommended that you check for that
+            /// value in each call to this method.
+            /// </para></remarks>
+            public override int Advance(int target)
+            {
+                Debug.Assert(!exhausted);
+                Debug.Assert(target >= 0);
+                exhausted = true;
+                return NO_MORE_DOCS;
+            }
+
+            /// <summary>
+            /// Returns the following document id. It will return -1 if <see cref="NextDoc()" />
+            /// has not been called or <see cref="DocIdSetIterator.NO_MORE_DOCS" /> if the iterator has been
+            /// exhausted.
+            /// </summary>
+            /// <value>The document identifier.</value>
+            /// <remarks>@since 2.9</remarks>
+            public override int DocId
+            {
+                get { return exhausted ? NO_MORE_DOCS : -1; }
+                
+            }
+
+            /// <summary>
+            /// Advances to the next document in the set and returns the doc it is
+            /// currently on, or <seealso cref="DocIdSetIterator.NO_MORE_DOCS" /> if there are no more docs in the
+            /// set.
+            /// </summary>
+            /// <returns>System.Int32.</returns>
+            /// <remarks><para>
+            ///   <b>NOTE:</b> after the iterator has exhausted you should not call this
+            /// method, as it may result in unpredicted behavior.
+            /// </para>
+            /// @since 2.9</remarks>
+            public override int NextDoc()
+            {
+                Debug.Assert(!exhausted);
+                exhausted = true;
+                return NO_MORE_DOCS;
+            }
+
+            /// <summary>
+            /// Returns the estimated cost of this <seealso cref="DocIdSetIterator" />.
+            /// </summary>
+            /// <returns>System.Int64.</returns>
+            /// <remarks>this is generally an upper bound of the number of documents this iterator
+            /// might match, but may be a rough heuristic, hardcoded value, or otherwise
+            /// completely inaccurate.</remarks>
+            public override long Cost()
+            {
+                return 0;
+            }
+        }
+
+        /// <summary>
+        /// When returned by <seealso cref="NextDoc" />, <seealso cref="Advance(int)" /> and
+        /// <seealso cref="DocId" /> it means there are no more docs in the iterator.
+        /// </summary>
+        public const int NO_MORE_DOCS = int.MaxValue;
+
+        /// <summary>
+        /// Returns the following document id. It will return -1 if <see cref="NextDoc()" />
+        /// has not been called or <see cref="NO_MORE_DOCS" /> if the iterator has been
+        /// exhausted.
+        /// </summary>
+        /// <value>The document identifier.</value>
+        /// <remarks>@since 2.9</remarks>
+        public abstract int DocId { get; }
+
+        /// <summary>
+        /// Advances to the next document in the set and returns the doc it is
+        /// currently on, or <seealso cref="NO_MORE_DOCS" /> if there are no more docs in the
+        /// set.
+        /// </summary>
+        /// <returns>System.Int32.</returns>
+        /// <remarks><para>
+        ///   <b>NOTE:</b> after the iterator has exhausted you should not call this
+        /// method, as it may result in unpredicted behavior.
+        /// </para>
+        /// @since 2.9</remarks>
+        public abstract int NextDoc();
+
+        /// <summary>
+        /// Advances to the first beyond the current whose document number is greater
+        /// than or equal to <i>target</i>, and returns the document number itself.
+        /// Exhausts the iterator and returns <seealso cref="NO_MORE_DOCS" /> if <i>target</i>
+        /// is greater than the highest document number in the set.
+        /// </summary>
+        /// <param name="target">The target.</param>
+        /// <returns>System.Int32.</returns>
+        /// <remarks><para>
+        /// The behavior of this method is <b>undefined</b> when called with
+        /// <c> target &lt; current</c>, or after the iterator has exhausted.
+        /// Both cases may result in unpredicted behavior.
+        /// </para>
+        /// <para>
+        /// When <code> target &gt; current</code> it behaves as if written:
+        /// </para>
+        /// <example>
+        ///   <code language="c#">
+        /// int advance(int target) {
+        /// int doc;
+        /// while ((doc = nextDoc()) &lt; target) {
+        /// }
+        /// return doc;
+        /// }
+        /// </code>
+        ///   <para>
+        /// Some implementations are considerably more efficient than that.
+        /// </para>
+        /// </example>
+        /// <para>
+        ///   <b>NOTE:</b> this method may be called with <seealso cref="NO_MORE_DOCS" /> for
+        /// efficiency by some Scorers. If your implementation cannot efficiently
+        /// determine that it should exhaust, it is recommended that you check for that
+        /// value in each call to this method.
+        /// </para></remarks>
+        public abstract int Advance(int target);
+
+        /// <summary>
+        /// Slow (linear) implementation of <seealso cref="Advance(int)" /> relying on
+        /// <seealso cref="NextDoc()" /> to advance beyond the target position.
+        /// </summary>
+        /// <param name="target">The target.</param>
+        /// <returns>System.Int32.</returns>
+        protected internal int SlowAdvance(int target)
+        {
+            Debug.Assert(DocId == NO_MORE_DOCS || DocId < target); // can happen when the enum is not positioned yet
+            int doc;
+            do
+            {
+                doc = NextDoc();
+            } while (doc < target);
+            return doc;
+        }
+
+        /// <summary>
+        /// Returns the estimated cost of this <seealso cref="DocIdSetIterator"/>.
+        /// </summary>
+        /// <remarks>
+        ///     <para>
+        ///         this is generally an upper bound of the number of documents this iterator
+        ///         might match, but may be a rough heuristic, hardcoded value, or otherwise
+        ///         completely inaccurate.
+        ///     </para>
+        /// </remarks>
+        public abstract long Cost();
+
+        int IEnumerator<int>.Current
+        {
+            get { return this.DocId; }
+        }
+
+        object IEnumerator.Current
+        {
+            get { return this.DocId; }
+        }
+
+        bool IEnumerator.MoveNext()
+        {
+            return this.NextDoc() != NO_MORE_DOCS;
+        }
+
+        void IEnumerator.Reset()
+        {
+            this.Reset();
+        }
+
+        void IDisposable.Dispose()
+        {
+           GC.SuppressFinalize(this);
+           this.Dispose(true);
+        }
+
+        /// <summary>
+        /// Sets the enumerator to its initial position, which is before the first element in the collection.
+        /// </summary>
+        protected virtual void Reset()
+        {
+            
+        }
+
+        /// <summary>
+        /// Releases unmanaged and - optionally - managed resources.
+        /// </summary>
+        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
+        protected virtual void Dispose(bool disposing)
+        {
+            
+        }
+
+        /// <summary>
+        /// Finalizes an instance of the <see cref="DocIdSetIterator"/> class.
+        /// </summary>
+        ~DocIdSetIterator()
+        {
+            this.Dispose(false);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d3242166/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs b/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs
index d7cc737..a3db1d4 100644
--- a/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs
+++ b/src/Lucene.Net.Core/Support/ArrayExtensionMethods.cs
@@ -7,6 +7,18 @@ namespace Lucene.Net.Support
 
     public static class ArrayExtensionMethods
     {
+        public static T[] Fill<T>(this T[] array, int start, int count, T value)
+        {
+            Check.NotNull("array", array);
+            Check.InRangeOfLength(start, count, array.Length);
+      
+            for (var i = start; i < count; i++)
+            {
+                array[i] = value;
+            }
+
+            return array;
+        }
 
         public static T[] Copy<T>(this T[] array, int length = -1)
         {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d3242166/src/Lucene.Net.Core/Util/BytesRefBuilder.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BytesRefBuilder.cs b/src/Lucene.Net.Core/Util/BytesRefBuilder.cs
index 23ca12c..5da428e 100644
--- a/src/Lucene.Net.Core/Util/BytesRefBuilder.cs
+++ b/src/Lucene.Net.Core/Util/BytesRefBuilder.cs
@@ -231,7 +231,7 @@ namespace Lucene.Net.Util
             throw new NotSupportedException();
         }
 
-          /// <inherits />
+        /// <inherits />
         /// <exception cref="NotSupportedException">Throws when called.</exception>
         [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations", Justification = "Java Port Consistency")]
         public override int GetHashCode()

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d3242166/src/Lucene.Net.Core/Util/OpenBitSet.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/OpenBitSet.cs b/src/Lucene.Net.Core/Util/OpenBitSet.cs
new file mode 100644
index 0000000..7a176e3
--- /dev/null
+++ b/src/Lucene.Net.Core/Util/OpenBitSet.cs
@@ -0,0 +1,1158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Util
+{
+    using System;
+    using System.Diagnostics;
+    using Lucene.Net.Support;
+    using DocIdSet = Lucene.Net.Search.DocIdSet;
+    using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
+
+    // ReSharper disable CSharpWarnings::CS1574
+    /// <summary>
+    /// An "open" BitSet implementation that allows direct access to the array of words
+    /// storing the bits.
+    /// </summary>
+    /// <remarks>
+    /// 
+    /// <p/>
+    /// Unlike java.util.bitset, the fact that bits are packed into an array of longs
+    /// is part of the interface.  this allows efficient implementation of other algorithms
+    /// by someone other than the author.  It also allows one to efficiently implement
+    /// alternate serialization or interchange formats.
+    /// <p/>
+    /// <code>OpenBitSet</code> is faster than <code>java.util.BitSet</code> in most operations
+    /// and *much* faster at calculating cardinality of sets and results of set operations.
+    /// It can also handle sets of larger cardinality (up to 64 * 2**32-1)
+    /// <p/>
+    /// The goals of <code>OpenBitSet</code> are the fastest implementation possible, and
+    /// maximum code reuse.  Extra safety and encapsulation
+    /// may always be built on top, but if that's built in, the cost can never be removed (and
+    /// hence people re-implement their own version in order to get better performance).
+    /// If you want a "safe", totally encapsulated (and slower and limited) BitSet
+    /// class, use <code>java.util.BitSet</code>.
+    /// <p/>
+    /// <h3>Performance Results</h3>
+    ///
+    /// Test system: Pentium 4, Sun Java 1.5_06 -server -Xbatch -Xmx64M
+    /// <br/>BitSet size = 1,000,000
+    /// <br/>Results are java.util.BitSet time divided by OpenBitSet time.
+    /// <table border="1">
+    /// <tr>
+    ///  <th></th> <th>cardinality</th> <th>intersect_count</th> <th>union</th> <th>nextSetBit</th> <th>get</th> <th>iterator</th>
+    /// </tr>
+    /// <tr>
+    ///  <th>50% full</th> <td>3.36</td> <td>3.96</td> <td>1.44</td> <td>1.46</td> <td>1.99</td> <td>1.58</td>
+    /// </tr>
+    /// <tr>
+    ///   <th>1% full</th> <td>3.31</td> <td>3.90</td> <td>&amp;nbsp;</td> <td>1.04</td> <td>&amp;nbsp;</td> <td>0.99</td>
+    /// </tr>
+    /// </table>
+    /// <br/>
+    /// Test system: AMD Opteron, 64 bit linux, Sun Java 1.5_06 -server -Xbatch -Xmx64M
+    /// <br/>BitSet size = 1,000,000
+    /// <br/>Results are java.util.BitSet time divided by OpenBitSet time.
+    /// <table border="1">
+    /// <tr>
+    ///  <th></th> <th>cardinality</th> <th>intersect_count</th> <th>union</th> <th>nextSetBit</th> <th>get</th> <th>iterator</th>
+    /// </tr>
+    /// <tr>
+    ///  <th>50% full</th> <td>2.50</td> <td>3.50</td> <td>1.00</td> <td>1.03</td> <td>1.12</td> <td>1.25</td>
+    /// </tr>
+    /// <tr>
+    ///   <th>1% full</th> <td>2.51</td> <td>3.49</td> <td>&amp;nbsp;</td> <td>1.00</td> <td>&amp;nbsp;</td> <td>1.02</td>
+    /// </tr>
+    /// </table>
+    /// </remarks>
+
+    public class OpenBitSet : DocIdSet, IBits, ICloneable
+    {
+        private long[] bits;
+        private int wordLength; // number of words (elements) used in the array
+
+        // Used only for assert:
+        private long numBits;
+
+        /// <summary>
+        /// Constructs an OpenBitSet large enough to hold {@code numBits}. </summary>
+        public OpenBitSet(long numBits)
+        {
+            this.numBits = numBits;
+            bits = new long[Bits2Words(numBits)];
+            wordLength = bits.Length;
+        }
+
+        /// <summary>
+        /// Constructor: allocates enough space for 64 bits. </summary>
+        public OpenBitSet()
+            : this(64)
+        {
+        }
+
+        /// <summary>
+        /// Constructs an OpenBitSet from an existing long[].
+        /// </summary>
+        /// <remarks>
+        /// <p>
+        /// The first 64 bits are in long[0], with bit index 0 at the least significant
+        /// bit, and bit index 63 at the most significant. Given a bit index, the word
+        /// containing it is long[index/64], and it is at bit number index%64 within
+        /// that word.
+        /// </p>
+        /// <p>
+        /// numWords are the number of elements in the array that contain set bits
+        /// (non-zero longs). numWords should be &lt;= bits.length, and any existing
+        /// words in the array at position &gt;= numWords should be zero.
+        /// </p>
+        /// </remarks>
+        public OpenBitSet(long[] bits, int numWords)
+        {
+            if (numWords > bits.Length)
+            {
+                throw new ArgumentException("numWords cannot exceed bits.length");
+            }
+            this.bits = bits;
+            this.wordLength = numWords;
+            this.numBits = wordLength * 64;
+        }
+
+        public override DocIdSetIterator GetIterator()
+        {
+            return new OpenBitSetIterator(bits, this.wordLength);
+        }
+
+        public override IBits GetBits()
+        {
+            return this;
+        }
+
+        /// <summary>
+
+        /// Gets the <see cref="System.Boolean"/> at the specified index.
+        /// </summary>
+        /// <param name="index">The index.</param>
+        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
+        public bool this[int index]
+        {
+            get { return this.Get(index); }
+        }
+
+        /// <summary>
+        /// this DocIdSet implementation is cacheable. </summary>
+        public override bool Cacheable
+        {
+            get
+            {
+                return true;
+            }
+        }
+
+        /// <summary>
+        /// Returns the current capacity in bits (1 greater than the index of the last bit) </summary>
+        public virtual long Capacity()
+        {
+            return bits.Length << 6;
+        }
+
+        /// <summary>
+        /// Returns the current capacity of this set.  Included for
+        /// compatibility.  this is *not* equal to <seealso cref="Cardinality"/>
+        /// </summary>
+        public virtual long Size()
+        {
+            return Capacity();
+        }
+
+        /// <summary>
+        /// Returns the number of bits in the set.
+        /// </summary>
+        /// <value>The length.</value>
+        public virtual int Length
+        {
+            get
+            {
+                return bits.Length << 6;
+            }
+        }
+
+        /// <summary>
+        /// Returns true if there are no set bits </summary>
+        public virtual bool Empty
+        {
+            get
+            {
+                return Cardinality() == 0;
+            }
+        }
+
+        /// <summary>
+        /// Expert: returns the long[] storing the bits </summary>
+        public virtual long[] Bits
+        {
+            get
+            {
+                return bits;
+            }
+        }
+
+        /// <summary>
+        /// Expert: gets the number of longs in the array that are in use </summary>
+        public virtual int NumWords
+        {
+            get
+            {
+                return wordLength;
+            }
+        }
+
+        /// <summary>
+        /// Returns true or false for the specified bit index. </summary>
+        public virtual bool Get(int index)
+        {
+            int i = index >> 6; // div 64
+            // signed shift will keep a negative index and force an
+            // array-index-out-of-bounds-exception, removing the need for an explicit check.
+            if (i >= bits.Length)
+            {
+                return false;
+            }
+
+            int bit = index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            return (bits[i] & bitmask) != 0;
+        }
+
+        /// <summary>
+        /// Returns true or false for the specified bit index.
+        /// The index should be less than the OpenBitSet size
+        /// </summary>
+        public virtual bool FastGet(int index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int i = index >> 6; // div 64
+            // signed shift will keep a negative index and force an
+            // array-index-out-of-bounds-exception, removing the need for an explicit check.
+            int bit = index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            return (bits[i] & bitmask) != 0;
+        }
+
+        /// <summary>
+        /// Returns true or false for the specified bit index
+        /// </summary>
+        public virtual bool Get(long index)
+        {
+            var i = (int)(index >> 6); // div 64
+            if (i >= bits.Length)
+            {
+                return false;
+            }
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            return (bits[i] & bitmask) != 0;
+        }
+
+        /// <summary>
+        /// Returns true or false for the specified bit index.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual bool FastGet(long index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int i = (int)(index >> 6); // div 64
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            return (bits[i] & bitmask) != 0;
+        }
+
+        /*
+        // alternate implementation of get()
+        public boolean get1(int index) {
+          int i = index >> 6;                // div 64
+          int bit = index & 0x3f;            // mod 64
+          return ((bits[i]>>>bit) & 0x01) != 0;
+          // this does a long shift and a bittest (on x86) vs
+          // a long shift, and a long AND, (the test for zero is prob a no-op)
+          // testing on a P4 indicates this is slower than (bits[i] & bitmask) != 0;
+        }
+        */
+
+        /// <summary>
+        /// returns 1 if the bit is set, 0 if not.
+        /// The index should be less than the OpenBitSet size
+        /// </summary>
+        public virtual int GetBit(int index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int i = index >> 6; // div 64
+            int bit = index & 0x3f; // mod 64
+            return ((int)((long)((ulong)bits[i] >> bit))) & 0x01;
+        }
+
+        /*
+        public boolean get2(int index) {
+          int word = index >> 6;            // div 64
+          int bit = index & 0x0000003f;     // mod 64
+          return (bits[word] << bit) < 0;   // hmmm, this would work if bit order were reversed
+          // we could right shift and check for parity bit, if it was available to us.
+        }
+        */
+
+        /// <summary>
+        /// sets a bit, expanding the set size if necessary </summary>
+        public virtual void Set(long index)
+        {
+            int wordNum = ExpandingWordNum(index);
+            int bit = (int)index & 0x3f;
+            long bitmask = 1L << bit;
+            bits[wordNum] |= bitmask;
+        }
+
+        /// <summary>
+        /// Sets the bit at the specified index.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual void FastSet(int index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = index >> 6; // div 64
+            int bit = index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] |= bitmask;
+        }
+
+        /// <summary>
+        /// Sets the bit at the specified index.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual void FastSet(long index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = (int)(index >> 6);
+            int bit = (int)index & 0x3f;
+            long bitmask = 1L << bit;
+            bits[wordNum] |= bitmask;
+        }
+
+        /// <summary>
+        /// Sets a range of bits, expanding the set size if necessary
+        /// </summary>
+        /// <param name="startIndex"> lower index </param>
+        /// <param name="endIndex"> one-past the last bit to set </param>
+        public virtual void Set(long startIndex, long endIndex)
+        {
+            if (endIndex <= startIndex)
+            {
+                return;
+            }
+
+            int startWord = (int)(startIndex >> 6);
+
+            // since endIndex is one past the end, this is index of the last
+            // word to be changed.
+            int endWord = ExpandingWordNum(endIndex - 1);
+
+            long startmask = -1L << (int)startIndex;
+            long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+            if (startWord == endWord)
+            {
+                bits[startWord] |= (startmask & endmask);
+                return;
+            }
+
+            bits[startWord] |= startmask;
+            bits.Fill(startWord + 1, endWord, -1L);
+            bits[endWord] |= endmask;
+        }
+
+        protected internal virtual int ExpandingWordNum(long index)
+        {
+            int wordNum = (int)(index >> 6);
+            if (wordNum >= wordLength)
+            {
+                EnsureCapacity(index + 1);
+            }
+            return wordNum;
+        }
+
+        /// <summary>
+        /// clears a bit.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual void FastClear(int index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = index >> 6;
+            int bit = index & 0x03f;
+            long bitmask = 1L << bit;
+            bits[wordNum] &= ~bitmask;
+            // hmmm, it takes one more instruction to clear than it does to set... any
+            // way to work around this?  If there were only 63 bits per word, we could
+            // use a right shift of 10111111...111 in binary to position the 0 in the
+            // correct place (using sign extension).
+            // Could also use Long.rotateRight() or rotateLeft() *if* they were converted
+            // by the JVM into a native instruction.
+            // bits[word] &= Long.rotateLeft(0xfffffffe,bit);
+        }
+
+        /// <summary>
+        /// clears a bit.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual void FastClear(long index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = (int)(index >> 6); // div 64
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] &= ~bitmask;
+        }
+
+        /// <summary>
+        /// clears a bit, allowing access beyond the current set size without changing the size. </summary>
+        public virtual void Clear(long index)
+        {
+            int wordNum = (int)(index >> 6); // div 64
+            if (wordNum >= wordLength)
+            {
+                return;
+            }
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] &= ~bitmask;
+        }
+
+        /// <summary>
+        /// Clears a range of bits.  Clearing past the end does not change the size of the set.
+        /// </summary>
+        /// <param name="startIndex"> lower index </param>
+        /// <param name="endIndex"> one-past the last bit to clear </param>
+        public virtual void Clear(int startIndex, int endIndex)
+        {
+            if (endIndex <= startIndex)
+            {
+                return;
+            }
+
+            int startWord = (startIndex >> 6);
+            if (startWord >= wordLength)
+            {
+                return;
+            }
+
+            // since endIndex is one past the end, this is index of the last
+            // word to be changed.
+            int endWord = ((endIndex - 1) >> 6);
+
+            //LUCENE TO-DO
+            long startmask = -1L << startIndex;
+            long endmask = -(int)((uint)1L >> -endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+            // invert masks since we are clearing
+            startmask = ~startmask;
+            endmask = ~endmask;
+
+            if (startWord == endWord)
+            {
+                bits[startWord] &= (startmask | endmask);
+                return;
+            }
+
+            bits[startWord] &= startmask;
+
+            int middle = Math.Min(wordLength, endWord);
+            bits.Fill(startWord + 1, middle, 0L);
+            if (endWord < wordLength)
+            {
+                bits[endWord] &= endmask;
+            }
+        }
+
+        /// <summary>
+        /// Clears a range of bits.  Clearing past the end does not change the size of the set.
+        /// </summary>
+        /// <param name="startIndex"> lower index </param>
+        /// <param name="endIndex"> one-past the last bit to clear </param>
+        public virtual void Clear(long startIndex, long endIndex)
+        {
+            if (endIndex <= startIndex)
+            {
+                return;
+            }
+
+            int startWord = (int)(startIndex >> 6);
+            if (startWord >= wordLength)
+            {
+                return;
+            }
+
+            // since endIndex is one past the end, this is index of the last
+            // word to be changed.
+            int endWord = (int)((endIndex - 1) >> 6);
+
+            //LUCENE TO-DO
+            long startmask = -1L << (int)startIndex;
+            long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+            // invert masks since we are clearing
+            startmask = ~startmask;
+            endmask = ~endmask;
+
+            if (startWord == endWord)
+            {
+                bits[startWord] &= (startmask | endmask);
+                return;
+            }
+
+            bits[startWord] &= startmask;
+
+            int middle = Math.Min(wordLength, endWord);
+            bits.Fill(startWord + 1, middle, 0L);
+            if (endWord < wordLength)
+            {
+                bits[endWord] &= endmask;
+            }
+        }
+
+        /// <summary>
+        /// Sets a bit and returns the previous value.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual bool GetAndSet(int index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = index >> 6; // div 64
+            int bit = index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bool val = (bits[wordNum] & bitmask) != 0;
+            bits[wordNum] |= bitmask;
+            return val;
+        }
+
+        /// <summary>
+        /// Sets a bit and returns the previous value.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual bool GetAndSet(long index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = (int)(index >> 6); // div 64
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bool val = (bits[wordNum] & bitmask) != 0;
+            bits[wordNum] |= bitmask;
+            return val;
+        }
+
+        /// <summary>
+        /// flips a bit.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual void FastFlip(int index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = index >> 6; // div 64
+            int bit = index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] ^= bitmask;
+        }
+
+        /// <summary>
+        /// flips a bit.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual void FastFlip(long index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = (int)(index >> 6); // div 64
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] ^= bitmask;
+        }
+
+        /// <summary>
+        /// flips a bit, expanding the set size if necessary </summary>
+        public virtual void Flip(long index)
+        {
+            int wordNum = ExpandingWordNum(index);
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] ^= bitmask;
+        }
+
+        /// <summary>
+        /// flips a bit and returns the resulting bit value.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual bool FlipAndGet(int index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = index >> 6; // div 64
+            int bit = index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] ^= bitmask;
+            return (bits[wordNum] & bitmask) != 0;
+        }
+
+        /// <summary>
+        /// flips a bit and returns the resulting bit value.
+        /// The index should be less than the OpenBitSet size.
+        /// </summary>
+        public virtual bool FlipAndGet(long index)
+        {
+            Debug.Assert(index >= 0 && index < numBits);
+            int wordNum = (int)(index >> 6); // div 64
+            int bit = (int)index & 0x3f; // mod 64
+            long bitmask = 1L << bit;
+            bits[wordNum] ^= bitmask;
+            return (bits[wordNum] & bitmask) != 0;
+        }
+
+        /// <summary>
+        /// Flips a range of bits, expanding the set size if necessary
+        /// </summary>
+        /// <param name="startIndex"> lower index </param>
+        /// <param name="endIndex"> one-past the last bit to flip </param>
+        public virtual void Flip(long startIndex, long endIndex)
+        {
+            if (endIndex <= startIndex)
+            {
+                return;
+            }
+            int startWord = (int)(startIndex >> 6);
+
+            // since endIndex is one past the end, this is index of the last
+            // word to be changed.
+            int endWord = ExpandingWordNum(endIndex - 1);
+
+           
+            // Grrr, java shifting wraps around so -1L>>>64 == -1
+            // for that reason, make sure not to use endmask if the bits to flip will
+            // be zero in the last word (redefine endWord to be the last changed...)
+            // long startmask = -1L << (startIndex & 0x3f);     // example: 11111...111000
+            // long endmask = -1L >>> (64-(endIndex & 0x3f));   // example: 00111...111111
+           
+
+            //LUCENE TO-DO
+            long startmask = -1L << (int)startIndex;
+            long endmask = -(int)((uint)1L >> (int)-endIndex); // 64-(endIndex&0x3f) is the same as -endIndex due to wrap
+
+            if (startWord == endWord)
+            {
+                bits[startWord] ^= (startmask & endmask);
+                return;
+            }
+
+            bits[startWord] ^= startmask;
+
+            for (int i = startWord + 1; i < endWord; i++)
+            {
+                bits[i] = ~bits[i];
+            }
+
+            bits[endWord] ^= endmask;
+        }
+
+        /*
+        public static int pop(long v0, long v1, long v2, long v3) {
+          // derived from pop_array by setting last four elems to 0.
+          // exchanges one pop() call for 10 elementary operations
+          // saving about 7 instructions... is there a better way?
+            long twosA=v0 & v1;
+            long ones=v0^v1;
+
+            long u2=ones^v2;
+            long twosB =(ones&v2)|(u2&v3);
+            ones=u2^v3;
+
+            long fours=(twosA&twosB);
+            long twos=twosA^twosB;
+
+            return (pop(fours)<<2)
+                   + (pop(twos)<<1)
+                   + pop(ones);
+        }
+        */
+
+        /// <returns> the number of set bits </returns>
+        public virtual long Cardinality()
+        {
+            return BitUtil.PopArray(bits, 0, wordLength);
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of the intersection of the two sets.
+        /// Neither set is modified.
+        /// </summary>
+        public static long IntersectionCount(OpenBitSet a, OpenBitSet b)
+        {
+            return BitUtil.PopIntersect(a.bits, b.bits, 0, Math.Min(a.wordLength, b.wordLength));
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of the union of the two sets.
+        /// Neither set is modified.
+        /// </summary>
+        public static long UnionCount(OpenBitSet a, OpenBitSet b)
+        {
+            long tot = BitUtil.PopUnion(a.bits, b.bits, 0, Math.Min(a.wordLength, b.wordLength));
+            if (a.wordLength < b.wordLength)
+            {
+                tot += BitUtil.PopArray(b.bits, a.wordLength, b.wordLength - a.wordLength);
+            }
+            else if (a.wordLength > b.wordLength)
+            {
+                tot += BitUtil.PopArray(a.bits, b.wordLength, a.wordLength - b.wordLength);
+            }
+            return tot;
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of "a and not b"
+        /// or "intersection(a, not(b))".
+        /// Neither set is modified.
+        /// </summary>
+        public static long AndNotCount(OpenBitSet a, OpenBitSet b)
+        {
+            long tot = BitUtil.PopAndNot(a.bits, b.bits, 0, Math.Min(a.wordLength, b.wordLength));
+            if (a.wordLength > b.wordLength)
+            {
+                tot += BitUtil.PopArray(a.bits, b.wordLength, a.wordLength - b.wordLength);
+            }
+            return tot;
+        }
+
+        /// <summary>
+        /// Returns the popcount or cardinality of the exclusive-or of the two sets.
+        /// Neither set is modified.
+        /// </summary>
+        public static long XorCount(OpenBitSet a, OpenBitSet b)
+        {
+            long tot = BitUtil.PopXor(a.bits, b.bits, 0, Math.Min(a.wordLength, b.wordLength));
+            if (a.wordLength < b.wordLength)
+            {
+                tot += BitUtil.PopArray(b.bits, a.wordLength, b.wordLength - a.wordLength);
+            }
+            else if (a.wordLength > b.wordLength)
+            {
+                tot += BitUtil.PopArray(a.bits, b.wordLength, a.wordLength - b.wordLength);
+            }
+            return tot;
+        }
+
+        /// <summary>
+        /// Returns the index of the first set bit starting at the index specified.
+        ///  -1 is returned if there are no more set bits.
+        /// </summary>
+        public virtual int NextSetBit(int index)
+        {
+            int i = index >> 6;
+            if (i >= wordLength)
+            {
+                return -1;
+            }
+            int subIndex = index & 0x3f; // index within the word
+            long word = bits[i] >> subIndex; // skip all the bits to the right of index
+
+            if (word != 0)
+            {
+                return (i << 6) + subIndex + word.NumberOfTrailingZeros();
+            }
+
+            while (++i < wordLength)
+            {
+                word = bits[i];
+                if (word != 0)
+                {
+                    return (i << 6) + word.NumberOfTrailingZeros();
+                }
+            }
+
+            return -1;
+        }
+
+        /// <summary>
+        /// Returns the index of the first set bit starting at the index specified.
+        ///  -1 is returned if there are no more set bits.
+        /// </summary>
+        public virtual long NextSetBit(long index)
+        {
+            int i = (int)((long)((ulong)index >> 6));
+            if (i >= wordLength)
+            {
+                return -1;
+            }
+            int subIndex = (int)index & 0x3f; // index within the word
+            long word = (long)((ulong)bits[i] >> subIndex); // skip all the bits to the right of index
+
+            if (word != 0)
+            {
+                return (((long)i) << 6) + (subIndex + word.NumberOfTrailingZeros());
+            }
+
+            while (++i < wordLength)
+            {
+                word = bits[i];
+                if (word != 0)
+                {
+                    return (((long)i) << 6) + word.NumberOfTrailingZeros();
+                }
+            }
+
+            return -1;
+        }
+
+        /// <summary>
+        /// Returns the index of the first set bit starting downwards at
+        ///  the index specified.
+        ///  -1 is returned if there are no more set bits.
+        /// </summary>
+        public virtual int PrevSetBit(int index)
+        {
+            int i = index >> 6;
+            int subIndex;
+            long word;
+            if (i >= wordLength)
+            {
+                i = wordLength - 1;
+                if (i < 0)
+                {
+                    return -1;
+                }
+                subIndex = 63; // last possible bit
+                word = bits[i];
+            }
+            else
+            {
+                if (i < 0)
+                {
+                    return -1;
+                }
+                subIndex = index & 0x3f; // index within the word
+                word = (bits[i] << (63 - subIndex)); // skip all the bits to the left of index
+            }
+
+            if (word != 0)
+            {
+                return (i << 6) + subIndex - word.NumberOfLeadingZeros(); // See LUCENE-3197
+            }
+
+            while (--i >= 0)
+            {
+                word = bits[i];
+                if (word != 0)
+                {
+                    return (i << 6) + 63 - word.NumberOfLeadingZeros();
+                }
+            }
+
+            return -1;
+        }
+
+        /// <summary>
+        /// Returns the index of the first set bit starting downwards at
+        ///  the index specified.
+        ///  -1 is returned if there are no more set bits.
+        /// </summary>
+        public virtual long PrevSetBit(long index)
+        {
+            int i = (int)(index >> 6);
+            int subIndex;
+            long word;
+            if (i >= wordLength)
+            {
+                i = wordLength - 1;
+                if (i < 0)
+                {
+                    return -1;
+                }
+                subIndex = 63; // last possible bit
+                word = bits[i];
+            }
+            else
+            {
+                if (i < 0)
+                {
+                    return -1;
+                }
+                subIndex = (int)index & 0x3f; // index within the word
+                word = (bits[i] << (63 - subIndex)); // skip all the bits to the left of index
+            }
+
+            if (word != 0)
+            {
+                return (((long)i) << 6) + subIndex - word.NumberOfLeadingZeros(); // See LUCENE-3197
+            }
+
+            while (--i >= 0)
+            {
+                word = bits[i];
+                if (word != 0)
+                {
+                    return (((long)i) << 6) + 63 - word.NumberOfLeadingZeros();
+                }
+            }
+
+            return -1;
+        }
+
+        /// <summary>
+        /// Clones <see cref="OpenBitSet"/>. Set <paramref name="deepCopy"/> to
+        /// to <c>true</c> for most copies.
+        /// </summary>
+        /// <param name="deepCopy">if set to <c>true</c> [deep copy].</param>
+        /// <returns>System.Object.</returns>
+        /// <exception cref="System.InvalidOperationException"></exception>
+        public object Clone(bool deepCopy = true)
+        {
+            if (!deepCopy) 
+                return new OpenBitSet((long[])this.bits.Copy(), this.wordLength);
+            
+            try
+            {
+                //OpenBitSet obs = (OpenBitSet)base.Clone();
+                //obs.bits = (long[])obs.bits.Clone(); // hopefully an array clone is as fast(er) than arraycopy
+                var obs = new OpenBitSet((long[])this.bits.Clone(), this.wordLength);
+                return obs;
+            }
+            catch (Exception e)
+            {
+                throw new InvalidOperationException(e.Message, e);
+            }
+        }
+
+        /// <summary>
+        /// this = this AND other </summary>
+        public virtual void Intersect(OpenBitSet other)
+        {
+            int newLen = Math.Min(this.wordLength, other.wordLength);
+            long[] thisArr = this.bits;
+            long[] otherArr = other.bits;
+            // testing against zero can be more efficient
+            int pos = newLen;
+            while (--pos >= 0)
+            {
+                thisArr[pos] &= otherArr[pos];
+            }
+            if (this.wordLength > newLen)
+            {
+                // fill zeros from the new shorter length to the old length
+                bits.Fill(newLen, this.wordLength, 0L);
+            }
+            this.wordLength = newLen;
+        }
+
+        /// <summary>
+        /// this = this OR other </summary>
+        public virtual void Union(OpenBitSet other)
+        {
+            int newLen = Math.Max(wordLength, other.wordLength);
+            EnsureCapacityWords(newLen);
+            Debug.Assert((numBits = Math.Max(other.numBits, numBits)) >= 0);
+
+            long[] thisArr = this.bits;
+            long[] otherArr = other.bits;
+            int pos = Math.Min(wordLength, other.wordLength);
+            while (--pos >= 0)
+            {
+                thisArr[pos] |= otherArr[pos];
+            }
+            if (this.wordLength < newLen)
+            {
+                Array.Copy(otherArr, this.wordLength, thisArr, this.wordLength, newLen - this.wordLength);
+            }
+            this.wordLength = newLen;
+        }
+
+        /// <summary>
+        /// Remove all elements set in other. this = this AND_NOT other </summary>
+        public virtual void Remove(OpenBitSet other)
+        {
+            int idx = Math.Min(wordLength, other.wordLength);
+            long[] thisArr = this.bits;
+            long[] otherArr = other.bits;
+            while (--idx >= 0)
+            {
+                thisArr[idx] &= ~otherArr[idx];
+            }
+        }
+
+        /// <summary>
+        /// this = this XOR other </summary>
+        public virtual void Xor(OpenBitSet other)
+        {
+            int newLen = Math.Max(wordLength, other.wordLength);
+            EnsureCapacityWords(newLen);
+            Debug.Assert((numBits = Math.Max(other.numBits, numBits)) >= 0);
+
+            long[] thisArr = this.bits;
+            long[] otherArr = other.bits;
+            int pos = Math.Min(wordLength, other.wordLength);
+            while (--pos >= 0)
+            {
+                thisArr[pos] ^= otherArr[pos];
+            }
+            if (this.wordLength < newLen)
+            {
+                Array.Copy(otherArr, this.wordLength, thisArr, this.wordLength, newLen - this.wordLength);
+            }
+            this.wordLength = newLen;
+        }
+
+        // some BitSet compatability methods
+
+        //** see {@link intersect} */
+        public virtual void And(OpenBitSet other)
+        {
+            Intersect(other);
+        }
+
+        //** see {@link union} */
+        public virtual void Or(OpenBitSet other)
+        {
+            Union(other);
+        }
+
+        //** see {@link andNot} */
+        public virtual void AndNot(OpenBitSet other)
+        {
+            Remove(other);
+        }
+
+        /// <summary>
+        /// returns true if the sets have any elements in common </summary>
+        public virtual bool Intersects(OpenBitSet other)
+        {
+            int pos = Math.Min(this.wordLength, other.wordLength);
+            long[] thisArr = this.bits;
+            long[] otherArr = other.bits;
+            while (--pos >= 0)
+            {
+                if ((thisArr[pos] & otherArr[pos]) != 0)
+                {
+                    return true;
+                }
+            }
+            return false;
+        }
+
+        /// <summary>
+        /// Expand the long[] with the size given as a number of words (64 bit longs). </summary>
+        public virtual void EnsureCapacityWords(int numWords)
+        {
+            bits = ArrayUtil.Grow(bits, numWords);
+            wordLength = numWords;
+            Debug.Assert((this.numBits = Math.Max(this.numBits, numWords << 6)) >= 0);
+        }
+
+        /// <summary>
+        /// Ensure that the long[] is big enough to hold numBits, expanding it if
+        /// necessary.
+        /// </summary>
+        public virtual void EnsureCapacity(long numberOfBits)
+        {
+            EnsureCapacityWords(Bits2Words(numberOfBits));
+            // ensureCapacityWords sets numBits to a multiple of 64, but we want to set
+            // it to exactly what the app asked.
+            Debug.Assert((this.numBits = Math.Max(this.numBits, numberOfBits)) >= 0);
+        }
+
+        /// <summary>
+        /// Lowers numWords, the number of words in use,
+        /// by checking for trailing zero words.
+        /// </summary>
+        public virtual void TrimTrailingZeros()
+        {
+            int idx = wordLength - 1;
+            while (idx >= 0 && bits[idx] == 0)
+            {
+                idx--;
+            }
+            wordLength = idx + 1;
+        }
+
+        /// <summary>
+        /// returns the number of 64 bit words it would take to hold numBits </summary>
+        public static int Bits2Words(long numBits)
+        {
+            return (((int)((uint)(numBits - 1) >> 6)) + 1);
+        }
+
+        /// <summary>
+        /// returns true if both sets have the same bits set </summary>
+        public override bool Equals(object o)
+        {
+            if (this == o)
+            {
+                return true;
+            }
+            if (!(o is OpenBitSet))
+            {
+                return false;
+            }
+            OpenBitSet a;
+            OpenBitSet b = (OpenBitSet)o;
+            // make a the larger set.
+            if (b.wordLength > this.wordLength)
+            {
+                a = b;
+                b = this;
+            }
+            else
+            {
+                a = this;
+            }
+
+            // check for any set bits out of the range of b
+            for (int i = a.wordLength - 1; i >= b.wordLength; i--)
+            {
+                if (a.bits[i] != 0)
+                {
+                    return false;
+                }
+            }
+
+            for (int i = b.wordLength - 1; i >= 0; i--)
+            {
+                if (a.bits[i] != b.bits[i])
+                {
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        public override int GetHashCode()
+        {
+            // Start with a zero hash and use a mix that results in zero if the input is zero.
+            // this effectively truncates trailing zeros without an explicit check.
+            long h = 0;
+            // ReSharper disable NonReadonlyFieldInGetHashCode
+            for (int i = bits.Length; --i >= 0; )
+            {
+                h ^= bits[i];
+                h = (h << 1) | ((long)((ulong)h >> 63)); // rotate left
+            }
+            // fold leftmost bits into right and add a constant to prevent
+            // empty sets from returning 0, which is too common.
+            return (int)((h >> 32) ^ h) + unchecked((int)0x98761234);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/d3242166/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
new file mode 100644
index 0000000..9b2484c
--- /dev/null
+++ b/src/Lucene.Net.Core/Util/OpenBitSetIterator.cs
@@ -0,0 +1,184 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Util
+{
+    using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
+
+    /// <summary>
+    /// An iterator to iterate over set bits in an OpenBitSet.
+    /// this is faster than nextSetBit() for iterating over the complete set of bits,
+    /// especially when the density of the bits set is high.
+    /// </summary>
+    public class OpenBitSetIterator : DocIdSetIterator
+    {
+        // hmmm, what about an iterator that finds zeros though,
+        // or a reverse iterator... should they be separate classes
+        // for efficiency, or have a common root interface?  (or
+        // maybe both?  could ask for a SetBitsIterator, etc...
+
+        private readonly long[] array;
+        private readonly int words;
+        private int position = -1;
+        private long word;
+        private int wordShift;
+        private int indexArray;
+        private int currentDocId = -1;
+
+        public OpenBitSetIterator(OpenBitSet obs)
+            : this(obs.Bits, obs.NumWords)
+        {
+        }
+
+        public OpenBitSetIterator(long[] bits, int numWords)
+        {
+            array = bits;
+            words = numWords;
+        }
+
+        // 64 bit shifts
+        private void Shift()
+        {
+            if ((int)word == 0)
+            {
+                wordShift += 32;
+                word = (long)((ulong)word >> 32);
+            }
+            if ((word & 0x0000FFFF) == 0)
+            {
+                wordShift += 16;
+                word = (long)((ulong)word >> 16);
+            }
+            if ((word & 0x000000FF) == 0)
+            {
+                wordShift += 8;
+                word = (long)((ulong)word >> 8);
+            }
+            indexArray = BitUtil.BitList((byte)word);
+        }
+
+        /// <summary>
+        ///*** alternate shift implementations
+        /// // 32 bit shifts, but a long shift needed at the end
+        /// private void shift2() {
+        ///  int y = (int)word;
+        ///  if (y==0) {wordShift +=32; y = (int)(word >>>32); }
+        ///  if ((y & 0x0000FFFF) == 0) { wordShift +=16; y>>>=16; }
+        ///  if ((y & 0x000000FF) == 0) { wordShift +=8; y>>>=8; }
+        ///  indexArray = bitlist[y & 0xff];
+        ///  word >>>= (wordShift +1);
+        /// }
+        ///
+        /// private void shift3() {
+        ///  int lower = (int)word;
+        ///  int lowByte = lower & 0xff;
+        ///  if (lowByte != 0) {
+        ///    indexArray=bitlist[lowByte];
+        ///    return;
+        ///  }
+        ///  shift();
+        /// }
+        /// *****
+        /// </summary>
+
+        public override int NextDoc()
+        {
+            if (indexArray == 0)
+            {
+                if (word != 0)
+                {
+                    word = (long)((ulong)word >> 8);
+                    wordShift += 8;
+                }
+
+                while (word == 0)
+                {
+                    if (++position >= words)
+                    {
+                        return currentDocId = NO_MORE_DOCS;
+                    }
+                    word = array[position];
+                    wordShift = -1; // loop invariant code motion should move this
+                }
+
+                // after the first time, should I go with a linear search, or
+                // stick with the binary search in shift?
+                Shift();
+            }
+
+            int bitIndex = (indexArray & 0x0f) + wordShift;
+            indexArray = (int)((uint)indexArray >> 4);
+            // should i<<6 be cached as a separate variable?
+            // it would only save one cycle in the best circumstances.
+            return currentDocId = (position << 6) + bitIndex;
+        }
+
+        public override int Advance(int target)
+        {
+            indexArray = 0;
+            position = target >> 6;
+            if (position >= words)
+            {
+                word = 0; // setup so next() will also return -1
+                return currentDocId = NO_MORE_DOCS;
+            }
+            wordShift = target & 0x3f;
+            word = (long)((ulong)array[position] >> wordShift);
+            if (word != 0)
+            {
+                wordShift--; // compensate for 1 based arrIndex
+            }
+            else
+            {
+                while (word == 0)
+                {
+                    if (++position >= words)
+                    {
+                        return currentDocId = NO_MORE_DOCS;
+                    }
+                    word = array[position];
+                }
+                wordShift = -1;
+            }
+
+            Shift();
+
+            int bitIndex = (indexArray & 0x0f) + wordShift;
+            indexArray = (int)((uint)indexArray >> 4);
+            // should i<<6 be cached as a separate variable?
+            // it would only save one cycle in the best circumstances.
+            return currentDocId = (position << 6) + bitIndex;
+        }
+
+        public override int DocId
+        {
+            get { return this.currentDocId; }
+           
+        }
+
+        public override long Cost()
+        {
+            return words / 64;
+        }
+
+        protected override void Reset()
+        {
+            this.position = -1;
+            this.currentDocId = -1;
+        }
+    }
+}
\ No newline at end of file


[4/7] lucenenet git commit: creating new projects in order to separate out logic create to suppliment .NET with JAVA standard library functionality.

Posted by mh...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj b/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
index 54711db..7a3150c 100644
--- a/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
+++ b/test/Lucene.Net.Core.Tests/Lucene.Net.Core.Tests.csproj
@@ -23,7 +23,7 @@
   <Import Project="..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
-    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProjectGuid>{C879C7A6-FBE5-4F22-B363-A4356C7B8E76}</ProjectGuid>
@@ -34,8 +34,8 @@
     <DefaultLanguage>en-US</DefaultLanguage>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
-    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
     <RestorePackages>true</RestorePackages>
   </PropertyGroup>
@@ -70,6 +70,7 @@
     <Compile Include="Util\TestCharsRef.cs" />
     <Compile Include="Util\TestConstants.cs" />
     <Compile Include="Util\TestInPlaceMergeSorter.cs" />
+    <Compile Include="Util\TestOpenBitSet.cs" />
     <Compile Include="Util\TestPurgableThreadLocal.cs" />
     <Compile Include="Util\TestRamEstimatorUsage.cs" />
     <Compile Include="Util\TestSetOnce.cs" />
@@ -95,6 +96,10 @@
       <Project>{ad8901c0-209d-4132-80aa-257dbaceecb4}</Project>
       <Name>Lucene.Net.Core</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj">
+      <Project>{438b8450-e93a-425f-9a9b-11d02e8896d5}</Project>
+      <Name>Lucene.Net.TestFramework.Core</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Lucene.Net.TestFramework\Lucene.Net.TestFramework.csproj">
       <Project>{f0d68fea-b118-43b6-b760-3fb75cde766d}</Project>
       <Name>Lucene.Net.TestFramework</Name>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs b/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
index 0318665..3d8931c 100644
--- a/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
+++ b/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
@@ -98,7 +98,7 @@ namespace Lucene.Net.Util
             var entries = new Entry[length];
             for (var i = 0; i < entries.Length; ++i)
             {
-                strategy.SetValue(this.Random, entries, i);
+                strategy.SetValue(Random, entries, i);
             }
 
             return entries;
@@ -107,8 +107,8 @@ namespace Lucene.Net.Util
         // test(Entry[] array)
         protected Entry[] CopyAndSort(Entry[] entries)
         {
-            int start = this.Random.Next(1000);
-            var toSort = new Entry[start + entries.Length + this.Random.Next(3)];
+            int start = Random.Next(1000);
+            var toSort = new Entry[start + entries.Length + Random.Next(3)];
             Array.Copy(entries, 0, toSort, start, entries.Length);
 
             var sorter = this.CreateSorter(toSort);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs b/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
index db6bbe3..e91d419 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestBroadWord.cs
@@ -98,10 +98,11 @@ namespace Lucene.Net.Util
         }
 
         [Test]
-        [Perf] // TODO: implement a real performance test.
+        [Performance] // TODO: implement a real performance test.
         public void TestPerfSelectAllBitsBroad()
         {
-            for (int j = 0; j < 100000; j++)
+            var length = AtLeast(5000);
+            for (int j = 0; j < length; j++)
             { // 1000000 for real perf test
                 for (int i = 0; i < 64; i++)
                 {
@@ -111,10 +112,12 @@ namespace Lucene.Net.Util
             }
         }
 
-        [Test][Perf]
+        [Test]
+        [Performance]
         public void TestPerfSelectAllBitsNaive()
         {
-            for (int j = 0; j < 10000; j++)
+            var length = AtLeast(5000);
+            for (int j = 0; j < length; j++)
             { // real perftest: 1000000
                 for (int i = 0; i < 64; i++)
                 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs b/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
index f7b6897..bb6de32 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestByteArrayRef.cs
@@ -28,7 +28,7 @@ namespace Lucene.Net.Util
         [Test]
         public virtual void TestAppend()
         {
-            var random = this.Random;
+            var random = Random;
             var  list = new BytesRefArray(Counter.NewCounter());
             IList<string> stringList = new List<string>();
             for (int j = 0; j < 2; j++)
@@ -38,7 +38,7 @@ namespace Lucene.Net.Util
                     list.Clear();
                     stringList.Clear();
                 }
-                int entries = this.AtLeast(500);
+                int entries = Random.AtLeast(500);
                 var spare = new BytesRefBuilder();
                 int initSize = list.Length;
                 for (int i = 0; i < entries; i++)
@@ -78,7 +78,7 @@ namespace Lucene.Net.Util
         [Test]
         public virtual void TestSort()
         {
-            var random = this.Random;
+            var random = Random;
             var list = new BytesRefArray(Util.Counter.NewCounter());
             var stringList = new List<string>();
 
@@ -89,7 +89,7 @@ namespace Lucene.Net.Util
                     list.Clear();
                     stringList.Clear();
                 }
-                int entries = this.AtLeast(500);
+                int entries = Random.AtLeast(500);
                 var spare = new BytesRef();
                 int initSize = list.Length;
                 for (int i = 0; i < entries; i++)

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs b/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
index 0bfff1b..95321cc 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestByteBlockPool.cs
@@ -52,17 +52,17 @@ namespace Lucene.Net.Util
             var bytesUsed = Counter.NewCounter();
             var  pool = new ByteBlockPool(new ByteBlockPool.DirectTrackingAllocator(bytesUsed));
             
-            var reuseFirst = this.Random.NextBoolean();
+            var reuseFirst = Random.NextBoolean();
             for (var j = 0; j < 2; j++)
             {
                 IList<BytesRefProxy> list = new List<BytesRefProxy>();
-                int maxLength = this.AtLeast(500),
-                    numValues = this.AtLeast(100);
+                int maxLength = Random.AtLeast(500),
+                    numValues = Random.AtLeast(100);
                 
                
                 numValues.Times(i =>
                 {
-                    string value = this.Random.RandomRealisticUnicodeString(maxLength: maxLength);
+                    string value = Random.RandomRealisticUnicodeString(maxLength: maxLength);
                     list.Add(new BytesRefProxy(value));
                     var @ref = new BytesRefProxy();
                     @ref.CopyChars(value);
@@ -80,7 +80,7 @@ namespace Lucene.Net.Util
                     Equal(expected, @ref);
                     position += @ref.Length;
                 }
-                pool.Reset(this.Random.NextBoolean(), reuseFirst);
+                pool.Reset(Random.NextBoolean(), reuseFirst);
                 if (reuseFirst)
                 {
                     Equal(ByteBlockPool.BYTE_BLOCK_SIZE, bytesUsed.Count);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs b/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
index 034d89f..7a19bf7 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
@@ -50,7 +50,7 @@ namespace Lucene.Net.Util
         {
             100.Times((i) =>
             {
-                var utf8Str1 = this.Random.ToUnicodeString();
+                var utf8Str1 = Random.ToUnicodeString();
                 var utf8Str2 = new BytesRef(utf8Str1).Utf8ToString();
                 Equal(utf8Str1, utf8Str2);
             });

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs b/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
index 35b789c..02ab41b 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
@@ -31,13 +31,13 @@ namespace Lucene.Net.Util
         [Test]
         public void TestUtf16InUtf8Order()
         {
-            var iterations = this.AtLeast(1000);
+            var iterations = AtLeast(1000);
             var utf8 = new BytesRef[iterations];
             var utf16 = new CharsRef[iterations];
 
             iterations.Times((i) =>
             {
-                var s = this.Random.RandomUnicodeString();
+                var s = Random.RandomUnicodeString();
                 utf8[i] = new BytesRef(s);
                 utf16[i] = new CharsRef(s);
             });
@@ -55,11 +55,11 @@ namespace Lucene.Net.Util
         public void TestAppend() {
             var builder = new CharsRefBuilder();
             var sb = new StringBuilder();
-            int iterations = this.AtLeast(10);
+            int iterations = Random.AtLeast(10);
 
             iterations.Times((i) => {
-                var charArray = this.Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
-                int offset = this.Random.Next(charArray.Length);
+                var charArray = Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
+                int offset = Random.Next(charArray.Length);
                 int length = charArray.Length - offset;
                 sb.Append(charArray, offset, length);
                 builder.Append(charArray, offset, length);  
@@ -72,11 +72,11 @@ namespace Lucene.Net.Util
         [Test]
         public void TestCopy()
         {
-            var iterations = this.AtLeast(10);
+            var iterations = Random.AtLeast(10);
             iterations.Times((i) => {
                 var builder = new CharsRefBuilder();
-                var charArray = this.Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
-                int offset = this.Random.Next(charArray.Length),
+                var charArray = Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
+                int offset = Random.Next(charArray.Length),
                     length = charArray.Length - offset;
 
                String str = new String(charArray, offset, length);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs b/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs
new file mode 100644
index 0000000..13a09dc
--- /dev/null
+++ b/test/Lucene.Net.Core.Tests/Util/TestOpenBitSet.cs
@@ -0,0 +1,439 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+namespace Lucene.Net.Util
+{
+    using Lucene.Net.Random;
+    using Lucene.Net.Support;
+    using System.Collections;
+
+    using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
+
+    /*
+    public class TestOpenBitSet : BaseDocIdSetTestCase<OpenBitSet>
+    {
+        public override OpenBitSet CopyOf(BitArray bs, int length)
+        {
+            OpenBitSet set = new OpenBitSet(length);
+            for (int doc = bs.NextSetBit(0); doc != -1; doc = bs.NextSetBit(doc + 1))
+            {
+                set.Set(doc);
+            }
+            return set;
+        }
+
+        internal virtual void DoGet(BitArray a, OpenBitSet b)
+        {
+            int max = a.Count;
+            for (int i = 0; i < max; i++)
+            {
+                if (a.Get(i) != b.Get(i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+                if (a.Get(i) != b.Get((long)i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+            }
+        }
+
+        internal virtual void DoGetFast(BitArray a, OpenBitSet b, int max)
+        {
+            for (int i = 0; i < max; i++)
+            {
+                if (a.Get(i) != b.FastGet(i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+                if (a.Get(i) != b.FastGet((long)i))
+                {
+                    Assert.Fail("mismatch: BitSet=[" + i + "]=" + a.Get(i));
+                }
+            }
+        }
+
+        internal virtual void DoNextSetBit(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = b.NextSetBit(bb + 1);
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoNextSetBitLong(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = (int)b.NextSetBit((long)(bb + 1));
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoPrevSetBit(BitArray a, OpenBitSet b)
+        {
+            int aa = a.Count + Random().Next(100);
+            int bb = aa;
+            do
+            {
+                // aa = a.PrevSetBit(aa-1);
+                aa--;
+                while ((aa >= 0) && (!a.Get(aa)))
+                {
+                    aa--;
+                }
+                bb = b.PrevSetBit(bb - 1);
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoPrevSetBitLong(BitArray a, OpenBitSet b)
+        {
+            int aa = a.Count + Random().Next(100);
+            int bb = aa;
+            do
+            {
+                // aa = a.PrevSetBit(aa-1);
+                aa--;
+                while ((aa >= 0) && (!a.Get(aa)))
+                {
+                    aa--;
+                }
+                bb = (int)b.PrevSetBit((long)(bb - 1));
+                Assert.AreEqual(aa, bb);
+            } while (aa >= 0);
+        }
+
+        // test interleaving different OpenBitSetIterator.Next()/skipTo()
+        internal virtual void DoIterate(BitArray a, OpenBitSet b, int mode)
+        {
+            if (mode == 1)
+            {
+                DoIterate1(a, b);
+            }
+            if (mode == 2)
+            {
+                DoIterate2(a, b);
+            }
+        }
+
+        internal virtual void DoIterate1(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            OpenBitSetIterator iterator = new OpenBitSetIterator(b);
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = Random().NextBoolean() ? iterator.NextDoc() : iterator.Advance(bb + 1);
+                Assert.AreEqual(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoIterate2(BitArray a, OpenBitSet b)
+        {
+            int aa = -1, bb = -1;
+            OpenBitSetIterator iterator = new OpenBitSetIterator(b);
+            do
+            {
+                aa = a.NextSetBit(aa + 1);
+                bb = Random().NextBoolean() ? iterator.NextDoc() : iterator.Advance(bb + 1);
+                Assert.AreEqual(aa == -1 ? DocIdSetIterator.NO_MORE_DOCS : aa, bb);
+            } while (aa >= 0);
+        }
+
+        internal virtual void DoRandomSets(int maxSize, int iter, int mode)
+        {
+            BitArray a0 = null;
+            OpenBitSet b0 = null;
+
+            for (int i = 0; i < iter; i++)
+            {
+                int sz = Random().Next(maxSize);
+                BitArray a = new BitArray(sz);
+                OpenBitSet b = new OpenBitSet(sz);
+
+                // test the various ways of setting bits
+                if (sz > 0)
+                {
+                    int nOper = Random().Next(sz);
+                    for (int j = 0; j < nOper; j++)
+                    {
+                        int idx;
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, true);
+                        b.FastSet(idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, true);
+                        b.FastSet((long)idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, false);
+                        b.FastClear(idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, false);
+                        b.FastClear((long)idx);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, !a.Get(idx));
+                        b.FastFlip(idx);
+
+                        bool val = b.FlipAndGet(idx);
+                        bool val2 = b.FlipAndGet(idx);
+                        Assert.IsTrue(val != val2);
+
+                        idx = Random().Next(sz);
+                        a.Set(idx, !a.Get(idx));
+                        b.FastFlip((long)idx);
+
+                        val = b.FlipAndGet((long)idx);
+                        val2 = b.FlipAndGet((long)idx);
+                        Assert.IsTrue(val != val2);
+
+                        val = b.GetAndSet(idx);
+                        Assert.IsTrue(val2 == val);
+                        Assert.IsTrue(b.Get(idx));
+
+                        if (!val)
+                        {
+                            b.FastClear(idx);
+                        }
+                        Assert.IsTrue(b.Get(idx) == val);
+                    }
+                }
+
+                // test that the various ways of accessing the bits are equivalent
+                DoGet(a, b);
+                DoGetFast(a, b, sz);
+
+                // test ranges, including possible extension
+                int fromIndex, toIndex;
+                fromIndex = Random().Next(sz + 80);
+                toIndex = fromIndex + Random().Next((sz >> 1) + 1);
+                BitArray aa = (BitArray)a.Clone();
+                aa.Flip(fromIndex, toIndex);
+                OpenBitSet bb = (OpenBitSet)b.Clone();
+                bb.Flip(fromIndex, toIndex);
+
+                DoIterate(aa, bb, mode); // a problem here is from flip or doIterate
+
+                fromIndex = Random().Next(sz + 80);
+                toIndex = fromIndex + Random().Next((sz >> 1) + 1);
+                aa = (BitArray)a.Clone();
+                aa.Clear(fromIndex, toIndex);
+                bb = (OpenBitSet)b.Clone();
+                bb.Clear(fromIndex, toIndex);
+
+                DoNextSetBit(aa, bb); // a problem here is from clear() or nextSetBit
+                DoNextSetBitLong(aa, bb);
+
+                DoPrevSetBit(aa, bb);
+                DoPrevSetBitLong(aa, bb);
+
+                fromIndex = Random().Next(sz + 80);
+                toIndex = fromIndex + Random().Next((sz >> 1) + 1);
+                aa = (BitArray)a.Clone();
+                aa.Set(fromIndex, toIndex);
+                bb = (OpenBitSet)b.Clone();
+                bb.Set(fromIndex, toIndex);
+
+                DoNextSetBit(aa, bb); // a problem here is from set() or nextSetBit
+                DoNextSetBitLong(aa, bb);
+
+                DoPrevSetBit(aa, bb);
+                DoPrevSetBitLong(aa, bb);
+
+                if (a0 != null)
+                {
+                    Assert.AreEqual(a.Equals(a0), b.Equals(b0));
+
+                    Assert.AreEqual(a.Cardinality(), b.Cardinality());
+
+                    BitArray a_and = (BitArray)a.Clone();
+                    a_and = a_and.And(a0);
+                    BitArray a_or = (BitArray)a.Clone();
+                    a_or = a_or.Or(a0);
+                    BitArray a_xor = (BitArray)a.Clone();
+                    a_xor = a_xor.Xor(a0);
+                    BitArray a_andn = (BitArray)a.Clone();
+                    a_andn.AndNot(a0);
+
+                    OpenBitSet b_and = (OpenBitSet)b.Clone();
+                    Assert.AreEqual(b, b_and);
+                    b_and.And(b0);
+                    OpenBitSet b_or = (OpenBitSet)b.Clone();
+                    b_or.Or(b0);
+                    OpenBitSet b_xor = (OpenBitSet)b.Clone();
+                    b_xor.Xor(b0);
+                    OpenBitSet b_andn = (OpenBitSet)b.Clone();
+                    b_andn.AndNot(b0);
+
+                    DoIterate(a_and, b_and, mode);
+                    DoIterate(a_or, b_or, mode);
+                    DoIterate(a_xor, b_xor, mode);
+                    DoIterate(a_andn, b_andn, mode);
+
+                    Assert.AreEqual(a_and.Cardinality(), b_and.Cardinality());
+                    Assert.AreEqual(a_or.Cardinality(), b_or.Cardinality());
+                    Assert.AreEqual(a_xor.Cardinality(), b_xor.Cardinality());
+                    Assert.AreEqual(a_andn.Cardinality(), b_andn.Cardinality());
+
+                    // test non-mutating popcounts
+                    Assert.AreEqual(b_and.Cardinality(), OpenBitSet.IntersectionCount(b, b0));
+                    Assert.AreEqual(b_or.Cardinality(), OpenBitSet.UnionCount(b, b0));
+                    Assert.AreEqual(b_xor.Cardinality(), OpenBitSet.XorCount(b, b0));
+                    Assert.AreEqual(b_andn.Cardinality(), OpenBitSet.AndNotCount(b, b0));
+                }
+
+                a0 = a;
+                b0 = b;
+            }
+        }
+
+        // large enough to flush obvious bugs, small enough to run in <.5 sec as part of a
+        // larger testsuite.
+        [Test]
+        public virtual void TestSmall()
+        {
+            DoRandomSets(AtLeast(1200), AtLeast(1000), 1);
+            DoRandomSets(AtLeast(1200), AtLeast(1000), 2);
+        }
+
+        // uncomment to run a bigger test (~2 minutes).
+        /*
+        public void TestBig() {
+          doRandomSets(2000,200000, 1);
+          doRandomSets(2000,200000, 2);
+        }
+        */
+
+        /*
+
+        [Test]
+        public virtual void TestEquals()
+        {
+            OpenBitSet b1 = new OpenBitSet(1111);
+            OpenBitSet b2 = new OpenBitSet(2222);
+            Assert.IsTrue(b1.Equals(b2));
+            Assert.IsTrue(b2.Equals(b1));
+            b1.Set(10);
+            Assert.IsFalse(b1.Equals(b2));
+            Assert.IsFalse(b2.Equals(b1));
+            b2.Set(10);
+            Assert.IsTrue(b1.Equals(b2));
+            Assert.IsTrue(b2.Equals(b1));
+            b2.Set(2221);
+            Assert.IsFalse(b1.Equals(b2));
+            Assert.IsFalse(b2.Equals(b1));
+            b1.Set(2221);
+            Assert.IsTrue(b1.Equals(b2));
+            Assert.IsTrue(b2.Equals(b1));
+
+            // try different type of object
+            Assert.IsFalse(b1.Equals(new object()));
+        }
+
+        [Test]
+        public virtual void TestHashCodeEquals()
+        {
+            OpenBitSet bs1 = new OpenBitSet(200);
+            OpenBitSet bs2 = new OpenBitSet(64);
+            bs1.Set(3);
+            bs2.Set(3);
+            Assert.AreEqual(bs1, bs2);
+            Assert.AreEqual(bs1.GetHashCode(), bs2.GetHashCode());
+        }
+
+        private OpenBitSet MakeOpenBitSet(int[] a)
+        {
+            OpenBitSet bs = new OpenBitSet();
+            foreach (int e in a)
+            {
+                bs.Set(e);
+            }
+            return bs;
+        }
+
+        private BitArray MakeBitSet(int[] a)
+        {
+            BitArray bs = new BitArray(a.Length);
+            foreach (int e in a)
+            {
+                bs.Set(e, true);
+            }
+            return bs;
+        }
+
+        private void CheckPrevSetBitArray(int[] a)
+        {
+            OpenBitSet obs = MakeOpenBitSet(a);
+            BitArray bs = MakeBitSet(a);
+            DoPrevSetBit(bs, obs);
+        }
+
+        [Test]
+        public virtual void TestPrevSetBit()
+        {
+            CheckPrevSetBitArray(new int[] { });
+            CheckPrevSetBitArray(new int[] { 0 });
+            CheckPrevSetBitArray(new int[] { 0, 2 });
+        }
+
+        [Test]
+        public virtual void TestEnsureCapacity()
+        {
+            OpenBitSet bits = new OpenBitSet(1);
+            int bit = Random().Next(100) + 10;
+            bits.EnsureCapacity(bit); // make room for more bits
+            bits.FastSet(bit - 1);
+            Assert.IsTrue(bits.FastGet(bit - 1));
+            bits.EnsureCapacity(bit + 1);
+            bits.FastSet(bit);
+            Assert.IsTrue(bits.FastGet(bit));
+            bits.EnsureCapacity(3); // should not change numBits nor grow the array
+            bits.FastSet(3);
+            Assert.IsTrue(bits.FastGet(3));
+            bits.FastSet(bit - 1);
+            Assert.IsTrue(bits.FastGet(bit - 1));
+
+            // test ensureCapacityWords
+            int numWords = Random().Next(10) + 2; // make sure we grow the array (at least 128 bits)
+            bits.EnsureCapacityWords(numWords);
+            bit = TestUtil.NextInt(Random(), 127, (numWords << 6) - 1); // pick a bit >= to 128, but still within range
+            bits.FastSet(bit);
+            Assert.IsTrue(bits.FastGet(bit));
+            bits.FastClear(bit);
+            Assert.IsFalse(bits.FastGet(bit));
+            bits.FastFlip(bit);
+            Assert.IsTrue(bits.FastGet(bit));
+            bits.EnsureCapacityWords(2); // should not change numBits nor grow the array
+            bits.FastSet(3);
+            Assert.IsTrue(bits.FastGet(3));
+            bits.FastSet(bit - 1);
+            Assert.IsTrue(bits.FastGet(bit - 1));
+        }
+    }*/
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs b/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
index ee18cac..e6bf2f0 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestWeakIdentityMap.cs
@@ -31,7 +31,7 @@ namespace Lucene.Net.Util
         [Test]
         public async virtual void TestSimpleHashMap()
         {
-            var map = WeakIdentityMap<string, string>.NewHashMap(this.Random.NextBoolean());
+            var map = WeakIdentityMap<string, string>.NewHashMap(Random.NextBoolean());
             // we keep strong references to the keys,
             // so WeakIdentityMap will not forget about them:
             string key1 = "foo",
@@ -190,7 +190,7 @@ namespace Lucene.Net.Util
             // don't make threadCount and keyCount random, otherwise easily OOMs or fails otherwise:
             const int threadCount = 8, keyCount = 1024;
             var tasks = new List<Task>();
-            var map = WeakIdentityMap<object, int?>.NewConcurrentHashMap(this.Random.NextBoolean());
+            var map = WeakIdentityMap<object, int?>.NewConcurrentHashMap(Random.NextBoolean());
             // we keep strong references to the keys,
             // so WeakIdentityMap will not forget about them:
             var keys = new AtomicReferenceArray<object>(keyCount);
@@ -201,7 +201,7 @@ namespace Lucene.Net.Util
 
             for (var t = 0; t < threadCount; t++)
             {
-                var rnd = new Random(this.Random.Next());
+                var rnd = new Random(Random.Next());
                 tasks.Add(Task.Run(() =>
                 {
                        
@@ -272,7 +272,7 @@ namespace Lucene.Net.Util
             public void Run()
             {
 // ReSharper disable once InvokeAsExtensionMethod
-                var count =  this.outerInstance.AtLeast(10000);
+                var count =  AtLeast(10000);
                 for (var i = 0; i < count; i++)
                 {
                     var j = rnd.Next(keyCount);

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj b/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
new file mode 100644
index 0000000..f1114ce
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Lucene.Net.Java.Tests.csproj
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{06FE85CA-11BA-4E69-81B4-1FA6E031E0B7}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Lucene.Net.Java</RootNamespace>
+    <AssemblyName>Lucene.Net.Java.Tests</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <RestorePackages>true</RestorePackages>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- A reference to the entire .NET Framework is automatically included -->
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Util\InsertionSortTests.cs" />
+    <Compile Include="Util\SortTestClass.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="xunit.abstractions">
+      <HintPath>..\..\packages\xunit.abstractions.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.abstractions.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.assert">
+      <HintPath>..\..\packages\xunit.assert.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.core">
+      <HintPath>..\..\packages\xunit.core.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\src\Lucene.Net.Java\Lucene.Net.Java.csproj">
+      <Project>{4ad3fe35-aa0a-4c3c-a043-12711625df74}</Project>
+      <Name>Lucene.Net.Java</Name>
+    </ProjectReference>
+    <ProjectReference Include="..\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj">
+      <Project>{438b8450-e93a-425f-9a9b-11d02e8896d5}</Project>
+      <Name>Lucene.Net.TestFramework.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
+    <PropertyGroup>
+      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
+    </PropertyGroup>
+    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
+  </Target>
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs b/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..879cf92
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Lucene.Net.Java.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Lucene.Net.Java.Tests")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs b/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs
new file mode 100644
index 0000000..e2e798d
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Util/InsertionSortTests.cs
@@ -0,0 +1,71 @@
+
+namespace Lucene.Net.Java.Util
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using global::Java.Util;
+
+    public class InsertionSortTests : SortTestClass
+    {
+
+        [Test]
+        public void TestSort()
+        {
+            var length = Random.Next(20);
+            var array = new int[length];
+            Arrays.Fill(array, () => Random.Next());
+
+            InsertionSort.Sort(array);
+            
+            this.AssertSort(array);
+
+            Throws<ArgumentNullException>(() =>
+            {
+                int[] test = null;
+                
+                // ReSharper disable ExpressionIsAlwaysNull
+                InsertionSort.Sort(test);
+            });
+        }
+
+        [Test]
+        public void TestSortWithSlice()
+        {
+            var offset = Random.Next(5, 10);
+            var length = Random.Next(30, 35);
+            var list = new char[length];
+
+            Ok(list.Length > offset);
+            Arrays.Fill(list, () => (char) Random.Next(97, 122));
+           
+            var copy = list.ToList();
+
+            InsertionSort.Sort(list, offset, length - offset - 5);
+ 
+            this.AssertSort(list, offset, length - offset - 5);
+            
+            // ensure what was outside of the slice was not sorted
+            for (var i = 0; i < offset; i++)
+            {
+                Equal(list[i], copy[i]);
+            }
+
+            for (var i = length - 5; i < length; i++)
+            {
+                Equal(list[i], copy[i]);
+            }
+
+            var listB = new char[10];
+
+            // verify exceptions
+            Throws<ArgumentNullException>(() => InsertionSort.Sort((IList<int>)null, -1, 10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, -1, 10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, 0, -10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, 10, 10));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, 0, 11));
+            Throws<ArgumentOutOfRangeException>(() => InsertionSort.Sort(listB, -9, 5));
+
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs b/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs
new file mode 100644
index 0000000..6078100
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/Util/SortTestClass.cs
@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.Java.Util
+{
+    public class SortTestClass : TestClass
+    {
+
+        protected void AssertSort<T>(IList<T> list, int start = 0, int count = -1) where T : IComparable<T>
+        {
+            if(count == -1)
+                count = list.Count;
+
+            count.Times(i =>
+            {
+                if (i < start)
+                   return;
+                
+
+                var current = list[i];
+
+                if (i > start)
+                {
+                    var previous = list[i - 1];
+                    Ok(previous.CompareTo(current) <= 0, "previous value, {0}, should be less than or equal to {1} at index {2}", previous, current, i);
+                }
+
+                if (i < (count - 2))
+                {
+                    var next = list[i + 1];
+                    Ok(next.CompareTo(current) >= 0, "next value, {0}, should be greater than or equal to {1} at index {2}", next, current, i);
+                }
+            });
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/packages.config
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/packages.config b/test/Lucene.Net.Java.Tests/packages.config
new file mode 100644
index 0000000..b71d5c9
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/packages.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<packages>
+  <package id="xunit" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.abstractions" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.assert" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.core" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.Java.Tests/project.json
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Java.Tests/project.json b/test/Lucene.Net.Java.Tests/project.json
new file mode 100644
index 0000000..27f9bf3
--- /dev/null
+++ b/test/Lucene.Net.Java.Tests/project.json
@@ -0,0 +1,37 @@
+{
+    "licenses": ["apache 2.0"],
+    "version": "5.0.0.0",
+    "compilationOptions": {
+        "warningsAsErrors": false,
+        "define": ["XUNIT"]
+    },
+    "sources": ["../src"],
+    "code": "**/*.cs",
+    "commands": {
+        "test": "Xunit.KRunner"
+    },
+    
+    
+    "dependencies": {
+        "Lucene.Net.Java":  "",
+        "Lucene.Net.TestFramework.Core": "",
+        "Xunit.KRunner": "1.0.0-*",
+        "System.Console": "4.0.0.0"
+    },
+
+    "configurations" : {
+        "net451": {},
+        "net45" : { 
+            "dependencies": {
+            }
+        },
+        "k10" : { 
+            "dependencies": {
+                "System.Runtime": "4.0.20.0",
+                "System.Diagnostics.Debug": "4.0.10.0"
+              
+            }
+            
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs b/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs
new file mode 100644
index 0000000..ce21ef4
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/CategoryAttribute.cs
@@ -0,0 +1,44 @@
+
+
+
+namespace Lucene.Net
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using Xunit.Abstractions;
+    using Xunit.Sdk;
+
+    [TraitDiscoverer("CategoryDiscoverer", "TraitExtensibility")]
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class CategoryAttribute : System.Attribute, Xunit.Sdk.ITraitAttribute
+    {
+        public string Name { get; private set; }
+
+        public CategoryAttribute(string category)
+        {
+            this.Name = category;
+        }
+    }
+
+    /// <summary>
+    /// This class discovers all of the tests and test classes that have
+    /// applied the Category attribute
+    /// </summary>
+    public class CategoryDiscoverer : ITraitDiscoverer
+    {
+        /// <summary>
+        /// Gets the trait values from the Category attribute.
+        /// </summary>
+        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
+        /// <returns>The trait values.</returns>
+        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
+        {
+            var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
+
+            yield return new KeyValuePair<string, string>("Category", ctorArgs[0].ToString());
+           
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs b/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs
new file mode 100644
index 0000000..e4a7f95
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/ExtensionMethods.cs
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net
+{
+    using System;
+    /// <summary>
+    /// Extension methods to make writing tests easier.
+    /// </summary>
+    public static class ExtensionMethods
+    {
+        /// <summary>
+        /// Performs a loop for the specified number of times. 
+        /// </summary>
+        /// <param name="value">The number of times to perform a loop.</param>
+        /// <param name="invoke">The code that should be ivnoked for each iteration.</param>
+        public static void Times(this int value, Action<int> invoke)
+        {
+            for(var i = 0; i < value; i++)
+            {
+                invoke(i);
+            }
+        }
+
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj b/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
new file mode 100644
index 0000000..3e66773
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/Lucene.Net.TestFramework.Core.csproj
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{438B8450-E93A-425F-9A9B-11D02E8896D5}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Lucene.Net</RootNamespace>
+    <AssemblyName>Lucene.Net.TestFramework.Core</AssemblyName>
+    <DefaultLanguage>en-US</DefaultLanguage>
+    <FileAlignment>512</FileAlignment>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>TRACE;DEBUG;XUNIT</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <!-- A reference to the entire .NET Framework is automatically included -->
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CategoryAttribute.cs" />
+    <Compile Include="ExtensionMethods.cs" />
+    <Compile Include="NightlyAttribute.cs" />
+    <Compile Include="PerformanceAttribute.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="RandomExtensions.cs" />
+    <Compile Include="Settings.cs" />
+    <Compile Include="TestAttribute.cs" />
+    <Compile Include="TestClass.cs" />
+    <Compile Include="TicketAttribute.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <Reference Include="xunit.abstractions">
+      <HintPath>..\..\packages\xunit.abstractions.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.abstractions.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.assert">
+      <HintPath>..\..\packages\xunit.assert.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monoandroid+monotouch10\xunit.assert.dll</HintPath>
+    </Reference>
+    <Reference Include="xunit.core">
+      <HintPath>..\..\packages\xunit.core.2.0.0-beta-build2700\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid\xunit.core.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs b/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs
new file mode 100644
index 0000000..0eba11d
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/NightlyAttribute.cs
@@ -0,0 +1,18 @@
+
+
+
+namespace Lucene.Net
+{
+    using System;
+
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class NightlyAttribute : CategoryAttribute
+    {
+
+        public NightlyAttribute()
+            : base("Nightly")
+        {
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs b/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs
new file mode 100644
index 0000000..f854a55
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/PerformanceAttribute.cs
@@ -0,0 +1,17 @@
+
+
+namespace Lucene.Net
+{
+    using System;
+
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class PerformanceAttribute : CategoryAttribute
+    {
+
+        public PerformanceAttribute()
+            : base("Performance")
+        {
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs b/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..d561817
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/Properties/AssemblyInfo.cs
@@ -0,0 +1,30 @@
+using System.Resources;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Lucene.Net.TestFramework.Core")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Lucene.Net.TestFramework.Core")]
+[assembly: AssemblyCopyright("Copyright ©  2014")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+[assembly: NeutralResourcesLanguage("en")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs b/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs
new file mode 100644
index 0000000..bff600e
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/RandomExtensions.cs
@@ -0,0 +1,30 @@
+
+
+
+namespace Lucene.Net
+{
+    using System;
+
+    public static class RandomExtensions
+    {
+
+        public static int AtLeast(this Random random, int minimumValue)
+        {
+            minimumValue = Settings.Nightly ? (2*minimumValue) : minimumValue;
+            minimumValue = minimumValue*Settings.RandomMultiplier;
+
+            // Even with the current short number of tests,
+            // some of tests take too long to complete due to the
+            // number of loops and computations created by using
+            // high numbers with AtLeast. This is to cut
+            // down on local development test time.
+            if (!Settings.Nightly && minimumValue > 100)
+            {
+                minimumValue = 100;
+            }
+
+            var max = minimumValue + (minimumValue / 2);
+            return random.Next(minimumValue, max);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/Settings.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/Settings.cs b/test/Lucene.Net.TestFramework.Core/Settings.cs
new file mode 100644
index 0000000..e7a3382
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/Settings.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net
+{
+    public static class Settings
+    {
+
+        public static bool Nightly { get; set; }
+
+        public static int RandomMultiplier { get; set; }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/TestAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/TestAttribute.cs b/test/Lucene.Net.TestFramework.Core/TestAttribute.cs
new file mode 100644
index 0000000..5f8b3c5
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/TestAttribute.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net
+{
+    /// <summary>
+    /// Summary description for TestAttribute
+    /// </summary>
+    public class TestAttribute : Xunit.FactAttribute
+    {
+
+        public string JavaMethodName { get; set; }
+
+        public TestAttribute(string displayName, string javaMethodName = null, string skip = null)
+        {
+            
+            // ReSharper disable DoNotCallOverridableMethodsInConstructor
+            this.DisplayName = displayName;
+            this.Skip = skip;
+            this.JavaMethodName = javaMethodName;
+        }
+
+        public TestAttribute()
+        {
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/TestClass.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/TestClass.cs b/test/Lucene.Net.TestFramework.Core/TestClass.cs
new file mode 100644
index 0000000..df433a0
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/TestClass.cs
@@ -0,0 +1,226 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Xunit;
+
+namespace Lucene.Net
+{
+    using System.Diagnostics;
+    using System.Threading;
+
+    public class TestClass
+    {
+        private static readonly ThreadLocal<System.Random> random;
+
+
+        public static Random Random
+        {
+            get { return random.Value; }
+        }
+
+        static TestClass()
+        {
+            random = new ThreadLocal<System.Random>(() => 
+                new System.Random((int) DateTime.Now.Ticks & 0x0000FFFF));
+        }
+
+        public class LuceneAssertionException : Exception
+        {
+            //
+            // For guidelines regarding the creation of new exception types, see
+            //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
+            // and
+            //    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
+            //
+
+            public LuceneAssertionException()
+            {
+            }
+
+            public LuceneAssertionException(string message) : base(message)
+            {
+            }
+
+            public LuceneAssertionException(string message, Exception inner) : base(message, inner)
+            {
+            }
+
+#if NET45
+            protected LuceneAssertionException(
+                System.Runtime.Serialization.SerializationInfo info,
+                StreamingContext context) : base(info, context)
+            {
+            }
+#endif
+        }
+
+#if XUNIT
+
+        [DebuggerHidden]
+        public static void Null(object value, string message = null, params  object[] args)
+        {
+            try
+            {
+                Assert.Null(value);
+            }
+            catch (Exception ex)
+            {
+                var msg = message ?? "The value must be null.";
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        public static void NotNull(object value, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.NotNull(value);
+            }
+            catch (Exception ex)
+            {
+                var msg = message ?? "The value must not be null.";
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        /// <summary>
+        /// Asserts that two object are the same.
+        /// </summary>
+        /// <param name="expected">The expected value.</param>
+        /// <param name="actual">The actual value.</param>
+        [DebuggerHidden]
+        public static void Same(object expected, object actual)
+        {
+            Assert.Same(expected, actual);
+        }
+
+        /// <summary>
+        /// Assert that two objects are not the same.
+        /// </summary>
+        /// <param name="expected">The expected value.</param>
+        /// <param name="actual">The actual value.</param>
+        [DebuggerHidden]
+        public static void NotSame(object expected, object actual)
+        {
+            Assert.NotSame(expected, actual);
+        }
+
+        [DebuggerHidden]
+        public static void Equal(string expected, string actual, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.Equal(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        [DebuggerHidden]
+        public static void Equal<T>(T expected, T actual, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.Equal(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        [DebuggerHidden]
+        public static void Equal<T>(IEnumerable<T> expected, IEnumerable<T> actual, string message= null, params object[] args)
+        {
+            try
+            {
+                Assert.Equal(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+        }
+
+        [DebuggerHidden]
+        public static void NotEqual<T>(T expected, T actual, string message = null, params object[] args)
+        {
+            try
+            {
+                Assert.NotEqual(expected, actual);
+            }
+            catch (Exception ex)
+            {
+                if (message == null)
+                    throw;
+
+                var msg = message;
+                if (args != null && args.Length > 0)
+                    msg = string.Format(msg, args);
+
+                throw new LuceneAssertionException(msg, ex);
+            }
+           
+        }
+
+
+        [DebuggerHidden]
+        public static void Ok(bool condition, string message = null, params object[] values)
+        {
+            if (!string.IsNullOrWhiteSpace(message))
+            {
+                var exceptionMessage = message;
+
+                if(values != null && values.Length > 0)
+                {
+                    exceptionMessage = String.Format(exceptionMessage, values);
+                }
+
+                Assert.True(condition, exceptionMessage);
+            }
+            else 
+            {
+                Assert.True(condition);    
+            }
+        }
+
+        [DebuggerHidden]
+        public static T Throws<T>(Action code) where T : Exception
+        {
+            return Assert.Throws<T>(code);
+        }
+        
+        #endif
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs b/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs
new file mode 100644
index 0000000..80e973b
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/TicketAttribute.cs
@@ -0,0 +1,52 @@
+
+
+namespace Lucene.Net
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using Xunit.Abstractions;
+    using Xunit.Sdk;
+
+    [TraitDiscoverer("TicketDiscoverer", "TraitExtensibility")]
+    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
+    public class TicketAttribute : System.Attribute, Xunit.Sdk.ITraitAttribute
+    {
+        public string Ticket { get; private set; }
+
+        public string Description { get; private set; }
+
+        public TicketAttribute(string ticket, string description)
+        {
+            this.Ticket = ticket;
+            this.Description = description;
+        }
+    }
+
+
+    /// <summary>
+    /// This class discovers all of the tests and test classes that have
+    /// applied the Category attribute
+    /// </summary>
+    public class TicketDiscoverer : ITraitDiscoverer
+    {
+        /// <summary>
+        /// Gets the trait values from the Category attribute.
+        /// </summary>
+        /// <param name="traitAttribute">The trait attribute containing the trait values.</param>
+        /// <returns>The trait values.</returns>
+        public IEnumerable<KeyValuePair<string, string>> GetTraits(IAttributeInfo traitAttribute)
+        {
+            var ctorArgs = traitAttribute.GetConstructorArguments().ToList();
+            var message = "";
+
+            if (ctorArgs.Count > 0)
+                message = ctorArgs[1].ToString();
+
+
+            yield return new KeyValuePair<string, string>("Ticket", ctorArgs[0].ToString());
+            yield return new KeyValuePair<string, string>("Ticket Description", message);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/packages.config
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/packages.config b/test/Lucene.Net.TestFramework.Core/packages.config
new file mode 100644
index 0000000..b71d5c9
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/packages.config
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements.  See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership.  The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied.  See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<packages>
+  <package id="xunit" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.abstractions" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.assert" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+  <package id="xunit.core" version="2.0.0-beta-build2700" targetFramework="portable-net45+win+wpa81+wp80" />
+</packages>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework.Core/project.json
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework.Core/project.json b/test/Lucene.Net.TestFramework.Core/project.json
new file mode 100644
index 0000000..a6b6ae4
--- /dev/null
+++ b/test/Lucene.Net.TestFramework.Core/project.json
@@ -0,0 +1,34 @@
+{
+    "licenses": ["apache 2.0"],
+      "version": "5.0.0.0",
+    "compilationOptions": {
+        "warningsAsErrors": false,
+        "define": ["XUNIT"]
+    },
+    "sources": ["../src"],
+    "code": "**/*.cs",
+    "commands": {
+        "test": "Xunit.KRunner"
+    },
+
+    
+    "dependencies": {
+        "Xunit.KRunner": "1.0.0-*"
+    },
+
+    "configurations" : {
+        "net451": {},
+        "net45" : { 
+            "dependencies": {
+            }
+        },
+        "k10" : { 
+            "dependencies": {
+                "System.Runtime": "4.0.20.0",
+                "System.Linq": "",
+                "System.Diagnostics.Debug": "4.0.10.0",
+                "System.Threading": ""
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj b/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
index b44dcff..2714c6f 100644
--- a/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
+++ b/test/Lucene.Net.TestFramework/Lucene.Net.TestFramework.csproj
@@ -23,7 +23,7 @@
   <Import Project="..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props" Condition="Exists('..\..\packages\xunit.core.2.0.0-beta-build2700\build\portable-net45+win+wpa81+wp80\xunit.core.props')" />
   <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
   <PropertyGroup>
-    <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion>
+    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <ProjectGuid>{F0D68FEA-B118-43B6-B760-3FB75CDE766D}</ProjectGuid>
@@ -34,8 +34,8 @@
     <DefaultLanguage>en-US</DefaultLanguage>
     <FileAlignment>512</FileAlignment>
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
-    <TargetFrameworkProfile>Profile151</TargetFrameworkProfile>
-    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
     <RestorePackages>true</RestorePackages>
   </PropertyGroup>
@@ -57,12 +57,11 @@
     <WarningLevel>4</WarningLevel>
   </PropertyGroup>
   <ItemGroup>
-    <Compile Include="Util\ExtensionMethods.cs" />
+    <Compile Include="Util\BaseDocIdSetTestCase.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="Random\RandomExtensions.cs" />
     <Compile Include="Util\LuceneTestCase.cs" />
     <Compile Include="Util\RamUsageTester.cs" />
-    <Compile Include="Util\TestAttribute.cs" />
     <Compile Include="Util\TestUtil.cs" />
   </ItemGroup>
   <ItemGroup>
@@ -77,13 +76,19 @@
     </Reference>
   </ItemGroup>
   <ItemGroup>
-    <None Include="packages.config" />
+    <None Include="packages.config">
+      <SubType>Designer</SubType>
+    </None>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\..\src\Lucene.Net.Core\Lucene.Net.Core.csproj">
       <Project>{ad8901c0-209d-4132-80aa-257dbaceecb4}</Project>
       <Name>Lucene.Net.Core</Name>
     </ProjectReference>
+    <ProjectReference Include="..\Lucene.Net.TestFramework.Core\Lucene.Net.TestFramework.Core.csproj">
+      <Project>{438b8450-e93a-425f-9a9b-11d02e8896d5}</Project>
+      <Name>Lucene.Net.TestFramework.Core</Name>
+    </ProjectReference>
   </ItemGroup>
   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
   <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs b/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
index eb0112f..00cbc59 100644
--- a/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
+++ b/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
@@ -33,12 +33,7 @@ namespace Lucene.Net.Random
     {
 
 
-        public static int AtLeast(this LuceneTestCase instance, int minimumValue)
-        {
-            int min = (LuceneTestCase.TEST_NIGHTLY ? 2 * minimumValue : minimumValue) * LuceneTestCase.RANDOM_MULTIPLIER;
-            int max = min + (min / 2);
-            return instance.Random.NextBetween(min, max);
-        }
+      
 
 	    /// <summary>
 	    /// Returns an integer between the min and max value. This is compatable 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs b/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
new file mode 100644
index 0000000..0292187
--- /dev/null
+++ b/test/Lucene.Net.TestFramework/Util/BaseDocIdSetTestCase.cs
@@ -0,0 +1,226 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Lucene.Net.Util
+{
+    using Lucene.Net.Random;
+    using Lucene.Net.Support;
+    using System;
+    using System.Collections;
+    using System.Diagnostics;
+    using DocIdSet = Lucene.Net.Search.DocIdSet;
+    using DocIdSetIterator = Lucene.Net.Search.DocIdSetIterator;
+
+  
+
+    /// <summary>
+    /// Base test class for <seealso cref="DocIdSet"/>s. </summary>
+    public abstract class BaseDocIdSetTestCase<T> : LuceneTestCase
+        where T : Lucene.Net.Search.DocIdSet
+    {
+        /// <summary>
+        /// Create a copy of the given <seealso cref="BitSet"/> which has <code>length</code> bits. </summary>
+        public abstract T CopyOf(BitArray bs, int length);
+
+        /// <summary>
+        /// Create a random set which has <code>numBitsSet</code> of its <code>numBits</code> bits set. </summary>
+        protected internal BitArray RandomSet(int numberOfBits, int numberOfBitsSet)
+        {
+            Debug.Assert(numberOfBitsSet <= numberOfBits);
+            BitArray set = new BitArray(numberOfBits);
+            if (numberOfBitsSet == numberOfBits)
+            {
+                set.Set(0, numberOfBits != 0); //convert int to boolean
+            }
+            else
+            {
+                for (int i = 0; i < numberOfBitsSet; ++i)
+                {
+                    while (true)
+                    {
+                        int o = Random.Next(numberOfBits);
+                        if (!set.Get(o))
+                        {
+                            set.Set(o, true);
+                            break;
+                        }
+                    }
+                }
+            }
+            return set;
+        }
+
+        /// <summary>
+        /// Same as <seealso cref="#randomSet(int, int)"/> but given a load factor. </summary>
+        protected internal BitArray RandomSet(int numBits, float percentSet)
+        {
+            return RandomSet(numBits, (int)(percentSet * numBits));
+        }
+
+        /// <summary>
+        /// Test length=0. </summary>
+        public virtual void TestNoBit()
+        {
+            BitArray bs = new BitArray(1);
+            T copy = CopyOf(bs, 0);
+            AssertEquals(0, bs, copy);
+        }
+
+        /// <summary>
+        /// Test length=1. </summary>
+        public virtual void Test1Bit()
+        {
+            BitArray bs = new BitArray(1);
+            if (Random.NextBoolean())
+            {
+                bs.Set(0, true);
+            }
+            T copy = CopyOf(bs, 1);
+            AssertEquals(1, bs, copy);
+        }
+
+        /// <summary>
+        /// Test length=2. </summary>
+        public virtual void Test2Bits()
+        {
+            BitArray bs = new BitArray(2);
+            if (Random.NextBoolean())
+            {
+                bs.Set(0, true);
+            }
+            if (Random.NextBoolean())
+            {
+                bs.Set(1, true);
+            }
+            T copy = CopyOf(bs, 2);
+            AssertEquals(2, bs, copy);
+        }
+
+        /// <summary>
+        /// Compare the content of the set against a <seealso cref="BitSet"/>. </summary>
+        public virtual void TestAgainstBitSet()
+        {
+            int numBits = Random.NextBetween(100, 1 << 20);
+            // test various random sets with various load factors
+            foreach (float percentSet in new float[] { 0f, 0.0001f, (float)Random.NextDouble() / 2, 0.9f, 1f })
+            {
+                BitArray set = RandomSet(numBits, percentSet);
+                T copy = CopyOf(set, numBits);
+                AssertEquals(numBits, set, copy);
+            }
+            // test one doc
+            BitArray set_ = new BitArray(numBits);
+            set_.Set(0, true); // 0 first
+            T copy_ = CopyOf(set_, numBits);
+            AssertEquals(numBits, set_, copy_);
+            set_.Set(0, false);
+            set_.Set(Random.Next(numBits), true);
+            copy_ = CopyOf(set_, numBits); // then random index
+            AssertEquals(numBits, set_, copy_);
+            // test regular increments
+            for (int inc = 2; inc < 1000; inc += Random.NextBetween(1, 100))
+            {
+                set_ = new BitArray(numBits);
+                for (int d = Random.Next(10); d < numBits; d += inc)
+                {
+                    set_.Set(d, true);
+                }
+                copy_ = CopyOf(set_, numBits);
+                AssertEquals(numBits, set_, copy_);
+            }
+        }
+
+        /// <summary>
+        /// Assert that the content of the <seealso cref="DocIdSet"/> is the same as the content of the <seealso cref="BitSet"/>. </summary>
+        public virtual void AssertEquals(int numBits, BitArray ds1, T ds2)
+        {
+            /*
+            // nextDoc
+            DocIdSetIterator it2 = ds2.GetIterator();
+            if (it2 == null)
+            {
+                Equal(-1, ds1.NextSetBit(0));
+            }
+            else
+            {
+                Equal(-1, it2.DocId);
+                for (int doc = ds1.NextSetBit(0); doc != -1; doc = ds1.NextSetBit(doc + 1))
+                {
+                    Equal(doc, it2.NextDoc());
+                    Equal(doc, it2.DocId);
+                }
+                Equal(DocIdSetIterator.NO_MORE_DOCS, it2.NextDoc());
+                Equal(DocIdSetIterator.NO_MORE_DOCS, it2.DocId);
+            }
+
+            // nextDoc / advance
+            it2 = ds2.GetIterator();
+            if (it2 == null)
+            {
+                Equal(-1, ds1.NextSetBit(0));
+            }
+            else
+            {
+                for (int doc = -1; doc != DocIdSetIterator.NO_MORE_DOCS; )
+                {
+                    if (Random.NextBoolean())
+                    {
+                        doc = ds1.NextSetBit(doc + 1);
+                        if (doc == -1)
+                        {
+                            doc = DocIdSetIterator.NO_MORE_DOCS;
+                        }
+                        Equal(doc, it2.NextDoc());
+                        Equal(doc, it2.DocId);
+                    }
+                    else
+                    {
+                        int target = doc + 1 + Random.Next(Random.NextBoolean() ? 64 : Math.Max(numBits / 8, 1));
+                        doc = ds1.NextSetBit(target);
+                        if (doc == -1)
+                        {
+                            doc = DocIdSetIterator.NO_MORE_DOCS;
+                        }
+                        Equal(doc, it2.Advance(target));
+                        Equal(doc, it2.DocId);
+                    }
+                }
+            }
+
+            // bits()
+            var bits = ds2.GetBits();
+            if (bits != null)
+            {
+                // test consistency between bits and iterator
+                it2 = ds2.GetIterator();
+                for (int previousDoc = -1, doc = it2.NextDoc(); ; previousDoc = doc, doc = it2.NextDoc())
+                {
+                    int max = doc == DocIdSetIterator.NO_MORE_DOCS ? bits.Length : doc;
+                    for (int i = previousDoc + 1; i < max; ++i)
+                    {
+                        Equal(false, bits[i]);
+                    }
+                    if (doc == DocIdSetIterator.NO_MORE_DOCS)
+                    {
+                        break;
+                    }
+                    Equal(true, bits[doc]);
+                }
+            }*/
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/4b4d4d93/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs b/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
deleted file mode 100644
index 94cac09..0000000
--- a/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-namespace Lucene.Net.Util
-{
-    using System;
-    using Lucene.Net.Random;
-    /// <summary>
-    /// Extension methods to make writing tests easier.
-    /// </summary>
-    public static class ExtensionMethods
-    {
-        /// <summary>
-        /// Performs a loop for the specified number of times. 
-        /// </summary>
-        /// <param name="value">The number of times to perform a loop.</param>
-        /// <param name="invoke">The code that should be ivnoked for each iteration.</param>
-        public static void Times(this int value, Action<int> invoke)
-        {
-            for(var i = 0; i < value; i++)
-            {
-                invoke(i);
-            }
-        }
-
-    }
-}