lucenenet-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mhern...@apache.org
Subject [3/5] git commit: adding CharsRefBuilder and tests for CharsRef. Ensuring all current *.cs files have license in header. Adding custom enumerator for CharsRef and BytesRef.
Date Thu, 14 Aug 2014 01:22:25 GMT
adding CharsRefBuilder and tests for CharsRef.  Ensuring all current *.cs files have license in header.  Adding custom enumerator for CharsRef and BytesRef.


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

Branch: refs/heads/pcl
Commit: fde20a6f50eb80cb3e301624208250a17d674e1a
Parents: 626809a
Author: Michael Herndon <mherndon@michaelherndon.com>
Authored: Wed Aug 13 18:20:53 2014 -0400
Committer: Michael Herndon <mherndon@michaelherndon.com>
Committed: Wed Aug 13 18:20:53 2014 -0400

----------------------------------------------------------------------
 src/Lucene.Net.Core/Check.cs                    |  30 +--
 src/Lucene.Net.Core/Lucene.Net.Core.csproj      |   1 +
 .../Support/DeepCloneNotSupportedException.cs   |  30 +--
 src/Lucene.Net.Core/Support/EnumUtil.cs         |  30 +--
 src/Lucene.Net.Core/Support/HashMap.cs          |  32 +--
 src/Lucene.Net.Core/Support/ICharSequence.cs    |  21 +-
 src/Lucene.Net.Core/Support/ICloneable.cs       |  30 +--
 .../Support/NumberExtensionMethods.cs           |  45 ++--
 .../Support/SerializableAttribute.cs            |  17 +-
 .../ShallowCloneNotSupportedException.cs        |  30 +--
 .../Support/StringExtensionMethods.cs           |  30 +--
 .../Support/SupportExtensionMethods.cs          |  52 ++--
 .../Util/ArrayInPlaceMergeSorter`.cs            |   6 +-
 src/Lucene.Net.Core/Util/ArrayUtil.cs           |  21 +-
 src/Lucene.Net.Core/Util/BitUtil.cs             |   2 +-
 src/Lucene.Net.Core/Util/Bits.cs                |   1 -
 src/Lucene.Net.Core/Util/BroadWord.cs           |   2 -
 src/Lucene.Net.Core/Util/BytesRef.cs            | 140 ++++++++---
 src/Lucene.Net.Core/Util/CharsRef.cs            | 109 ++++++--
 src/Lucene.Net.Core/Util/CharsRefBuilder.cs     | 247 +++++++++++++++++++
 src/Lucene.Net.Core/Util/InPlaceMergeSorter.cs  |  41 ++-
 src/Lucene.Net.Core/Util/RamUsageEstimator.cs   |   2 -
 src/Lucene.Net.Core/Util/Sorter.cs              |   1 -
 src/Lucene.Net.Core/Util/StringHelper.cs        |  21 +-
 src/Lucene.Net.Core/Util/UnicodeUtil.cs         |  48 +++-
 src/Lucene.Net.Core/Util/Version.cs             |  30 +--
 .../Support/ICloneableTests.cs                  |  31 +--
 .../Util/BaseSorterTestCase.cs                  |   2 -
 test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs |  17 +-
 test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs | 179 ++++++++++++--
 .../Lucene.Net.Core.Tests/Util/TestConstants.cs |  31 ++-
 .../Util/TestInPlaceMergeSorter.cs              |   1 -
 .../Util/TestRamEstimatorUsage.cs               |   9 +-
 test/Lucene.Net.Core.Tests/Util/TestVersion.cs  |  30 +--
 .../Random/RandomExtensions.cs                  |  11 +-
 .../Util/ExtensionMethods.cs                    |   3 +-
 .../Util/LuceneTestCase.cs                      |  42 ++--
 .../Util/TestAttribute.cs                       |  84 +++++--
 test/Lucene.Net.TestFramework/Util/TestUtil.cs  | 107 +++++++-
 39 files changed, 1172 insertions(+), 394 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Check.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Check.cs b/src/Lucene.Net.Core/Check.cs
index 58b9be7..96913c8 100644
--- a/src/Lucene.Net.Core/Check.cs
+++ b/src/Lucene.Net.Core/Check.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 4e1050a..64dfeb9 100644
--- a/src/Lucene.Net.Core/Lucene.Net.Core.csproj
+++ b/src/Lucene.Net.Core/Lucene.Net.Core.csproj
@@ -74,6 +74,7 @@
     <Compile Include="Util\BitUtil.cs" />
     <Compile Include="Util\BroadWord.cs" />
     <Compile Include="Util\BytesRef.cs" />
+    <Compile Include="Util\CharsRefBuilder.cs" />
     <Compile Include="Util\CharsRef.cs" />
     <Compile Include="Util\Constants.cs" />
     <Compile Include="Util\IAccountable.cs" />

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Support/DeepCloneNotSupportedException.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/DeepCloneNotSupportedException.cs b/src/Lucene.Net.Core/Support/DeepCloneNotSupportedException.cs
index fd2a940..38915ff 100644
--- a/src/Lucene.Net.Core/Support/DeepCloneNotSupportedException.cs
+++ b/src/Lucene.Net.Core/Support/DeepCloneNotSupportedException.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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/fde20a6f/src/Lucene.Net.Core/Support/EnumUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/EnumUtil.cs b/src/Lucene.Net.Core/Support/EnumUtil.cs
index 43f6958..e7f2ba7 100644
--- a/src/Lucene.Net.Core/Support/EnumUtil.cs
+++ b/src/Lucene.Net.Core/Support/EnumUtil.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Support/HashMap.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/HashMap.cs b/src/Lucene.Net.Core/Support/HashMap.cs
index 492de3e..3dfa99e 100644
--- a/src/Lucene.Net.Core/Support/HashMap.cs
+++ b/src/Lucene.Net.Core/Support/HashMap.cs
@@ -1,25 +1,19 @@
 /*
+ * 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
  *
- * 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
  *
- *   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.
- *
-*/
-
-
+ * 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/fde20a6f/src/Lucene.Net.Core/Support/ICharSequence.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/ICharSequence.cs b/src/Lucene.Net.Core/Support/ICharSequence.cs
index 8dbad2e..885a691 100644
--- a/src/Lucene.Net.Core/Support/ICharSequence.cs
+++ b/src/Lucene.Net.Core/Support/ICharSequence.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/fde20a6f/src/Lucene.Net.Core/Support/ICloneable.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/ICloneable.cs b/src/Lucene.Net.Core/Support/ICloneable.cs
index 11f9179..0819ad5 100644
--- a/src/Lucene.Net.Core/Support/ICloneable.cs
+++ b/src/Lucene.Net.Core/Support/ICloneable.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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/fde20a6f/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs b/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs
index 53971ed..786ffc5 100644
--- a/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs
+++ b/src/Lucene.Net.Core/Support/NumberExtensionMethods.cs
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-
-
 namespace Lucene.Net.Support
 {
     using System;
@@ -113,33 +111,50 @@ namespace Lucene.Net.Support
             return DeBruijn64.Position(value);
         }
 
-
-        internal static uint RotateLeft(this uint value, int distance)
+        /// <summary>
+        /// Rotates bits to the left. Similar to _rotl in c++ or Java's Integer.rotateLeft.
+        /// </summary>
+        /// <param name="value">The value to rotate.</param>
+        /// <param name="shift">The number of bits to shift.</param>
+        /// <returns>The rotated value.</returns>
+        internal static uint RotateLeft(this uint value, int shift)
         {
             var v = value;
-            return (v << distance) | (v >> (32 - distance));
+            return (v << shift) | (v >> (32 - shift));
         }
 
-        internal static uint RotateRight(this uint value, int distance)
+        /// <summary>
+        /// Rotates bits to the right. Similar to _rotr in c++ or Java's Integer.rotateRight.
+        /// </summary>
+        /// <param name="value">The value to rotate.</param>
+        /// <param name="shift">The number of bits to shift.</param>
+        /// <returns>The rotated value.</returns>
+        internal static uint RotateRight(this uint value, int shift)
         {
             var v = value;
-            return (v >> distance) | (v << (32 - distance));
+            return (v >> shift) | (v << (32 - shift));
         }
 
         /// <summary>
-        /// 
+        /// Rotates bits to the left. Similar to _rotl in c++ or Java's Integer.rotateLeft.
         /// </summary>
-        /// <param name="value"></param>
-        /// <param name="distance"></param>
-        /// <returns></returns>
-        public static int RotateLeft(this int value, int distance)
+        /// <param name="value">The value to rotate.</param>
+        /// <param name="shift">The number of bits to shift.</param>
+        /// <returns>The rotated value.</returns>
+        public static int RotateLeft(this int value, int shift)
         {
-            return (int)RotateLeft((uint)value, distance);
+            return (int)RotateLeft((uint)value, shift);
         }
 
-        public static int RotateRight(this int value, int distance)
+        /// <summary>
+        /// Rotates bits to the right. Similar to _rotr in c++ or Java's Integer.rotateRight.
+        /// </summary>
+        /// <param name="value">The value to rotate.</param>
+        /// <param name="shift">The number of bits to shift.</param>
+        /// <returns>The rotated value.</returns>
+        public static int RotateRight(this int value, int shift)
         {
-            return (int)RotateRight((uint)value, distance);
+            return (int)RotateRight((uint)value, shift);
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Support/SerializableAttribute.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/SerializableAttribute.cs b/src/Lucene.Net.Core/Support/SerializableAttribute.cs
index de7401d..a632ec9 100644
--- a/src/Lucene.Net.Core/Support/SerializableAttribute.cs
+++ b/src/Lucene.Net.Core/Support/SerializableAttribute.cs
@@ -1,4 +1,19 @@
-
+/*
+ * 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/fde20a6f/src/Lucene.Net.Core/Support/ShallowCloneNotSupportedException.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/ShallowCloneNotSupportedException.cs b/src/Lucene.Net.Core/Support/ShallowCloneNotSupportedException.cs
index 1b377d3..5cc187d 100644
--- a/src/Lucene.Net.Core/Support/ShallowCloneNotSupportedException.cs
+++ b/src/Lucene.Net.Core/Support/ShallowCloneNotSupportedException.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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/fde20a6f/src/Lucene.Net.Core/Support/StringExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/StringExtensionMethods.cs b/src/Lucene.Net.Core/Support/StringExtensionMethods.cs
index ca678ba..5167fa0 100644
--- a/src/Lucene.Net.Core/Support/StringExtensionMethods.cs
+++ b/src/Lucene.Net.Core/Support/StringExtensionMethods.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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/fde20a6f/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs b/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
index 76e82e4..e7ca972 100644
--- a/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
+++ b/src/Lucene.Net.Core/Support/SupportExtensionMethods.cs
@@ -1,23 +1,20 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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
 {
     /// <summary>
@@ -25,9 +22,6 @@ namespace Lucene.Net.Support
     /// </summary>
     public static class SupportExtensionMethods
     {
-
-
-
         /// <summary>
         /// Clones and casts the new instance to the same type of the old instance. 
         /// </summary>
@@ -54,15 +48,29 @@ namespace Lucene.Net.Support
         /// <returns>The computed hash.</returns>
         public static int ComputeMurmurHash3(this int value)
         {
-            uint x = (uint)value;
+            return (int) ((uint)value).ComputerMurmurHash3();
+        }
 
+        /// <summary>
+        /// Computes the integer into Austin Appleby's MurmurHash3
+        /// </summary>
+        /// <remarks>
+        ///     <para>
+        ///     <see cref="https://code.google.com/p/smhasher/wiki/MurmurHash3">MurmurHash3</see>
+        ///     </para>
+        /// </remarks>
+        /// <param name="value">The value, usually from a <see cref="System.Object.GetHashCode"/>.</param>
+        /// <returns>The computed hash.</returns>
+        internal static uint ComputerMurmurHash3(this uint value)
+        {
+            var x = value;
             x ^= x >> 16;
             x *= 0x85ebca6b;
             x ^= x >> 13;
             x *= 0xc2b2ae35;
             x ^= x >> 16;
 
-            return (int)x;
+            return x;
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/ArrayInPlaceMergeSorter`.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/ArrayInPlaceMergeSorter`.cs b/src/Lucene.Net.Core/Util/ArrayInPlaceMergeSorter`.cs
index b613b5a..bb9c39d 100644
--- a/src/Lucene.Net.Core/Util/ArrayInPlaceMergeSorter`.cs
+++ b/src/Lucene.Net.Core/Util/ArrayInPlaceMergeSorter`.cs
@@ -15,11 +15,11 @@
  * limitations under the License.
  */
 
-using System;
-using System.Collections.Generic;
-
 namespace Lucene.Net.Util
 {
+    using System;
+    using System.Collections.Generic;
+
     /// <summary>
     /// Summary description for ArrayInPlaceMergeSorter_
     /// </summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 091ad0a..57822b5 100644
--- a/src/Lucene.Net.Core/Util/ArrayUtil.cs
+++ b/src/Lucene.Net.Core/Util/ArrayUtil.cs
@@ -1,4 +1,19 @@
-
+/*
+ * 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
 {
@@ -158,7 +173,7 @@ namespace Lucene.Net.Util
         /// <exception cref="ArgumentNullException">Throws when <paramref name="chars"/> is null.</exception>
         /// <exception cref="ArgumentException">Throws when <paramref name="chars"/> is empty.</exception>
         /// <exception cref="ArgumentOutOfRangeException">
-        ///     <list>
+        ///     <list type="bullet">
         ///         <item>Throws when <paramref name="offset"/> is less than zero or greater than <paramref name="chars"/>.Length.</item>
         ///         <item>Throws when <paramref name="limit"/> is greater than <paramref name="chars"/>.Length.</item>
         ///         <item>Throws when <paramref name="radix"/> is less than 2 or greater than 36.</item>
@@ -183,7 +198,7 @@ namespace Lucene.Net.Util
         /// <exception cref="ArgumentNullException">Throws when <paramref name="chars"/> is null.</exception>
         /// <exception cref="ArgumentException">Throws when <paramref name="chars"/> is empty.</exception>
         /// <exception cref="ArgumentOutOfRangeException">
-        ///     <list>
+        ///     <list type="bullet">
         ///         <item>Throws when <paramref name="offset"/> is less than zero or greater than <paramref name="chars"/>.Length.</item>
         ///         <item>Throws when <paramref name="limit"/> is greater than <paramref name="chars"/>.Length.</item>
         ///         <item>Throws when <paramref name="radix"/> is less than 2 or greater than 36.</item>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/BitUtil.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BitUtil.cs b/src/Lucene.Net.Core/Util/BitUtil.cs
index da5f735..8ee0581 100644
--- a/src/Lucene.Net.Core/Util/BitUtil.cs
+++ b/src/Lucene.Net.Core/Util/BitUtil.cs
@@ -120,7 +120,7 @@ namespace Lucene.Net.Util
         /// Gets the number of bits which are encoded in <paramref name="value"/> .
         /// </summary>
         /// <remarks>
-        ///     <list>
+        ///     <list type="bullet">
         ///     <item>
         ///         <code>(i >>> (4 * n)) & 0x0F</code> is the offset of the n-th set bit of the given 
         ///         byte. For example <see cref="GetBiteList"/>(12) returns 0x43.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/Bits.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Bits.cs b/src/Lucene.Net.Core/Util/Bits.cs
index 9c5b9d7..365e6bf 100644
--- a/src/Lucene.Net.Core/Util/Bits.cs
+++ b/src/Lucene.Net.Core/Util/Bits.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 namespace Lucene.Net.Util
 {
     /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/BroadWord.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/BroadWord.cs b/src/Lucene.Net.Core/Util/BroadWord.cs
index 074c82a..1fa2f36 100644
--- a/src/Lucene.Net.Core/Util/BroadWord.cs
+++ b/src/Lucene.Net.Core/Util/BroadWord.cs
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-
-
 namespace Lucene.Net.Util
 {
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 b400896..e227cae 100644
--- a/src/Lucene.Net.Core/Util/BytesRef.cs
+++ b/src/Lucene.Net.Core/Util/BytesRef.cs
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 namespace Lucene.Net.Util
 {
     using Lucene.Net.Support;
@@ -45,15 +46,15 @@ namespace Lucene.Net.Util
 
         /// <summary>
         /// The contents of the BytesRef. Should never be {@code null}. </summary>
-        public byte[] Bytes { get; set; }
+        public byte[] Bytes { get; internal set; }
 
         /// <summary>
         /// Offset of first valid byte. </summary>
-        public int Offset { get; set; }
+        public int Offset { get; internal set; }
 
         /// <summary>
         /// Length of used bytes. </summary>
-        public int Length { get; set; }
+        public int Length { get; internal set; }
 
         /// <summary>
         /// Create a BytesRef with <seealso cref="#EMPTY_BYTES"/> </summary>
@@ -71,7 +72,7 @@ namespace Lucene.Net.Util
             this.Bytes = bytes;
             this.Offset = offset;
             this.Length = length;
-            Debug.Assert(Valid);
+            Debug.Assert(this.Valid());
         }
 
         /// <summary>
@@ -432,50 +433,123 @@ namespace Lucene.Net.Util
         /// Performs internal consistency checks.
         /// Always returns true (or throws InvalidOperationException)
         /// </summary>
-        public bool Valid
+        // this should be a method instead of a property due to the exceptions thrown. 
+        public bool Valid()
         {
-            get
+            
+            if (Bytes == null)
             {
-                if (Bytes == null)
-                {
-                    throw new Exception("bytes is null");
-                }
-                if (Length < 0)
-                {
-                    throw new Exception("length is negative: " + Length);
-                }
-                if (Length > Bytes.Length)
-                {
-                    throw new Exception("length is out of bounds: " + Length + ",bytes.length=" + Bytes.Length);
-                }
-                if (Offset < 0)
-                {
-                    throw new Exception("offset is negative: " + Offset);
-                }
-                if (Offset > Bytes.Length)
-                {
-                    throw new Exception("offset out of bounds: " + Offset + ",bytes.length=" + Bytes.Length);
-                }
-                if (Offset + Length < 0)
+                throw new Exception("bytes is null");
+            }
+            if (Length < 0)
+            {
+                throw new Exception("length is negative: " + Length);
+            }
+            if (Length > Bytes.Length)
+            {
+                throw new Exception("length is out of bounds: " + Length + ",bytes.length=" + Bytes.Length);
+            }
+            if (Offset < 0)
+            {
+                throw new Exception("offset is negative: " + Offset);
+            }
+            if (Offset > Bytes.Length)
+            {
+                throw new Exception("offset out of bounds: " + Offset + ",bytes.length=" + Bytes.Length);
+            }
+            if (Offset + Length < 0)
+            {
+                throw new Exception("offset+length is negative: offset=" + Offset + ",length=" + Length);
+            }
+            if (Offset + Length > Bytes.Length)
+            {
+                throw new Exception("offset+length out of bounds: offset=" + Offset + ",length=" + Length + ",bytes.length=" + Bytes.Length);
+            }
+            return true;
+            
+        }
+
+        public class ByteEnumerator : IEnumerator<byte>
+        {
+            private int length;
+            private byte[] bytes;
+            private int position = -1;
+            private int offset = 0;
+
+            public ByteEnumerator(byte[] bytes, int offset = 0, int length = 0)
+            {
+                if (length == 0 || length > bytes.Length)
+                    length = bytes.Length;
+
+                this.bytes = bytes;
+                this.length = length;
+                this.offset = offset;
+                this.position = (this.offset - 1);
+            }
+
+
+
+
+            public byte Current
+            {
+                get
                 {
-                    throw new Exception("offset+length is negative: offset=" + Offset + ",length=" + Length);
+                    return this.bytes[this.position];
                 }
-                if (Offset + Length > Bytes.Length)
+            }
+
+            object System.Collections.IEnumerator.Current
+            {
+                get { return this.Current; }
+            }
+
+            public bool MoveNext()
+            {
+                this.position = this.position + 1;
+                return this.position < this.length;
+            }
+
+            public void Reset()
+            {
+                this.position = this.offset - 1;
+            }
+
+            public void Dispose()
+            {
+                this.Dispose(true);
+            }
+
+            protected virtual void Dispose(bool dispose)
+            {
+                if (dispose)
                 {
-                    throw new Exception("offset+length out of bounds: offset=" + Offset + ",length=" + Length + ",bytes.length=" + Bytes.Length);
+                    this.bytes = null;
+                    this.offset = 0;
+                    this.length = 0;
+                    this.position = -1;
                 }
-                return true;
+            }
+
+            ~ByteEnumerator()
+            {
+                this.Dispose(false);
+            }
+
+            public int Length
+            {
+                get { return this.length; }
             }
         }
 
+
         public IEnumerator<byte> GetEnumerator()
         {
-            return ((IEnumerable<byte>)this.Bytes).GetEnumerator();
+            return new ByteEnumerator(this.Bytes, this.Offset, this.Length);
         }
 
         System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
         {
-            return this.Bytes.GetEnumerator();
+            return this.GetEnumerator();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 53150e5..8fde6e8 100644
--- a/src/Lucene.Net.Core/Util/CharsRef.cs
+++ b/src/Lucene.Net.Core/Util/CharsRef.cs
@@ -42,11 +42,11 @@ namespace Lucene.Net.Util
 
         /// <summary>
         /// The contents of the CharsRef. Should never be <see cref="Null"/>. </summary>
-        public char[] Chars { get; set; }
+        public char[] Chars { get; internal set; }
 
         /// <summary>
         /// Offset of first valid character. </summary>
-        public int Offset {get; set;}
+        public int Offset {get; internal set;}
 
         /// <summary>
         /// Length of used characters. </summary>
@@ -86,9 +86,9 @@ namespace Lucene.Net.Util
         /// Creates a new <seealso cref="CharsRef"/> initialized with the given Strings character
         /// array
         /// </summary>
-        public CharsRef(string @string)
+        public CharsRef(string value)
         {
-            this.Chars = @string.ToCharArray();
+            this.Chars = value.ToCharArray();
             this.Offset = 0;
             this.Length = Chars.Length;
         }
@@ -98,11 +98,16 @@ namespace Lucene.Net.Util
         /// <b>not</b> copied and will be shared by both the returned object and this
         /// object.
         /// </summary>
-        /// <seealso cref= #deepCopyOf </seealso>
+        /// <seealso cref="Lucene.Net.Support.ICloneable"/>
         public object Clone(bool deepClone = false)
         {
             if (deepClone)
-                throw new DeepCloneNotSupportedException(typeof(CharsRef));
+            {
+                var charsRef = new CharsRef();
+                charsRef.CopyChars(this);
+
+                return charsRef;
+            }
 
             return new CharsRef(Chars, Offset, Length);
         }
@@ -354,12 +359,7 @@ namespace Lucene.Net.Util
         /// The returned CharsRef will have a length of other.length
         /// and an offset of zero.
         /// </summary>
-        public static CharsRef DeepCopyOf(CharsRef other)
-        {
-            CharsRef clone = new CharsRef();
-            clone.CopyChars(other);
-            return clone;
-        }
+       
 
         /// <summary>
         /// Performs internal consistency checks.
@@ -403,12 +403,93 @@ namespace Lucene.Net.Util
 
         public IEnumerator<char> GetEnumerator()
         {
-            return ((IEnumerable<char>)this.Chars).GetEnumerator();
+            return new CharEnumerator(this.Chars, this.Offset, this.Offset + this.Length);
+        }
+
+        public class CharEnumerator : IEnumerator<char>, ICharSequence
+        {
+            private int length;
+            private char[] chars;
+            private int position = -1;
+            private int offset = 0;
+      
+            public CharEnumerator(char[] chars, int offset = 0, int length = 0)
+            {
+                if (length == 0 || length > chars.Length)
+                    length = chars.Length;
+
+                this.chars = chars;
+                this.length = length;
+                this.offset = offset;
+                this.position = (this.offset - 1);
+            }
+
+      
+
+
+            public char Current
+            {
+                get {
+                    return this.chars[this.position];
+                }
+            }
+
+            object System.Collections.IEnumerator.Current
+            {
+                get { return this.Current; }
+            }
+
+            public bool MoveNext()
+            {
+                this.position = this.position + 1;
+                return this.position < this.length;
+            }
+
+            public void Reset()
+            {
+                this.position = this.offset - 1;
+            }
+
+            public void Dispose()
+            {
+                this.Dispose(true);
+            }
+
+            protected  virtual void Dispose(bool dispose)
+            {
+                if(dispose)
+                {
+                    this.chars = null;
+                    this.offset = 0;
+                    this.length = 0;
+                    this.position = -1;
+                }
+            }
+
+            ~CharEnumerator()
+            {
+                this.Dispose(false);
+            }
+
+            public int Length
+            {
+                get { return this.length; }
+            }
+
+            public char CharAt(int index)
+            {
+                return this.chars[index];
+            }
+
+            public ICharSequence SubSequence(int start, int end)
+            {
+                return new CharEnumerator(this.chars, start, end - start);
+            }
         }
 
         System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
         {
-            return this.Chars.GetEnumerator();
+            return this.GetEnumerator();
         }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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
new file mode 100644
index 0000000..3a1e054
--- /dev/null
+++ b/src/Lucene.Net.Core/Util/CharsRefBuilder.cs
@@ -0,0 +1,247 @@
+/*
+ * 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.Diagnostics.CodeAnalysis;
+
+    /// <summary>
+    /// Builds up characters for a <see cref="Lucene.Net.Util.CharRef"/>. 
+    /// This class is meant for internal use only. 
+    /// </summary>
+    public class CharsRefBuilder:
+        IEnumerable<char>
+    {
+        private CharsRef charsRef;
+        
+        /// <summary>
+        /// Initializes a new instance of <see cref="CharsRefBuilder"/>.
+        /// </summary>
+        public CharsRefBuilder()
+        {
+            this.charsRef = new CharsRef();
+        }
+
+        /// <summary>
+        /// Gets or sets the character value at the specified index.
+        /// </summary>
+        /// <param name="index">The position of the value to get or set.</param>
+        /// <returns>The value at the spcified index.</returns>
+        public char this[int index]
+        {
+            get { return this.charsRef.Chars[index]; }
+            set
+            {
+                this.charsRef.Chars[index] = value;
+            }
+        }
+
+        /// <summary>
+        /// Gets the internal reference of <see cref="Lucene.Net.Util.CharRef"/> 
+        /// that the builder uses.
+        /// </summary>
+        public CharsRef CharRef
+        {
+            get { return this.charsRef; }
+        }
+
+        /// <summary>
+        /// Gets the array of characters.
+        /// </summary>
+        public Char[] Chars
+        {
+            get { return this.charsRef.Chars; }
+        }
+
+        /// <summary>
+        /// Gets or sets the number of characters in the builder.
+        /// </summary>
+        public int Length
+        {
+            get { return this.charsRef.Length; }
+            set { this.charsRef.Length = value; }
+        }
+
+        /// <summary>
+        /// Appends the characters at the end of the array in this instance.
+        /// </summary>
+        /// <param name="chars">The array of characters to copy.</param>
+        /// <param name="offset">The starting position in <paramref name="chars"/> for the copy.</param>
+        /// <param name="length">The number of characters to copy from <paramref name="chars"/>.</param>
+        /// <exception cref="System.ArgumentException">
+        ///     <list type="bullet">
+        ///         <item>Thrown when <paramref name="offset"/> is less than 0.</item>
+        ///         <item>Thrown when <paramref name="length"/> is less than 0 or greater than <paramref name="chars"/>.Length.</item>
+        ///     </list>
+        /// </exception>
+        public void Append(char[] chars, int offset = 0, int length = 0)
+        {
+            this.InternalCopyChars(chars, offset, length, true);
+        }
+
+        /// <summary>
+        /// Reset the current instance of <see cref="Lucene.Net.Util.CharsRefBuilder"/>
+        /// to an empty state.
+        /// </summary>
+        public void Clear()
+        {
+            this.charsRef.Length = 0;
+        }
+
+        /// <summary>
+        /// Copies the <see cref="Lucene.Net.Util.CharRef"/> into this instance.
+        /// </summary>
+        /// <param name="other">The instance to copy.</param>
+        public void CopyChars(CharsRef other)
+        {
+            this.CopyChars(other.Chars);
+        }
+
+        /// <summary>
+        /// Copies the characters into this instance.
+        /// </summary>
+        /// <param name="chars">The array of characters to copy.</param>
+        /// <param name="offset">The starting position in <paramref name="chars"/> for the copy.</param>
+        /// <param name="length">The number of characters to copy from <paramref name="chars"/>.</param>
+        /// <exception cref="System.ArgumentException">
+        ///     <list type="bullet">
+        ///         <item>Thrown when <paramref name="offset"/> is less than 0.</item>
+        ///         <item>Thrown when <paramref name="length"/> is less than 0 or greater than <paramref name="chars"/>.Length.</item>
+        ///     </list>
+        /// </exception>
+        public void CopyChars(char[] chars, int offset = 0, int length = 0)
+        {
+            this.InternalCopyChars(chars, offset, length, false);
+        }
+
+        private void InternalCopyChars(char[] chars, int offset = 0, int length = 0, bool append = false)
+        {
+            Check.Condition(offset < 0, "offset", "Parameter 'offset' should be greater than or equal to 0.");
+            Check.Condition(length < 0 || length > chars.Length, "length",
+                    "Parameter 'length' must be greater or equal to 0 and less than or equal to chars.Length.");
+
+            if (length == 0)
+                length = chars.Length;
+
+            int position = 0;
+            int newLength = length;
+            if(append)
+            {
+                position = this.charsRef.Length;
+                newLength = this.charsRef.Length + length;
+            }
+
+            this.Grow(newLength);
+            Array.Copy(chars, offset, this.charsRef.Chars, position, length);
+
+            this.charsRef.Length = newLength;
+        }
+
+
+        /// <summary>
+        /// Copies the <see cref="Lucene.Net.Util.BytesRef"/> into this instance.
+        /// </summary>
+        /// <param name="other">The instance to copy.</param>
+        public void CopyUtf8Bytes(BytesRef bytes)
+        {
+            this.CopyUtf8Bytes(bytes.Bytes, bytes.Offset, bytes.Length);
+        }
+
+
+        /// <summary>
+        /// Copies the bytes into this instance.
+        /// </summary>
+        /// <param name="chars">The array of characters to copy.</param>
+        /// <param name="offset">The starting position in <paramref name="chars"/> for the copy.</param>
+        /// <param name="length">The number of characters to copy from <paramref name="chars"/>.</param>
+        /// <exception cref="System.ArgumentException">
+        ///     <list type="bullet">
+        ///         <item>Thrown when <paramref name="offset"/> is less than 0.</item>
+        ///         <item>Thrown when <paramref name="length"/> is less than 0 or greater than <paramref name="chars"/>.Length.</item>
+        ///     </list>
+        /// </exception>
+        public void CopyUtf8Bytes(byte[] bytes, int offset = 0, int length = 0)
+        {
+            Check.Condition(offset < 0, "offset", "Parameter 'offset' should be greater than or equal to 0.");
+            //Check.Condition(length < 0 || length > bytes.Length, "length",
+            //    "Parameter 'length' must be greater or equal to 0 and less than or equal to bytes.Length.");
+
+            if (length == 0)
+                length = bytes.Length;
+
+            this.Grow(length);
+
+            this.charsRef.Length = UnicodeUtil.UTF8toUTF16(bytes, offset, length, this.charsRef);
+        }
+
+        /// <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>
+        /// Resizes and increases the length of the reference array.
+        /// </summary>
+        /// <param name="mininumSize">The minimum size to grow the array.</param>
+        public void Grow(int mininumSize)
+        {
+            this.charsRef.Chars = ArrayUtil.Grow(this.charsRef.Chars, mininumSize);
+        }
+
+        /// <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();
+        }
+
+
+        /// <summary>
+        /// Returns a new instance of <see cref="Lucene.Net.Util.CharRef"/> that has 
+        /// copy of the current state of this instance.
+        /// </summary>
+        /// <returns>a new instance of <see cref="Lucene.Net.Util.CharRef"/></returns>
+        public CharsRef ToCharRef()
+        {
+            var copy = this.charsRef.Chars.CopyOf(this.charsRef.Length);
+            return new CharsRef(copy, 0, this.charsRef.Length);
+        }
+
+        public override string ToString()
+        {
+            return this.charsRef.ToString();
+        }
+
+        #region IEnumerable<char>
+        public IEnumerator<char> GetEnumerator()
+        {
+            return this.charsRef.GetEnumerator();
+        }
+
+        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
+        {
+            return this.charsRef.GetEnumerator();
+        }
+        #endregion
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/InPlaceMergeSorter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/InPlaceMergeSorter.cs b/src/Lucene.Net.Core/Util/InPlaceMergeSorter.cs
index ae2fbb7..2d8fc8b 100644
--- a/src/Lucene.Net.Core/Util/InPlaceMergeSorter.cs
+++ b/src/Lucene.Net.Core/Util/InPlaceMergeSorter.cs
@@ -1,28 +1,27 @@
 /*
-* 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.
-*/
+ * 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
 {
-
-
-    /** {@link Sorter} implementation based on the merge-sort algorithm that merges
-     *  in place (no extra memory will be allocated). Small arrays are sorted with
-     *  insertion sort.
-     *  @lucene.internal */
+    /// <summary>
+    /// <see cref="Sorter"/> implementation based on the merge-sort algorithm that merge
+    /// in place (no extra memory will be allocated). Small arrays are sorted with insertion sort.
+    /// This class is meant for internal use only.
+    /// </summary>
     public abstract class InPlaceMergeSorter : Sorter
     {
 

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/RamUsageEstimator.cs b/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
index cc46b66..83f4914 100644
--- a/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
+++ b/src/Lucene.Net.Core/Util/RamUsageEstimator.cs
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-
-
 namespace Lucene.Net.Util
 {
     using Lucene.Net.Support;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/Sorter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Sorter.cs b/src/Lucene.Net.Core/Util/Sorter.cs
index 7b5f5e4..bbb7312 100644
--- a/src/Lucene.Net.Core/Util/Sorter.cs
+++ b/src/Lucene.Net.Core/Util/Sorter.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 namespace Lucene.Net.Util
 {
     using System;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/StringHelper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/StringHelper.cs b/src/Lucene.Net.Core/Util/StringHelper.cs
index 68122b1..de2c290 100644
--- a/src/Lucene.Net.Core/Util/StringHelper.cs
+++ b/src/Lucene.Net.Core/Util/StringHelper.cs
@@ -1,12 +1,23 @@
-
+/*
+ * 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 System.Text;
-    using System.Threading.Tasks;
     using Lucene.Net.Support;
 
     public class StringHelper

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 ef99984..9861f66 100644
--- a/src/Lucene.Net.Core/Util/UnicodeUtil.cs
+++ b/src/Lucene.Net.Core/Util/UnicodeUtil.cs
@@ -1,12 +1,31 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-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.Util
 {
+    using System;
+    using System.Collections.Generic;
+    using System.Diagnostics;
+    using System.Linq;
+    using System.Text;
+
+    /// <summary>
+    /// Utility methods for dealing with unicode.
+    /// </summary>
     public static class UnicodeUtil
     {
         public const int UNI_SUR_HIGH_START = 0xD800;
@@ -23,7 +42,14 @@ namespace Lucene.Net.Util
 
         private static readonly int SURROGATE_OFFSET = MIN_SUPPLEMENTARY_CODE_POINT - (UNI_SUR_HIGH_START << (int)HALF_SHIFT) - UNI_SUR_LOW_START;
 
-        public static void UTF16toUTF8(IEnumerable<char> s, int offset, int length, BytesRef result)
+        /// <summary>
+        /// 
+        /// </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)
         {
             int end = offset + length;
 
@@ -39,7 +65,7 @@ namespace Lucene.Net.Util
             int upto = 0;
             for (int i = offset; i < end; i++)
             {
-                int code = (int)s.ElementAt(i);
+                int code = (int)chars.ElementAt(i);
 
                 if (code < 0x80)
                 {
@@ -62,7 +88,7 @@ namespace Lucene.Net.Util
                     // confirm valid high surrogate
                     if (code < 0xDC00 && (i < end - 1))
                     {
-                        int utf32 = (int)s.ElementAt(i + 1);
+                        int utf32 = (int)chars.ElementAt(i + 1);
                         // confirm valid low surrogate and write pair
                         if (utf32 >= 0xDC00 && utf32 <= 0xDFFF)
                         {
@@ -97,7 +123,7 @@ namespace Lucene.Net.Util
         /// Explicit checks for valid UTF-8 are not performed.
         /// </summary>
         // TODO: broken if chars.offset != 0
-        public static void UTF8toUTF16(byte[] utf8, int offset, int length, CharsRef chars)
+        public static int UTF8toUTF16(byte[] utf8, int offset, int length, CharsRef chars)
         {
             int outOffset = chars.Offset = 0,
                 limit = offset + length;
@@ -140,6 +166,8 @@ namespace Lucene.Net.Util
                 }
             }
             chars.Length = outOffset - chars.Offset;
+
+            return chars.Length;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/src/Lucene.Net.Core/Util/Version.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net.Core/Util/Version.cs b/src/Lucene.Net.Core/Util/Version.cs
index a13caa9..92c362c 100644
--- a/src/Lucene.Net.Core/Util/Version.cs
+++ b/src/Lucene.Net.Core/Util/Version.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/test/Lucene.Net.Core.Tests/Support/ICloneableTests.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Support/ICloneableTests.cs b/test/Lucene.Net.Core.Tests/Support/ICloneableTests.cs
index 53202ce..6e934fb 100644
--- a/test/Lucene.Net.Core.Tests/Support/ICloneableTests.cs
+++ b/test/Lucene.Net.Core.Tests/Support/ICloneableTests.cs
@@ -1,25 +1,20 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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
 {
     using Lucene.Net.Util;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 5d57069..2295746 100644
--- a/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
+++ b/test/Lucene.Net.Core.Tests/Util/BaseSorterTestCase.cs
@@ -15,8 +15,6 @@
  * limitations under the License.
  */
 
-
-
 namespace Lucene.Net.Util
 {
     using System;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 5ef6ba3..d5927e2 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestBytesRef.cs
@@ -1,4 +1,19 @@
-
+/*
+ * 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
 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 052abc5..0516186 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestCharsRef.cs
@@ -1,25 +1,172 @@
 /*
-* 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.
-*/
+ * 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.Support;
     using System;
+    using System.Collections.Generic;
+    using System.Linq;
+    using System.Linq.Expressions;
+    using Lucene.Net.Random;
+    using System.Text;
 
-    public class TestCharsRef
+
+    public class TestCharsRef : LuceneTestCase
     {
+        [Test]
+        public void testUTF16InUTF8Order()
+        {
+            int iterations = this.AtLeast(1000);
+            BytesRef[] utf8 = new BytesRef[iterations];
+            CharsRef[] utf16 = new CharsRef[iterations];
+
+            iterations.Times((i) =>
+            {
+                var s = this.Random.RandomUnicodeString();
+                utf8[i] = new BytesRef(s);
+                utf16[i] = new CharsRef(s);
+            });
+
+            Array.Sort(utf8);
+#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()));
+        }
+
+
+        [Test]
+        public void TestAppend() {
+            var builder = new CharsRefBuilder();
+            var sb = new StringBuilder();
+            int iterations = this.AtLeast(10);
+
+            iterations.Times((i) => {
+                var charArray = this.Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
+                int offset = this.Random.Next(charArray.Length);
+                int length = charArray.Length - offset;
+                sb.Append(charArray, offset, length);
+                builder.Append(charArray, offset, length);  
+            });
+   
+    
+            Equal(sb.ToString(), builder.CharRef.ToString());
+        }
+
+        [Test]
+        public void TestCopy()
+        {
+            var iterations = this.AtLeast(10);
+            iterations.Times((i) => {
+                var builder = new CharsRefBuilder();
+                var charArray = this.Random.RandomRealisticUnicodeString(1, 100).ToCharArray();
+                int offset = this.Random.Next(charArray.Length),
+                    length = charArray.Length - offset;
+
+               String str = new String(charArray, offset, length);
+               builder.CopyChars(charArray, offset, length);
+             
+               Equals(str, builder.ToString());  
+            });
+        }
+
+        [Test]
+        [Ticket("LUCENE-3590", "fix charsequence to fully obey interface")]
+        public void TestCharSequenceAt()
+        {
+            var c = new CharsRef("abc");
+
+            Equal('b', c.CharAt(1));
+            Equal('b', c.ElementAt(1));
+
+            Throws<IndexOutOfRangeException>(() =>
+            {
+                c.CharAt(-1);
+            });
+
+            Throws<IndexOutOfRangeException>(() =>
+            {
+                c.CharAt(3);
+            });
+        }
+
+    
+        [Ticket("LUCENE-3590", " fix off-by-one in subsequence, and fully obey interface")]
+        [Ticket("LUCENE-4671", " fix subSequence")]
+        public void TestCharSequenceSubSequence() {
+            CharsRef[] sequences =  {
+                new CharsRef("abc"),
+                new CharsRef("0abc".ToCharArray(), 1, 3),
+                new CharsRef("abc0".ToCharArray(), 0, 3),
+                new CharsRef("0abc0".ToCharArray(), 1, 3)
+            };
+    
+            foreach(var c in sequences) {
+               AssertSequence(c);
+            }
+        }
+
+        private void AssertSequence(CharsRef c)
+        {
+            // 
+
+            Equal("a", c.SubSequence(0, 1).ToString());
+            
+            var sub1 = string.Join("", c.Take(1));
+            Ok("a" == sub1, "sub1 should be 'a' but was '{0}' from ref {1}", sub1, c.ToString());
+            
+            // mid subsequence
+            Equal("b", c.SubSequence(1, 2).ToString());
+
+            var sub2 = string.Join("", c.Skip(1).Take(1));
+            Ok("b" == sub2, "sub1 should be 'b' but was '{0}' from ref {1}", sub2, c.ToString());
+            
+            // end subsequence
+            Equal("bc", c.SubSequence(1, 3).ToString());
+
+            var sub3 = string.Join("", c.Skip(1).Take(2));
+            Ok("bc" == sub3, "sub3 should be 'bc' but was '{0}' from ref {1}", sub3, c.ToString());
+            
+            // empty subsequence
+            Equal("", c.SubSequence(0, 0).ToString());
+            Equal("", string.Join("", c.Skip(0).Take(0)));
+            
+            Throws<IndexOutOfRangeException>(() =>
+            {
+                c.SubSequence(-1, 1);
+            });
+
+            Throws<IndexOutOfRangeException>(() =>
+            {
+                c.SubSequence(0, -1);
+            });
+
+            Throws<IndexOutOfRangeException>(() =>
+            {
+                c.SubSequence(0, 4);
+            });
+
+            Throws<IndexOutOfRangeException>(() =>
+            {
+                c.SubSequence(2, 1);
+            });
+            
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/test/Lucene.Net.Core.Tests/Util/TestConstants.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestConstants.cs b/test/Lucene.Net.Core.Tests/Util/TestConstants.cs
index 93f9eb4..c93f42e 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestConstants.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestConstants.cs
@@ -1,20 +1,19 @@
 /*
-* 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.
-*/
-
+ * 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
 {

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/test/Lucene.Net.Core.Tests/Util/TestInPlaceMergeSorter.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestInPlaceMergeSorter.cs b/test/Lucene.Net.Core.Tests/Util/TestInPlaceMergeSorter.cs
index 672e263..d09a0f0 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestInPlaceMergeSorter.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestInPlaceMergeSorter.cs
@@ -15,7 +15,6 @@
  * limitations under the License.
  */
 
-
 namespace Lucene.Net.Util
 {
     /// <summary>

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/test/Lucene.Net.Core.Tests/Util/TestRamEstimatorUsage.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestRamEstimatorUsage.cs b/test/Lucene.Net.Core.Tests/Util/TestRamEstimatorUsage.cs
index d498c35..7d25c09 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestRamEstimatorUsage.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestRamEstimatorUsage.cs
@@ -1,13 +1,13 @@
-/* 
+/*
  * 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
- * 
+ *
+ *     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.
@@ -16,7 +16,6 @@
  */
 
 
-
 namespace Lucene.Net.Util
 {
     using System;

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/test/Lucene.Net.Core.Tests/Util/TestVersion.cs
----------------------------------------------------------------------
diff --git a/test/Lucene.Net.Core.Tests/Util/TestVersion.cs b/test/Lucene.Net.Core.Tests/Util/TestVersion.cs
index f4bd081..47c24c5 100644
--- a/test/Lucene.Net.Core.Tests/Util/TestVersion.cs
+++ b/test/Lucene.Net.Core.Tests/Util/TestVersion.cs
@@ -1,22 +1,18 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 48ebea8..c857372 100644
--- a/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
+++ b/test/Lucene.Net.TestFramework/Random/RandomExtensions.cs
@@ -15,9 +15,9 @@
  * limitations under the License.
  */
 
-
 namespace Lucene.Net.Random
 {
+    using Lucene.Net.Util;
     using System;
     using System.Diagnostics;
 
@@ -31,6 +31,15 @@ namespace Lucene.Net.Random
     /// </remarks>
     public static class RandomExtensions
     {
+
+
+        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 
         /// with the Java Lucene version of the NextIntBetween method.

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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
index 8b60178..94cac09 100644
--- a/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
+++ b/test/Lucene.Net.TestFramework/Util/ExtensionMethods.cs
@@ -18,7 +18,7 @@
 namespace Lucene.Net.Util
 {
     using System;
-
+    using Lucene.Net.Random;
     /// <summary>
     /// Extension methods to make writing tests easier.
     /// </summary>
@@ -36,5 +36,6 @@ namespace Lucene.Net.Util
                 invoke(i);
             }
         }
+
     }
 }

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/fde20a6f/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 3c08e61..70e580d 100644
--- a/test/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
+++ b/test/Lucene.Net.TestFramework/Util/LuceneTestCase.cs
@@ -1,25 +1,20 @@
-/**
+/*
+ * 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
  *
- * 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.
+ *     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;
@@ -30,6 +25,17 @@ namespace Lucene.Net.Util
 
     public class LuceneTestCase
     {
+        /// <summary>
+        ///  A random multiplier which you should use when writing random tests:
+        ///  multiply it by the number of iterations to scale your tests (for nightly builds).
+        /// </summary>
+        public static int RANDOM_MULTIPLIER = SystemProps.Get<int>("tests:multiplier", 1);
+
+        /// <summary>
+        /// Whether or not <see cref="NightlyAttribute" /> tests should run.
+        /// </summary>
+        public static bool TEST_NIGHTLY = SystemProps.Get<Boolean>("tests:nightly", false);
+
         private static ThreadLocal<System.Random> random;
 
         static LuceneTestCase()


Mime
View raw message