http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/IO/FileSupport.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/IO/FileSupport.cs 
b/src/Lucene.Net/Support/IO/FileSupport.cs
new file mode 100644
index 0000000..82e8b1c
--- /dev/null
+++ b/src/Lucene.Net/Support/IO/FileSupport.cs
@@ -0,0 +1,232 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+using System;
+using System.IO;
+using System.Linq;
+using System.Runtime.CompilerServices;
+using System.Text;
+
+namespace Lucene.Net.Support.IO
+{
+    /// <summary>
+    /// Represents the methods to support some operations over files.
+    /// </summary>
+    public class FileSupport
+    {
+        private static readonly object _lock = new object();
+
+        /// <summary>
+        /// Returns an array of abstract pathnames representing the files and 
directories of the specified path.
+        /// </summary>
+        /// <param name="path">The abstract pathname to list it childs.</param>
+        /// <returns>An array of abstract pathnames childs of the path 
specified or null if the path is not a directory</returns>
+        public static System.IO.FileInfo[] GetFiles(System.IO.FileInfo path)
+        {
+            if ((path.Attributes & FileAttributes.Directory) > 0)
+            {
+                String[] fullpathnames = 
Directory.GetFileSystemEntries(path.FullName);
+                System.IO.FileInfo[] result = new 
System.IO.FileInfo[fullpathnames.Length];
+                for (int i = 0; i < result.Length; i++)
+                    result[i] = new System.IO.FileInfo(fullpathnames[i]);
+                return result;
+            }
+            else
+                return null;
+        }
+
+        // TODO: This filesupport thing is silly.  Same goes with _TestUtil's 
RMDir.
+        //       If we're removing a directory
+        public static System.IO.FileInfo[] GetFiles(System.IO.DirectoryInfo 
path)
+        {
+            return GetFiles(new FileInfo(path.FullName));
+        }
+
+        ///// <summary>
+        ///// Returns a list of files in a give directory.
+        ///// </summary>
+        ///// <param name="fullName">The full path name to the 
directory.</param>
+        ///// <param name="indexFileNameFilter"></param>
+        ///// <returns>An array containing the files.</returns>
+        //public static System.String[] GetLuceneIndexFiles(System.String 
fullName,
+        //                                                  
Index.IndexFileNameFilter indexFileNameFilter)
+        //{
+        //    System.IO.DirectoryInfo dInfo = new 
System.IO.DirectoryInfo(fullName);
+        //    System.Collections.ArrayList list = new 
System.Collections.ArrayList();
+        //    foreach (System.IO.FileInfo fInfo in dInfo.GetFiles())
+        //    {
+        //        if (indexFileNameFilter.Accept(fInfo, fInfo.Name) == true)
+        //        {
+        //            list.Add(fInfo.Name);
+        //        }
+        //    }
+        //    System.String[] retFiles = new System.String[list.Count];
+        //    list.CopyTo(retFiles);
+        //    return retFiles;
+        //}
+
+        // Disable the obsolete warning since we must use FileStream.Handle
+        // because Mono does not support FileSystem.SafeFileHandle at present.
+#pragma warning disable 618
+
+        /// <summary>
+        /// Flushes the specified file stream. Ensures that all buffered
+        /// data is actually written to the file system.
+        /// </summary>
+        /// <param name="fileStream">The file stream.</param>
+        public static void Sync(System.IO.FileStream fileStream)
+        {
+            if (fileStream == null)
+                throw new ArgumentNullException("fileStream");
+
+            fileStream.Flush(true);
+
+            if (OS.IsWindows)
+            {
+#if NETSTANDARD
+                // Getting the SafeFileHandle property automatically flushes 
the
+                // stream: 
https://msdn.microsoft.com/en-us/library/system.io.filestream.safefilehandle(v=vs.110).aspx
+                var handle = fileStream.SafeFileHandle;
+#else
+                if (!FlushFileBuffers(fileStream.Handle))
+                    throw new IOException();
+#endif
+            }
+            //else if (OS.IsUnix)
+            //{
+            //    if (fsync(fileStream.Handle) != IntPtr.Zero)
+            //    throw new System.IO.IOException();
+            //}
+            //else
+            //{
+            //    throw new NotImplementedException();
+            //}
+        }
+
+#pragma warning restore 618
+
+        //[System.Runtime.InteropServices.DllImport("libc")]
+        //extern static IntPtr fsync(IntPtr fd);
+
+        [System.Runtime.InteropServices.DllImport("kernel32.dll")]
+        extern static bool FlushFileBuffers(IntPtr hFile);
+
+
+        /// <summary>
+        /// Creates a new empty file in the specified directory, using the 
given prefix and suffix strings to generate its name. 
+        /// If this method returns successfully then it is guaranteed that:
+        /// <list type="number">
+        /// <item>The file denoted by the returned abstract pathname did not 
exist before this method was invoked, and</item>
+        /// <item>Neither this method nor any of its variants will return the 
same abstract pathname again in the current invocation of the virtual 
machine.</item>
+        /// </list>
+        /// This method provides only part of a temporary-file facility.To 
arrange for a file created by this method to be deleted automatically, use the 
deleteOnExit() method.
+        /// The prefix argument must be at least three characters long. It is 
recommended that the prefix be a short, meaningful string such as "hjb" or 
"mail". The suffix argument may be null, in which case the suffix ".tmp" will 
be used.
+        /// To create the new file, the prefix and the suffix may first be 
adjusted to fit the limitations of the underlying platform.If the prefix is too 
long then it will be truncated, but its first three characters will always be 
preserved.If the suffix is too long then it too will be truncated, but if it 
begins with a period character ('.') then the period and the first three 
characters following it will always be preserved.Once these adjustments have 
been made the name of the new file will be generated by concatenating the 
prefix, five or more internally-generated characters, and the suffix.
+        /// If the directory argument is null then the system-dependent 
default temporary-file directory will be used.The default temporary-file 
directory is specified by the system property java.io.tmpdir.On UNIX systems 
the default value of this property is typically "/tmp" or "/var/tmp"; on 
Microsoft Windows systems it is typically "C:\\WINNT\\TEMP". A different value 
may be given to this system property when the Java virtual machine is invoked, 
but programmatic changes to this property are not guaranteed to have any effect 
upon the temporary directory used by this method.
+        /// 
+        /// Ported over from the java.io.File class. Used by the 
Analysis.Hunspell.Directory
+        /// class, but this can probably be removed when that class is 
upgraded to a more recent
+        /// version of lucene, where it uses the lucene Store.Directory class 
to create a temporary
+        /// file.
+        /// </summary>
+        /// <param name="prefix">The prefix string to be used in generating 
the file's name; must be at least three characters long</param>
+        /// <param name="suffix">The suffix string to be used in generating 
the file's name; may be null, in which case a random suffix will be 
generated</param>
+        /// <param name="directory">The directory in which the file is to be 
created, or null if the default temporary-file directory is to be used</param>
+        /// <returns></returns>
+        public static FileInfo CreateTempFile(string prefix, string suffix, 
DirectoryInfo directory)
+        {
+            lock (_lock)
+            {
+                if (string.IsNullOrEmpty(prefix))
+                    throw new ArgumentNullException("prefix");
+                if (prefix.Length < 3)
+                    throw new ArgumentException("Prefix string too short");
+
+                // Ensure the strings passed don't contain invalid characters
+                char[] invalid = Path.GetInvalidPathChars();
+
+                if (prefix.ToCharArray().Intersect(invalid).Any())
+                    throw new ArgumentException(string.Format("Prefix contains 
invalid characters. You may not use any of '{0}'", string.Join(", ", invalid)));
+                if (suffix != null && 
suffix.ToCharArray().Intersect(invalid).Any())
+                    throw new ArgumentException(string.Format("Suffix contains 
invalid characters. You may not use any of '{0}'", string.Join(", ", invalid)));
+
+                // If no directory supplied, create one.
+                if (directory == null)
+                {
+                    directory = new DirectoryInfo(Path.GetTempPath());
+                }
+                string fileName = string.Empty;
+
+                while (true)
+                {
+                    fileName = NewTempFileName(prefix, suffix, directory);
+
+                    if (File.Exists(fileName))
+                    {
+                        continue;
+                    }
+
+                    try
+                    {
+                        // Create the file, and close it immediately
+                        File.WriteAllText(fileName, string.Empty, new 
UTF8Encoding(encoderShouldEmitUTF8Identifier: false) /* No BOM */);
+                        break;
+                    }
+                    catch (IOException e)
+                    {
+                        // If the error was because the file exists, try again
+                        if (File.Exists(fileName))
+                        {
+                            continue;
+                        }
+
+                        // else rethrow it
+                        throw e;
+                    }
+                }
+                return new FileInfo(fileName);
+            }
+        }
+
+        /// <summary>
+        /// Generates a new random file name with the provided <paramref 
name="directory"/>, 
+        /// <paramref name="prefix"/> and optional <see cref="suffix"/>.
+        /// </summary>
+        /// <param name="prefix">The prefix string to be used in generating 
the file's name</param>
+        /// <param name="suffix">The suffix string to be used in generating 
the file's name; may be null, in which case a random suffix will be 
generated</param>
+        /// <param name="directory">A <see cref="DirectoryInfo"/> object 
containing the temp directory path. Must not be null.</param>
+        /// <returns>A random file name</returns>
+        internal static string NewTempFileName(string prefix, string suffix, 
DirectoryInfo directory)
+        {
+            string randomFileName = Path.GetRandomFileName();
+
+            if (suffix != null)
+            {
+                randomFileName = string.Concat(
+                    Path.GetFileNameWithoutExtension(randomFileName),
+                    suffix.StartsWith(".", StringComparison.Ordinal) ? suffix 
: '.' + suffix
+                );
+            }
+
+            return Path.Combine(directory.FullName, string.Concat(prefix, 
randomFileName));
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/IO/IDataInput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/IO/IDataInput.cs 
b/src/Lucene.Net/Support/IO/IDataInput.cs
new file mode 100644
index 0000000..3511038
--- /dev/null
+++ b/src/Lucene.Net/Support/IO/IDataInput.cs
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+namespace Lucene.Net.Support.IO
+{
+    /// <summary>
+    /// Equivalent to Java's DataInput interface
+    /// </summary>
+    public interface IDataInput
+    {
+        void ReadFully(byte[] b);
+        void ReadFully(byte[] b, int off, int len);
+        int SkipBytes(int n);
+        bool ReadBoolean();
+
+        /// <summary>
+        /// NOTE: This was readByte() in the JDK
+        /// </summary>
+        int ReadSByte();
+
+        /// <summary>
+        /// NOTE: This was readUnsignedByte() in the JDK
+        /// </summary>
+        byte ReadByte();
+
+        /// <summary>
+        /// NOTE: This was readShort() in the JDK
+        /// </summary>
+        short ReadInt16();
+
+        /// <summary>
+        /// NOTE: This was readUnsignedShort() in the JDK
+        /// </summary>
+        int ReadUInt16();
+        char ReadChar();
+
+        /// <summary>
+        /// NOTE: This was readInt() in the JDK
+        /// </summary>
+        int ReadInt32();
+
+        /// <summary>
+        /// NOTE: This was readLong() in the JDK
+        /// </summary>
+        long ReadInt64();
+        float ReadSingle();
+        double ReadDouble();
+        string ReadLine();
+        string ReadUTF();
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/IO/IDataOutput.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/IO/IDataOutput.cs 
b/src/Lucene.Net/Support/IO/IDataOutput.cs
new file mode 100644
index 0000000..cd9e3af
--- /dev/null
+++ b/src/Lucene.Net/Support/IO/IDataOutput.cs
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+namespace Lucene.Net.Support.IO
+{
+    /// <summary>
+    /// Equivalent to Java's DataOutut interface
+    /// </summary>
+    public interface IDataOutput
+    {
+        void Write(int b);
+        void Write(byte[] b);
+        void Write(byte[] b, int off, int len);
+        void WriteBoolean(bool v);
+        void WriteByte(int v);
+
+        /// <summary>
+        /// NOTE: This was writeShort() in the JDK
+        /// </summary>
+        void WriteInt16(int v);
+        void WriteChar(int v);
+
+        /// <summary>
+        /// NOTE: This was writeInt() in the JDK
+        /// </summary>
+        void WriteInt32(int v);
+
+        /// <summary>
+        /// NOTE: This was writeInt64() in the JDK
+        /// </summary>
+        void WriteInt64(long v);
+
+        /// <summary>
+        /// NOTE: This was writeSingle() in the JDK
+        /// </summary>
+        void WriteSingle(float v);
+        void WriteDouble(double v);
+        void WriteBytes(string s);
+        void WriteChars(string s);
+        void WriteUTF(string s);
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/IO/SafeTextWriterWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/IO/SafeTextWriterWrapper.cs 
b/src/Lucene.Net/Support/IO/SafeTextWriterWrapper.cs
new file mode 100644
index 0000000..78a7a4d
--- /dev/null
+++ b/src/Lucene.Net/Support/IO/SafeTextWriterWrapper.cs
@@ -0,0 +1,387 @@
+using System;
+using System.IO;
+#if !NETSTANDARD
+using System.Runtime.Remoting;
+#endif
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Lucene.Net.Support.IO
+{
+    /*
+        * 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.
+        */
+
+    /// <summary>
+    /// Decorates a <see cref="TextWriter"/> instance and
+    /// makes no assumptions about whether <see cref="IDisposable.Dispose"/>
+    /// has been called on the inner instance or not. Acts like a circuit 
breaker -
+    /// the first <see cref="ObjectDisposedException"/> caught turns it off and
+    /// the rest of the calls are ignored after that point until <see 
cref="Reset"/>
+    /// is called.
+    /// <para/>
+    /// The primary purpose is for using a <see cref="TextWriter"/> instance 
within a non-disposable
+    /// parent object. Since the creator of the <see cref="TextWriter"/> 
ultimately is responsible for
+    /// disposing it, our non-disposable object has no way of knowing whether 
it is safe to use the <see cref="TextWriter"/>.
+    /// Wraping the <see cref="TextWriter"/> within a <see 
cref="SafeTextWriterWrapper"/> ensures the
+    /// non-disposable object can continue to make calls to the <see 
cref="TextWriter"/> without raising
+    /// exceptions (it is presumed that the <see cref="TextWriter"/> 
functionality is optional).
+    /// </summary>
+    public class SafeTextWriterWrapper : TextWriter
+    {
+        private readonly TextWriter textWriter;
+        private bool isDisposed = false;
+
+        public SafeTextWriterWrapper(TextWriter textWriter)
+        {
+            if (textWriter == null)
+            {
+                throw new ArgumentNullException("textWriter");
+            }
+
+            this.textWriter = textWriter;
+        }
+
+        public override Encoding Encoding
+        {
+            get
+            {
+                return Run(() => textWriter.Encoding);
+            }
+        }
+
+        public override IFormatProvider FormatProvider
+        {
+            get
+            {
+                return Run(() => textWriter.FormatProvider);
+            }
+        }
+
+        public override string NewLine
+        {
+            get
+            {
+                return Run(() => textWriter.NewLine);
+            }
+
+            set
+            {
+                Run(() => textWriter.NewLine = value);
+            }
+        }
+
+#if !NETSTANDARD
+        public override void Close()
+        {
+            Run(() => textWriter.Close());
+        }
+
+        public override ObjRef CreateObjRef(Type requestedType)
+        {
+            return Run(() => textWriter.CreateObjRef(requestedType));
+        }
+#endif
+
+        public override bool Equals(object obj)
+        {
+            return Run(() => textWriter.Equals(obj));
+        }
+
+        public override void Flush()
+        {
+            Run(() => textWriter.Flush());
+        }
+
+        public override Task FlushAsync()
+        {
+            return Run(() => textWriter.FlushAsync());
+        }
+
+        public override int GetHashCode()
+        {
+            return Run(() => textWriter.GetHashCode());
+        }
+
+#if !NETSTANDARD
+        public override object InitializeLifetimeService()
+        {
+            return Run(() => textWriter.InitializeLifetimeService());
+        }
+#endif
+
+        public override string ToString()
+        {
+            return Run(() => textWriter.ToString());
+        }
+
+        public override void Write(bool value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(char value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(char[] buffer)
+        {
+            Run(() => textWriter.Write(buffer));
+        }
+
+        public override void Write(char[] buffer, int index, int count)
+        {
+            Run(() => textWriter.Write(buffer, index, count));
+        }
+
+        public override void Write(decimal value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(double value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(float value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(int value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(long value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(object value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override void Write(string format, object arg0)
+        {
+            Run(() => textWriter.Write(format, arg0));
+        }
+
+        public override void Write(string format, object arg0, object arg1)
+        {
+            Run(() => textWriter.Write(format, arg0, arg1));
+        }
+
+        public override void Write(string format, object arg0, object arg1, 
object arg2)
+        {
+            Run(() => textWriter.Write(format, arg0, arg1, arg2));
+        }
+
+        public override void Write(string format, params object[] arg)
+        {
+            Run(() => textWriter.Write(format, arg));
+        }
+
+        public override void Write(string value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        [CLSCompliant(false)]
+        public override void Write(uint value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        [CLSCompliant(false)]
+        public override void Write(ulong value)
+        {
+            Run(() => textWriter.Write(value));
+        }
+
+        public override Task WriteAsync(char value)
+        {
+            return Run(() => textWriter.WriteAsync(value));
+        }
+
+        public override Task WriteAsync(char[] buffer, int index, int count)
+        {
+            return Run(() => textWriter.WriteAsync(buffer, index, count));
+        }
+
+        public override Task WriteAsync(string value)
+        {
+            return Run(() => textWriter.WriteAsync(value));
+        }
+
+        public override void WriteLine()
+        {
+            Run(() => textWriter.WriteLine());
+        }
+
+        public override void WriteLine(bool value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(char value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(char[] buffer)
+        {
+            Run(() => textWriter.WriteLine(buffer));
+        }
+
+        public override void WriteLine(char[] buffer, int index, int count)
+        {
+            Run(() => textWriter.WriteLine(buffer, index, count));
+        }
+
+        public override void WriteLine(decimal value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(double value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(float value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(int value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(long value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(object value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override void WriteLine(string format, object arg0)
+        {
+            Run(() => textWriter.WriteLine(format, arg0));
+        }
+
+        public override void WriteLine(string format, object arg0, object arg1)
+        {
+            Run(() => textWriter.WriteLine(format, arg0, arg1));
+        }
+
+        public override void WriteLine(string format, object arg0, object 
arg1, object arg2)
+        {
+            Run(() => textWriter.WriteLine(format, arg0, arg1, arg2));
+        }
+
+        public override void WriteLine(string format, params object[] arg)
+        {
+            Run(() => textWriter.WriteLine(format, arg));
+        }
+
+        public override void WriteLine(string value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        [CLSCompliant(false)]
+        public override void WriteLine(uint value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        [CLSCompliant(false)]
+        public override void WriteLine(ulong value)
+        {
+            Run(() => textWriter.WriteLine(value));
+        }
+
+        public override Task WriteLineAsync()
+        {
+            return Run(() => textWriter.WriteLineAsync());
+        }
+
+        public override Task WriteLineAsync(char value)
+        {
+            return Run(() => textWriter.WriteLineAsync(value));
+        }
+
+        public override Task WriteLineAsync(char[] buffer, int index, int 
count)
+        {
+            return Run(() => textWriter.WriteLineAsync(buffer, index, count));
+        }
+
+        public override Task WriteLineAsync(string value)
+        {
+            return Run(() => textWriter.WriteLineAsync(value));
+        }
+
+        private void Run(Action method)
+        {
+            if (isDisposed) return;
+
+            try
+            {
+                method();
+            }
+            catch (ObjectDisposedException)
+            {
+                isDisposed = true;
+            }
+        }
+
+        private T Run<T>(Func<T> method)
+        {
+            if (isDisposed) return default(T);
+
+            try
+            {
+                return method();
+            }
+            catch (ObjectDisposedException)
+            {
+                isDisposed = true;
+                return default(T);
+            }
+        }
+
+        public virtual void Reset()
+        {
+            isDisposed = false;
+        }
+
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing)
+            {
+                textWriter.Dispose();
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/IO/StreamUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/IO/StreamUtils.cs 
b/src/Lucene.Net/Support/IO/StreamUtils.cs
new file mode 100644
index 0000000..965f50e
--- /dev/null
+++ b/src/Lucene.Net/Support/IO/StreamUtils.cs
@@ -0,0 +1,51 @@
+#if FEATURE_SERIALIZABLE
+using System.IO;
+using System.Runtime.Serialization.Formatters.Binary;
+
+namespace Lucene.Net.Support.IO
+{
+    /*
+        * 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.
+        */
+
+    public static class StreamUtils
+    {
+        static readonly BinaryFormatter formatter = new BinaryFormatter();
+
+        public static void SerializeToStream(object o, Stream outputStream)
+        {
+            formatter.Serialize(outputStream, o);
+        }
+
+        public static void SerializeToStream(object o, BinaryWriter writer)
+        {
+            formatter.Serialize(writer.BaseStream, o);
+        }
+
+        public static object DeserializeFromStream(Stream stream)
+        {
+            object o = formatter.Deserialize(stream);
+            return o;
+        }
+
+        public static object DeserializeFromStream(BinaryReader reader)
+        {
+            object o = formatter.Deserialize(reader.BaseStream);
+            return o;
+        }
+    }
+}
+#endif

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/Inflater.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/Inflater.cs 
b/src/Lucene.Net/Support/Inflater.cs
deleted file mode 100644
index 5f38db8..0000000
--- a/src/Lucene.Net/Support/Inflater.cs
+++ /dev/null
@@ -1,115 +0,0 @@
-#if !NETSTANDARD
-/*
- *
- * 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.
- *
-*/
-
-using System;
-using System.Linq;
-
-namespace Lucene.Net.Support
-{
-    public class Inflater
-    {
-        private delegate void SetInputDelegate(byte[] buffer);
-
-        private delegate bool GetIsFinishedDelegate();
-
-        private delegate int InflateDelegate(byte[] buffer);
-
-        private delegate void ResetDelegate();
-
-        private delegate void SetInputDelegate3(byte[] buffer, int index, int 
count);
-
-        private delegate int InflateDelegate3(byte[] buffer, int offset, int 
count);
-
-        private SetInputDelegate setInputMethod;
-        private GetIsFinishedDelegate getIsFinishedMethod;
-        private InflateDelegate inflateMethod;
-        private ResetDelegate resetMethod;
-        private SetInputDelegate3 setInput3Method;
-        private InflateDelegate3 inflate3Method;
-
-        internal Inflater(object inflaterInstance)
-        {
-            Type type = inflaterInstance.GetType();
-
-            setInputMethod = (SetInputDelegate)Delegate.CreateDelegate(
-                typeof(SetInputDelegate),
-                inflaterInstance,
-                type.GetMethod("SetInput", new Type[] { typeof(byte[]) }));
-
-            getIsFinishedMethod = 
(GetIsFinishedDelegate)Delegate.CreateDelegate(
-                typeof(GetIsFinishedDelegate),
-                inflaterInstance,
-                type.GetMethod("get_IsFinished", Type.EmptyTypes));
-
-            inflateMethod = (InflateDelegate)Delegate.CreateDelegate(
-                typeof(InflateDelegate),
-                inflaterInstance,
-                type.GetMethod("Inflate", new Type[] { typeof(byte[]) }));
-
-            resetMethod = (ResetDelegate)Delegate.CreateDelegate(
-                typeof(ResetDelegate),
-                inflaterInstance,
-                type.GetMethod("Reset", Type.EmptyTypes));
-
-            setInput3Method = (SetInputDelegate3)Delegate.CreateDelegate(
-                typeof(SetInputDelegate3),
-                inflaterInstance,
-                type.GetMethod("SetInput", new Type[] { typeof(byte[]), 
typeof(int), typeof(int) }));
-
-            inflate3Method = (InflateDelegate3)Delegate.CreateDelegate(
-                typeof(InflateDelegate3),
-                inflaterInstance,
-                type.GetMethod("Inflate", new Type[] { typeof(byte[]), 
typeof(int), typeof(int) }));
-        }
-
-        public void SetInput(byte[] buffer)
-        {
-            setInputMethod(buffer);
-        }
-
-        public void SetInput(byte[] buffer, int index, int count)
-        {
-            setInput3Method(buffer, index, count);
-        }
-
-        public bool IsFinished
-        {
-            get { return getIsFinishedMethod(); }
-        }
-
-        public int Inflate(byte[] buffer)
-        {
-            return inflateMethod(buffer);
-        }
-
-        public int Inflate(byte[] buffer, int offset, int count)
-        {
-            return inflate3Method(buffer, offset, count);
-        }
-
-        public void Reset()
-        {
-            resetMethod();
-        }
-    }
-}
-#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/SafeTextWriterWrapper.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/SafeTextWriterWrapper.cs 
b/src/Lucene.Net/Support/SafeTextWriterWrapper.cs
deleted file mode 100644
index f4383ff..0000000
--- a/src/Lucene.Net/Support/SafeTextWriterWrapper.cs
+++ /dev/null
@@ -1,387 +0,0 @@
-using System;
-using System.IO;
-#if !NETSTANDARD
-using System.Runtime.Remoting;
-#endif
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Lucene.Net.Support
-{
-    /*
-        * 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.
-        */
-
-    /// <summary>
-    /// Decorates a <see cref="TextWriter"/> instance and
-    /// makes no assumptions about whether <see cref="IDisposable.Dispose"/>
-    /// has been called on the inner instance or not. Acts like a circuit 
breaker -
-    /// the first <see cref="ObjectDisposedException"/> caught turns it off and
-    /// the rest of the calls are ignored after that point until <see 
cref="Reset"/>
-    /// is called.
-    /// <para/>
-    /// The primary purpose is for using a <see cref="TextWriter"/> instance 
within a non-disposable
-    /// parent object. Since the creator of the <see cref="TextWriter"/> 
ultimately is responsible for
-    /// disposing it, our non-disposable object has no way of knowing whether 
it is safe to use the <see cref="TextWriter"/>.
-    /// Wraping the <see cref="TextWriter"/> within a <see 
cref="SafeTextWriterWrapper"/> ensures the
-    /// non-disposable object can continue to make calls to the <see 
cref="TextWriter"/> without raising
-    /// exceptions (it is presumed that the <see cref="TextWriter"/> 
functionality is optional).
-    /// </summary>
-    public class SafeTextWriterWrapper : TextWriter
-    {
-        private readonly TextWriter textWriter;
-        private bool isDisposed = false;
-
-        public SafeTextWriterWrapper(TextWriter textWriter)
-        {
-            if (textWriter == null)
-            {
-                throw new ArgumentNullException("textWriter");
-            }
-
-            this.textWriter = textWriter;
-        }
-
-        public override Encoding Encoding
-        {
-            get
-            {
-                return Run(() => textWriter.Encoding);
-            }
-        }
-
-        public override IFormatProvider FormatProvider
-        {
-            get
-            {
-                return Run(() => textWriter.FormatProvider);
-            }
-        }
-
-        public override string NewLine
-        {
-            get
-            {
-                return Run(() => textWriter.NewLine);
-            }
-
-            set
-            {
-                Run(() => textWriter.NewLine = value);
-            }
-        }
-
-#if !NETSTANDARD
-        public override void Close()
-        {
-            Run(() => textWriter.Close());
-        }
-
-        public override ObjRef CreateObjRef(Type requestedType)
-        {
-            return Run(() => textWriter.CreateObjRef(requestedType));
-        }
-#endif
-
-        public override bool Equals(object obj)
-        {
-            return Run(() => textWriter.Equals(obj));
-        }
-
-        public override void Flush()
-        {
-            Run(() => textWriter.Flush());
-        }
-
-        public override Task FlushAsync()
-        {
-            return Run(() => textWriter.FlushAsync());
-        }
-
-        public override int GetHashCode()
-        {
-            return Run(() => textWriter.GetHashCode());
-        }
-
-#if !NETSTANDARD
-        public override object InitializeLifetimeService()
-        {
-            return Run(() => textWriter.InitializeLifetimeService());
-        }
-#endif
-
-        public override string ToString()
-        {
-            return Run(() => textWriter.ToString());
-        }
-
-        public override void Write(bool value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(char value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(char[] buffer)
-        {
-            Run(() => textWriter.Write(buffer));
-        }
-
-        public override void Write(char[] buffer, int index, int count)
-        {
-            Run(() => textWriter.Write(buffer, index, count));
-        }
-
-        public override void Write(decimal value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(double value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(float value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(int value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(long value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(object value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override void Write(string format, object arg0)
-        {
-            Run(() => textWriter.Write(format, arg0));
-        }
-
-        public override void Write(string format, object arg0, object arg1)
-        {
-            Run(() => textWriter.Write(format, arg0, arg1));
-        }
-
-        public override void Write(string format, object arg0, object arg1, 
object arg2)
-        {
-            Run(() => textWriter.Write(format, arg0, arg1, arg2));
-        }
-
-        public override void Write(string format, params object[] arg)
-        {
-            Run(() => textWriter.Write(format, arg));
-        }
-
-        public override void Write(string value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        [CLSCompliant(false)]
-        public override void Write(uint value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        [CLSCompliant(false)]
-        public override void Write(ulong value)
-        {
-            Run(() => textWriter.Write(value));
-        }
-
-        public override Task WriteAsync(char value)
-        {
-            return Run(() => textWriter.WriteAsync(value));
-        }
-
-        public override Task WriteAsync(char[] buffer, int index, int count)
-        {
-            return Run(() => textWriter.WriteAsync(buffer, index, count));
-        }
-
-        public override Task WriteAsync(string value)
-        {
-            return Run(() => textWriter.WriteAsync(value));
-        }
-
-        public override void WriteLine()
-        {
-            Run(() => textWriter.WriteLine());
-        }
-
-        public override void WriteLine(bool value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(char value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(char[] buffer)
-        {
-            Run(() => textWriter.WriteLine(buffer));
-        }
-
-        public override void WriteLine(char[] buffer, int index, int count)
-        {
-            Run(() => textWriter.WriteLine(buffer, index, count));
-        }
-
-        public override void WriteLine(decimal value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(double value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(float value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(int value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(long value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(object value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override void WriteLine(string format, object arg0)
-        {
-            Run(() => textWriter.WriteLine(format, arg0));
-        }
-
-        public override void WriteLine(string format, object arg0, object arg1)
-        {
-            Run(() => textWriter.WriteLine(format, arg0, arg1));
-        }
-
-        public override void WriteLine(string format, object arg0, object 
arg1, object arg2)
-        {
-            Run(() => textWriter.WriteLine(format, arg0, arg1, arg2));
-        }
-
-        public override void WriteLine(string format, params object[] arg)
-        {
-            Run(() => textWriter.WriteLine(format, arg));
-        }
-
-        public override void WriteLine(string value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        [CLSCompliant(false)]
-        public override void WriteLine(uint value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        [CLSCompliant(false)]
-        public override void WriteLine(ulong value)
-        {
-            Run(() => textWriter.WriteLine(value));
-        }
-
-        public override Task WriteLineAsync()
-        {
-            return Run(() => textWriter.WriteLineAsync());
-        }
-
-        public override Task WriteLineAsync(char value)
-        {
-            return Run(() => textWriter.WriteLineAsync(value));
-        }
-
-        public override Task WriteLineAsync(char[] buffer, int index, int 
count)
-        {
-            return Run(() => textWriter.WriteLineAsync(buffer, index, count));
-        }
-
-        public override Task WriteLineAsync(string value)
-        {
-            return Run(() => textWriter.WriteLineAsync(value));
-        }
-
-        private void Run(Action method)
-        {
-            if (isDisposed) return;
-
-            try
-            {
-                method();
-            }
-            catch (ObjectDisposedException)
-            {
-                isDisposed = true;
-            }
-        }
-
-        private T Run<T>(Func<T> method)
-        {
-            if (isDisposed) return default(T);
-
-            try
-            {
-                return method();
-            }
-            catch (ObjectDisposedException)
-            {
-                isDisposed = true;
-                return default(T);
-            }
-        }
-
-        public virtual void Reset()
-        {
-            isDisposed = false;
-        }
-
-        protected override void Dispose(bool disposing)
-        {
-            if (disposing)
-            {
-                textWriter.Dispose();
-            }
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/SharpZipLib.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/SharpZipLib.cs 
b/src/Lucene.Net/Support/SharpZipLib.cs
deleted file mode 100644
index 0ae3d06..0000000
--- a/src/Lucene.Net/Support/SharpZipLib.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-#if NET35
-/*
- *
- * 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.
- *
-*/
-
-using System.Reflection;
-
-namespace Lucene.Net.Support
-{
-    public class SharpZipLib
-    {
-        private static System.Reflection.Assembly asm = null;
-
-        static SharpZipLib()
-        {
-            try
-            {
-                asm = Assembly.Load("ICSharpCode.SharpZipLib");
-            }
-            catch { }
-        }
-
-        public static Deflater CreateDeflater()
-        {
-            if (asm == null) throw new System.IO.FileNotFoundException("Can 
not load ICSharpCode.SharpZipLib.dll");
-            return new 
Deflater(asm.CreateInstance("ICSharpCode.SharpZipLib.Zip.Compression.Deflater"));
-        }
-
-        public static Inflater CreateInflater()
-        {
-            if (asm == null) throw new System.IO.FileNotFoundException("Can 
not load ICSharpCode.SharpZipLib.dll");
-            return new 
Inflater(asm.CreateInstance("ICSharpCode.SharpZipLib.Zip.Compression.Inflater"));
-        }
-    }
-}
-#endif
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Support/StreamUtils.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Support/StreamUtils.cs 
b/src/Lucene.Net/Support/StreamUtils.cs
deleted file mode 100644
index 5b9ef0e..0000000
--- a/src/Lucene.Net/Support/StreamUtils.cs
+++ /dev/null
@@ -1,51 +0,0 @@
-#if FEATURE_SERIALIZABLE
-using System.IO;
-using System.Runtime.Serialization.Formatters.Binary;
-
-namespace Lucene.Net.Support
-{
-    /*
-        * 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.
-        */
-
-    public static class StreamUtils
-    {
-        static readonly BinaryFormatter formatter = new BinaryFormatter();
-
-        public static void SerializeToStream(object o, Stream outputStream)
-        {
-            formatter.Serialize(outputStream, o);
-        }
-
-        public static void SerializeToStream(object o, BinaryWriter writer)
-        {
-            formatter.Serialize(writer.BaseStream, o);
-        }
-
-        public static object DeserializeFromStream(Stream stream)
-        {
-            object o = formatter.Deserialize(stream);
-            return o;
-        }
-
-        public static object DeserializeFromStream(BinaryReader reader)
-        {
-            object o = formatter.Deserialize(reader.BaseStream);
-            return o;
-        }
-    }
-}
-#endif

http://git-wip-us.apache.org/repos/asf/lucenenet/blob/37901853/src/Lucene.Net/Util/OfflineSorter.cs
----------------------------------------------------------------------
diff --git a/src/Lucene.Net/Util/OfflineSorter.cs 
b/src/Lucene.Net/Util/OfflineSorter.cs
index 7c8f427..9eca503 100644
--- a/src/Lucene.Net/Util/OfflineSorter.cs
+++ b/src/Lucene.Net/Util/OfflineSorter.cs
@@ -1,6 +1,6 @@
 using Lucene.Net.Store;
 using Lucene.Net.Support;
-using Lucene.Net.Support.Compatibility;
+using Lucene.Net.Support.IO;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;

Reply via email to