Browse Source

[corlib] Text streams from reference sources

Marek Safar 11 năm trước cách đây
mục cha
commit
65347a166e

+ 1 - 1
external/referencesource

@@ -1 +1 @@
-Subproject commit 1f0908dddc1266b943a4259e6a822b4268e5d791
+Subproject commit 5ca0db753ca296eac802e839becd09780640f9e4

+ 1 - 1
mcs/class/corlib/Makefile

@@ -38,7 +38,7 @@ RESOURCE_FILES = \
 	resources/collation.cjkKO.bin \
 	resources/collation.cjkKOlv2.bin
 
-REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO
+REFERENCE_SOURCES_FLAGS = -d:FEATURE_PAL,GENERICS_WORK,FEATURE_LIST_PREDICATES,FEATURE_SERIALIZATION,FEATURE_ASCII,FEATURE_LATIN1,FEATURE_UTF7,FEATURE_UTF32,MONO_HYBRID_ENCODING_SUPPORT,FEATURE_ASYNC_IO,NEW_EXPERIMENTAL_ASYNC_IO,FEATURE_UTF32
 
 MOBILE_STATIC := $(filter mobile_static monotouch monotouch_runtime, $(PROFILE))
 

+ 6 - 0
mcs/class/corlib/ReferenceSources/__ConsoleStream.cs

@@ -0,0 +1,6 @@
+namespace System.IO
+{
+	sealed class __ConsoleStream
+	{
+	}
+}

+ 5 - 0
mcs/class/corlib/System.IO/FileStream.cs

@@ -148,6 +148,11 @@ namespace System.IO
 		}
 #endif
 
+		internal FileStream (string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, string msgPath, bool bFromProxy, bool useLongPath, bool checkHost)
+			: this (path, mode, access, share, bufferSize, false, options)
+		{
+		}
+
 		internal FileStream (string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool isAsync, bool anonymous)
 			: this (path, mode, access, share, bufferSize, anonymous, isAsync ? FileOptions.Asynchronous : FileOptions.None)
 		{

+ 0 - 755
mcs/class/corlib/System.IO/StreamReader.cs

@@ -1,755 +0,0 @@
-//
-// System.IO.StreamReader.cs
-//
-// Authors:
-//   Dietmar Maurer ([email protected])
-//   Miguel de Icaza ([email protected]) 
-//   Marek Safar ([email protected])
-//
-// (C) Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004 Novell (http://www.novell.com)
-// Copyright 2011, 2013 Xamarin Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Text;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace System.IO {
-	[Serializable]
-	[ComVisible (true)]
-	public class StreamReader : TextReader
-	{
-		sealed class NullStreamReader : StreamReader
-		{
-			internal NullStreamReader ()
-			{
-				base_stream = Stream.Null;
-			}
-
-			public override int Peek ()
-			{
-				return -1;
-			}
-
-			public override int Read ()
-			{
-				return -1;
-			}
-
-			public override int Read ([In, Out] char[] buffer, int index, int count)
-			{
-				return 0;
-			}
-
-			public override string ReadLine ()
-			{
-				return null;
-			}
-
-			public override string ReadToEnd ()
-			{
-				return String.Empty;
-			}
-
-			public override Stream BaseStream {
-				get { return Stream.Null; }
-			}
-
-			public override Encoding CurrentEncoding {
-				get { return Encoding.Unicode; }
-			}
-		}
-
-		const int DefaultBufferSize = 1024;
-		const int DefaultFileBufferSize = 4096;
-		const int MinimumBufferSize = 128;
-
-		//
-		// The input buffer
-		//
-		byte [] input_buffer;
-		
-		// Input buffer ready for recycling
-		static byte [] input_buffer_recycle;
-		static object input_buffer_recycle_lock = new object ();
-
-		//
-		// The decoded buffer from the above input buffer
-		//
-		char [] decoded_buffer;
-		static char[] decoded_buffer_recycle;
-
-		Encoding encoding;
-		Decoder decoder;
-		StringBuilder line_builder;
-		Stream base_stream;
-
-		//
-		// Decoded bytes in decoded_buffer.
-		//
-		int decoded_count;
-
-		//
-		// Current position in the decoded_buffer
-		//
-		int pos;
-
-		//
-		// The buffer size that we are using
-		//
-		int buffer_size;
-
-		int do_checks;
-		
-		bool mayBlock;
-
-		IDecoupledTask async_task;
-		readonly bool leave_open;
-
-		public new static readonly StreamReader Null =  new NullStreamReader ();
-		
-		private StreamReader() {}
-
-		public StreamReader(Stream stream)
-			: this (stream, Encoding.UTF8, true, DefaultBufferSize) { }
-
-		public StreamReader(Stream stream, bool detectEncodingFromByteOrderMarks)
-			: this (stream, Encoding.UTF8, detectEncodingFromByteOrderMarks, DefaultBufferSize) { }
-
-		public StreamReader(Stream stream, Encoding encoding)
-			: this (stream, encoding, true, DefaultBufferSize) { }
-
-		public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks)
-			: this (stream, encoding, detectEncodingFromByteOrderMarks, DefaultBufferSize) { }
-
-		public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize)
-			: this (stream, encoding, detectEncodingFromByteOrderMarks, bufferSize, false)
-		{
-		}
-
-		public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen)
-		{
-			leave_open = leaveOpen;
-			Initialize (stream, encoding, detectEncodingFromByteOrderMarks, bufferSize);
-		}
-
-		public StreamReader(string path)
-			: this (path, Encoding.UTF8, true, DefaultFileBufferSize) { }
-
-		public StreamReader(string path, bool detectEncodingFromByteOrderMarks)
-			: this (path, Encoding.UTF8, detectEncodingFromByteOrderMarks, DefaultFileBufferSize) { }
-
-		public StreamReader(string path, Encoding encoding)
-			: this (path, encoding, true, DefaultFileBufferSize) { }
-
-		public StreamReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks)
-			: this (path, encoding, detectEncodingFromByteOrderMarks, DefaultFileBufferSize) { }
-		
-		public StreamReader(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize)
-		{
-			if (null == path)
-				throw new ArgumentNullException("path");
-			if (String.Empty == path)
-				throw new ArgumentException("Empty path not allowed");
-			if (path.IndexOfAny (Path.InvalidPathChars) != -1)
-				throw new ArgumentException("path contains invalid characters");
-			if (null == encoding)
-				throw new ArgumentNullException ("encoding");
-			if (bufferSize <= 0)
-				throw new ArgumentOutOfRangeException ("bufferSize", "The minimum size of the buffer must be positive");
-
-			Stream stream = (Stream) File.OpenRead (path);
-			Initialize (stream, encoding, detectEncodingFromByteOrderMarks, bufferSize);
-		}
-
-		internal void Initialize (Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize)
-		{
-			if (null == stream)
-				throw new ArgumentNullException ("stream");
-			if (null == encoding)
-				throw new ArgumentNullException ("encoding");
-			if (!stream.CanRead)
-				throw new ArgumentException ("Cannot read stream");
-			if (bufferSize <= 0)
-				throw new ArgumentOutOfRangeException ("bufferSize", "The minimum size of the buffer must be positive");
-
-			if (bufferSize < MinimumBufferSize)
-				bufferSize = MinimumBufferSize;
-			
-			// since GetChars() might add flushed character, it 
-			// should have additional char buffer for extra 1 
-			// (probably 1 is ok, but might be insufficient. I'm not sure)
-			var decoded_buffer_size = encoding.GetMaxCharCount (bufferSize) + 1;
-
-			//
-			// Instead of allocating a new default buffer use the
-			// last one if there is any available
-			//
-			if (bufferSize <= DefaultBufferSize && input_buffer_recycle != null) {
-				lock (input_buffer_recycle_lock) {
-					if (input_buffer_recycle != null) {
-						input_buffer = input_buffer_recycle;
-						input_buffer_recycle = null;
-					}
-					
-					if (decoded_buffer_recycle != null && decoded_buffer_size <= decoded_buffer_recycle.Length) {
-						decoded_buffer = decoded_buffer_recycle;
-						decoded_buffer_recycle = null;
-					}
-				}
-			}
-			
-			if (input_buffer == null)
-				input_buffer = new byte [bufferSize];
-			else
-				Array.Clear (input_buffer, 0, bufferSize);
-			
-			if (decoded_buffer == null)
-				decoded_buffer = new char [decoded_buffer_size];
-			else
-				Array.Clear (decoded_buffer, 0, decoded_buffer_size);
-
-			base_stream = stream;		
-			this.buffer_size = bufferSize;
-			this.encoding = encoding;
-			decoder = encoding.GetDecoder ();
-
-			byte [] preamble = encoding.GetPreamble ();
-			do_checks = detectEncodingFromByteOrderMarks ? 1 : 0;
-			do_checks += (preamble.Length == 0) ? 0 : 2;
-			
-			decoded_count = 0;
-			pos = 0;
-		}
-
-		public virtual Stream BaseStream {
-			get {
-				return base_stream;
-			}
-		}
-
-		public virtual Encoding CurrentEncoding {
-			get {
-				return encoding;
-			}
-		}
-
-		public bool EndOfStream {
-			get { return Peek () < 0; }
-		}
-
-		public override void Close ()
-		{
-			Dispose (true);
-		}
-
-		protected override void Dispose (bool disposing)
-		{
-			if (disposing && base_stream != null && !leave_open)
-				base_stream.Close ();
-			
-			if (input_buffer != null && input_buffer.Length == DefaultBufferSize && input_buffer_recycle == null) {
-				lock (input_buffer_recycle_lock) {
-					if (input_buffer_recycle == null) {
-						input_buffer_recycle = input_buffer;
-					}
-					
-					if (decoded_buffer_recycle == null) {
-						decoded_buffer_recycle = decoded_buffer;
-					}
-				}
-			}
-			
-			input_buffer = null;
-			decoded_buffer = null;
-			encoding = null;
-			decoder = null;
-			base_stream = null;
-			base.Dispose (disposing);
-		}
-
-		//
-		// Provides auto-detection of the encoding, as well as skipping over
-		// byte marks at the beginning of a stream.
-		//
-		int DoChecks (int count)
-		{
-			if ((do_checks & 2) == 2){
-				byte [] preamble = encoding.GetPreamble ();
-				int c = preamble.Length;
-				if (count >= c){
-					int i;
-					
-					for (i = 0; i < c; i++)
-						if (input_buffer [i] != preamble [i])
-							break;
-
-					if (i == c)
-						return i;
-				}
-			}
-
-			if ((do_checks & 1) == 1){
-				if (count < 2)
-					return 0;
-
-				if (input_buffer [0] == 0xfe && input_buffer [1] == 0xff){
-					this.encoding = Encoding.BigEndianUnicode;
-					return 2;
-				}
-				if (input_buffer [0] == 0xff && input_buffer [1] == 0xfe && count < 4) {
-					// If we don't have enough bytes we can't check for UTF32, so use Unicode
-					this.encoding = Encoding.Unicode;
-					return 2;
-				}
-
-				if (count < 3)
-					return 0;
-
-				if (input_buffer [0] == 0xef && input_buffer [1] == 0xbb && input_buffer [2] == 0xbf){
-					this.encoding = EncodingHelper.UTF8Unmarked;
-					return 3;
-				}
-
-				if (count < 4) {
-					if (input_buffer [0] == 0xff && input_buffer [1] == 0xfe && input_buffer [2] != 0) {
-						this.encoding = Encoding.Unicode;
-						return 2;
-					}
-					return 0;
-				}
-
-				if (input_buffer [0] == 0 && input_buffer [1] == 0
-					&& input_buffer [2] == 0xfe && input_buffer [3] == 0xff)
-				{
-					this.encoding = EncodingHelper.BigEndianUTF32;
-					return 4;
-				}
-
-				if (input_buffer [0] == 0xff && input_buffer [1] == 0xfe) {
-					if (input_buffer [2] == 0 && input_buffer[3] == 0) {
-						this.encoding = Encoding.UTF32;
-						return 4;
-					}
-
-					this.encoding = Encoding.Unicode;
-					return 2;
-				}
-			}
-
-			return 0;
-		}
-
-		public void DiscardBufferedData ()
-		{
-			CheckState ();
-
-			pos = decoded_count = 0;
-			mayBlock = false;
-			// Discard internal state of the decoder too.
-			decoder = encoding.GetDecoder ();
-		}
-		
-		// the buffer is empty, fill it again
-		// Keep in sync with ReadBufferAsync
-		int ReadBuffer ()
-		{
-			pos = 0;
-
-			// keep looping until the decoder gives us some chars
-			decoded_count = 0;
-			do {
-				var cbEncoded = base_stream.Read (input_buffer, 0, buffer_size);
-				if (cbEncoded <= 0)
-					return 0;
-
-				decoded_count = ReadBufferCore (cbEncoded);
-			} while (decoded_count == 0);
-
-			return decoded_count;
-		}
-
-		int ReadBufferCore (int cbEncoded)
-		{
-			int parse_start;
-
-			mayBlock = cbEncoded < buffer_size;
-			if (do_checks > 0){
-				Encoding old = encoding;
-				parse_start = DoChecks (cbEncoded);
-				if (old != encoding){
-					int old_decoded_size = old.GetMaxCharCount (buffer_size) + 1;
-					int new_decoded_size = encoding.GetMaxCharCount (buffer_size) + 1;
-					if (old_decoded_size != new_decoded_size)
-						decoded_buffer = new char [new_decoded_size];
-					decoder = encoding.GetDecoder ();
-				}
-				do_checks = 0;
-				cbEncoded -= parse_start;
-			} else {
-				parse_start = 0;
-			}
-				
-			return decoder.GetChars (input_buffer, parse_start, cbEncoded, decoded_buffer, 0);
-		}
-
-		//
-		// Peek can block:
-		// http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=96484
-		//
-		public override int Peek ()
-		{
-			CheckState ();
-
-			if (pos >= decoded_count && ReadBuffer () == 0)
-				return -1;
-
-			return decoded_buffer [pos];
-		}
-
-		//
-		// Used internally by our console, as it previously depended on Peek() being a
-		// routine that would not block.
-		//
-		internal bool DataAvailable ()
-		{
-			return pos < decoded_count;
-		}
-		
-		public override int Read ()
-		{
-			CheckState ();
-
-			if (pos >= decoded_count && ReadBuffer () == 0)
-				return -1;
-
-			return decoded_buffer [pos++];
-		}
-
-		// Keep in sync with ReadAsync
-		public override int Read ([In, Out] char[] buffer, int index, int count)
-		{
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0)
-				throw new ArgumentOutOfRangeException ("index", "< 0");
-			if (count < 0)
-				throw new ArgumentOutOfRangeException ("count", "< 0");
-			// re-ordered to avoid possible integer overflow
-			if (index > buffer.Length - count)
-				throw new ArgumentException ("index + count > buffer.Length");
-
-			CheckState ();
-
-			int chars_read = 0;
-			while (count > 0) {
-				if (pos >= decoded_count && ReadBuffer () == 0)
-					return chars_read > 0 ? chars_read : 0;
-
-				int cch = Math.Min (decoded_count - pos, count);
-				Array.Copy (decoded_buffer, pos, buffer, index, cch);
-				pos += cch;
-				index += cch;
-				count -= cch;
-				chars_read += cch;
-				if (mayBlock)
-					break;
-			}
-			return chars_read;
-		}
-
-		bool foundCR;
-		int FindNextEOL ()
-		{
-			char c = '\0';
-			for (; pos < decoded_count; pos++) {
-				c = decoded_buffer [pos];
-				if (c == '\n') {
-					pos++;
-					int res = (foundCR) ? (pos - 2) : (pos - 1);
-					if (res < 0)
-						res = 0; // if a new buffer starts with a \n and there was a \r at
-							// the end of the previous one, we get here.
-					foundCR = false;
-					return res;
-				} else if (foundCR) {
-					foundCR = false;
-					if (pos == 0)
-						return -2; // Need to flush the current buffered line.
-							   // This is a \r at the end of the previous decoded buffer that
-							   // is not followed by a \n in the current decoded buffer.
-					return pos - 1;
-				}
-
-				foundCR = (c == '\r');
-			}
-
-			return -1;
-		}
-
-		// Keep in sync with ReadLineAsync
-		public override string ReadLine()
-		{
-			CheckState ();
-
-			if (pos >= decoded_count && ReadBuffer () == 0)
-				return null;
-
-			int begin = pos;
-			int end = FindNextEOL ();
-			if (end < decoded_count && end >= begin)
-				return new string (decoded_buffer, begin, end - begin);
-			if (end == -2)
-				return line_builder.ToString (0, line_builder.Length);
-
-			if (line_builder == null)
-				line_builder = new StringBuilder ();
-			else
-				line_builder.Length = 0;
-
-			while (true) {
-				if (foundCR) // don't include the trailing CR if present
-					decoded_count--;
-
-				line_builder.Append (decoded_buffer, begin, decoded_count - begin);
-				if (ReadBuffer () == 0) {
-					if (line_builder.Capacity > 32768) {
-						StringBuilder sb = line_builder;
-						line_builder = null;
-						return sb.ToString (0, sb.Length);
-					}
-					return line_builder.ToString (0, line_builder.Length);
-				}
-
-				begin = pos;
-				end = FindNextEOL ();
-				if (end < decoded_count && end >= begin) {
-					line_builder.Append (decoded_buffer, begin, end - begin);
-					if (line_builder.Capacity > 32768) {
-						StringBuilder sb = line_builder;
-						line_builder = null;
-						return sb.ToString (0, sb.Length);
-					}
-					return line_builder.ToString (0, line_builder.Length);
-				}
-
-				if (end == -2)
-					return line_builder.ToString (0, line_builder.Length);
-			}
-		}
-
-		// Keep in sync with ReadToEndAsync
-		public override string ReadToEnd()
-		{
-			CheckState ();
-
-			StringBuilder text = new StringBuilder ();
-
-			do {
-				text.Append (decoded_buffer, pos, decoded_count - pos);
-			} while (ReadBuffer () != 0);
-
-			return text.ToString ();
-		}
-
-		void CheckState ()
-		{
-			if (base_stream == null)
-				throw new ObjectDisposedException ("StreamReader", "Cannot read from a closed StreamReader");
-
-			if (async_task != null && !async_task.IsCompleted)
-				throw new InvalidOperationException ();
-		}
-
-		public override int ReadBlock ([In, Out] char[] buffer, int index, int count)
-		{
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0)
-				throw new ArgumentOutOfRangeException ("index", "< 0");
-			if (count < 0)
-				throw new ArgumentOutOfRangeException ("count", "< 0");
-			// re-ordered to avoid possible integer overflow
-			if (index > buffer.Length - count)
-				throw new ArgumentException ("index + count > buffer.Length");
-
-			CheckState ();
-
-			return base.ReadBlock (buffer, index, count);
-		}
-
-		public override Task<int> ReadAsync (char[] buffer, int index, int count)
-		{
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0)
-				throw new ArgumentOutOfRangeException ("index", "< 0");
-			if (count < 0)
-				throw new ArgumentOutOfRangeException ("count", "< 0");
-			// re-ordered to avoid possible integer overflow
-			if (index > buffer.Length - count)
-				throw new ArgumentException ("index + count > buffer.Length");
-
-			CheckState ();
-
-			DecoupledTask<int> res;
-			async_task = res = new DecoupledTask<int> (ReadAsyncCore (buffer, index, count));
-			return res.Task;
-		}
-
-		async Task<int> ReadAsyncCore (char[] buffer, int index, int count)
-		{
-			int chars_read = 0;
-
-			while (count > 0) {
-				if (pos >= decoded_count && await ReadBufferAsync ().ConfigureAwait (false) == 0)
-					return chars_read > 0 ? chars_read : 0;
-
-				int cch = Math.Min (decoded_count - pos, count);
-				Array.Copy (decoded_buffer, pos, buffer, index, cch);
-				pos += cch;
-				index += cch;
-				count -= cch;
-				chars_read += cch;
-				if (mayBlock)
-					break;
-			}
-
-			return chars_read;
-		}
-
-		public override Task<int> ReadBlockAsync (char[] buffer, int index, int count)
-		{
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0)
-				throw new ArgumentOutOfRangeException ("index", "< 0");
-			if (count < 0)
-				throw new ArgumentOutOfRangeException ("count", "< 0");
-			// re-ordered to avoid possible integer overflow
-			if (index > buffer.Length - count)
-				throw new ArgumentException ("index + count > buffer.Length");
-
-			CheckState ();
-
-			DecoupledTask<int> res;
-			async_task = res = new DecoupledTask<int> (ReadAsyncCore (buffer, index, count));
-			return res.Task;
-		}
-
-		public override Task<string> ReadLineAsync ()
-		{
-			CheckState ();
-
-			DecoupledTask<string> res;
-			async_task = res = new DecoupledTask<string> (ReadLineAsyncCore ());
-			return res.Task;
-		}
-
-		async Task<string> ReadLineAsyncCore ()
-		{
-			if (pos >= decoded_count && await ReadBufferAsync ().ConfigureAwait (false) == 0)
-				return null;
-
-			int begin = pos;
-			int end = FindNextEOL ();
-			if (end < decoded_count && end >= begin)
-				return new string (decoded_buffer, begin, end - begin);
-			if (end == -2)
-				return line_builder.ToString (0, line_builder.Length);
-
-			if (line_builder == null)
-				line_builder = new StringBuilder ();
-			else
-				line_builder.Length = 0;
-
-			while (true) {
-				if (foundCR) // don't include the trailing CR if present
-					decoded_count--;
-
-				line_builder.Append (decoded_buffer, begin, decoded_count - begin);
-				if (await ReadBufferAsync ().ConfigureAwait (false) == 0) {
-					if (line_builder.Capacity > 32768) {
-						StringBuilder sb = line_builder;
-						line_builder = null;
-						return sb.ToString (0, sb.Length);
-					}
-					return line_builder.ToString (0, line_builder.Length);
-				}
-
-				begin = pos;
-				end = FindNextEOL ();
-				if (end < decoded_count && end >= begin) {
-					line_builder.Append (decoded_buffer, begin, end - begin);
-					if (line_builder.Capacity > 32768) {
-						StringBuilder sb = line_builder;
-						line_builder = null;
-						return sb.ToString (0, sb.Length);
-					}
-					return line_builder.ToString (0, line_builder.Length);
-				}
-
-				if (end == -2)
-					return line_builder.ToString (0, line_builder.Length);
-			}
-		}
-
-		public override Task<string> ReadToEndAsync ()
-		{
-			CheckState ();
-
-			DecoupledTask<string> res;
-			async_task = res = new DecoupledTask<string> (ReadToEndAsyncCore ());
-			return res.Task;
-		}
-
-		async Task<string> ReadToEndAsyncCore ()
-		{
-			StringBuilder text = new StringBuilder ();
-
-			do {
-				text.Append (decoded_buffer, pos, decoded_count - pos);
-			} while (await ReadBufferAsync () != 0);
-
-			return text.ToString ();
-		}
-
-		async Task<int> ReadBufferAsync ()
-		{
-			pos = 0;
-
-			// keep looping until the decoder gives us some chars
-			decoded_count = 0;
-			do {
-				var cbEncoded = await base_stream.ReadAsync (input_buffer, 0, buffer_size).ConfigureAwait (false);
-				if (cbEncoded <= 0)
-					return 0;
-
-				decoded_count = ReadBufferCore (cbEncoded);
-			} while (decoded_count == 0);
-
-			return decoded_count;
-		}
-	}
-}

+ 0 - 546
mcs/class/corlib/System.IO/StreamWriter.cs

@@ -1,546 +0,0 @@
-//
-// System.IO.StreamWriter.cs
-//
-// Authors:
-//   Dietmar Maurer ([email protected])
-//   Paolo Molaro ([email protected])
-//   Marek Safar ([email protected])
-//
-// (C) Ximian, Inc.  http://www.ximian.com
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright 2011, 2013 Xamarin Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Text;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace System.IO {
-	
-	[Serializable]
-	[ComVisible (true)]
-	public class StreamWriter : TextWriter {
-
-		private Encoding internalEncoding;
-
-		private Stream internalStream;
-
-		private const int DefaultBufferSize = 1024;
-		private const int DefaultFileBufferSize = 4096;
-		private const int MinimumBufferSize = 256;
-
-		private byte[] byte_buf;
-		private char[] decode_buf;
-		private int byte_pos;
-		private int decode_pos;
-
-		private bool iflush;
-		private bool preamble_done;
-
-		readonly bool leave_open;
-		IDecoupledTask async_task;
-
-		public new static readonly StreamWriter Null = new StreamWriter (Stream.Null, EncodingHelper.UTF8Unmarked, 1);
-
-		public StreamWriter (Stream stream)
-			: this (stream, EncodingHelper.UTF8Unmarked, DefaultBufferSize) {}
-
-		public StreamWriter (Stream stream, Encoding encoding)
-			: this (stream, encoding, DefaultBufferSize) {}
-
-		internal void Initialize(Encoding encoding, int bufferSize) {
-			internalEncoding = encoding;
-			decode_pos = byte_pos = 0;
-			int BufferSize = Math.Max(bufferSize, MinimumBufferSize);
-			decode_buf = new char [BufferSize];
-			byte_buf = new byte [encoding.GetMaxByteCount (BufferSize)];
-
-			// Fixes bug http://bugzilla.ximian.com/show_bug.cgi?id=74513
-			if (internalStream.CanSeek && internalStream.Position > 0)
-				preamble_done = true;
-		}
-
-		public StreamWriter (Stream stream, Encoding encoding, int bufferSize)
-			: this (stream, encoding, bufferSize, false)
-		{
-		}
-		
-		public StreamWriter (Stream stream, Encoding encoding, int bufferSize, bool leaveOpen)
-		{
-			if (null == stream)
-				throw new ArgumentNullException("stream");
-			if (null == encoding)
-				throw new ArgumentNullException("encoding");
-			if (bufferSize <= 0)
-				throw new ArgumentOutOfRangeException("bufferSize");
-			if (!stream.CanWrite)
-				throw new ArgumentException ("Can not write to stream");
-
-			leave_open = leaveOpen;
-			internalStream = stream;
-
-			Initialize(encoding, bufferSize);
-		}
-
-		public StreamWriter (string path)
-			: this (path, false, EncodingHelper.UTF8Unmarked, DefaultFileBufferSize) {}
-
-		public StreamWriter (string path, bool append)
-			: this (path, append, EncodingHelper.UTF8Unmarked, DefaultFileBufferSize) {}
-
-		public StreamWriter (string path, bool append, Encoding encoding)
-			: this (path, append, encoding, DefaultFileBufferSize) {}
-
-		public StreamWriter (string path, bool append, Encoding encoding, int bufferSize)
-		{
-			if (null == encoding)
-				throw new ArgumentNullException("encoding");
-			if (bufferSize <= 0)
-				throw new ArgumentOutOfRangeException("bufferSize");
-
-			FileMode mode;
-
-			if (append)
-				mode = FileMode.Append;
-			else
-				mode = FileMode.Create;
-			
-			internalStream = new FileStream (path, mode, FileAccess.Write, FileShare.Read);
-
-			if (append)
-				internalStream.Position = internalStream.Length;
-			else
-				internalStream.SetLength (0);
-
-			Initialize(encoding, bufferSize);
-		}
-
-		public virtual bool AutoFlush {
-			get {
-				return iflush;
-			}
-			set {
-				iflush = value;
-				if (iflush)
-					Flush ();
-			}
-		}
-
-		public virtual Stream BaseStream {
-			get {
-				return internalStream;
-			}
-		}
-
-		public override Encoding Encoding {
-			get {
-				return internalEncoding;
-			}
-		}
-
-		protected override void Dispose (bool disposing) 
-		{
-			if (byte_buf == null || !disposing)
-				return;
-
-			try {
-				Flush ();
-			} finally {
-				byte_buf = null;
-				internalEncoding = null;
-				decode_buf = null;
-
-				if (!leave_open) {
-					internalStream.Close ();
-				}
-
-				internalStream = null;
-			}
-		}
-
-		public override void Flush ()
-		{
-			CheckState ();
-			FlushCore ();
-		}
-
-		// Keep in sync with FlushCoreAsync
-		void FlushCore ()
-		{
-			Decode ();
-			if (byte_pos > 0) {
-				FlushBytes ();
-				internalStream.Flush ();
-			}
-		}
-
-		// how the speedup works:
-		// the Write () methods simply copy the characters in a buffer of chars (decode_buf)
-		// Decode () is called when the buffer is full or we need to flash.
-		// Decode () will use the encoding to get the bytes and but them inside
-		// byte_buf. From byte_buf the data is finally outputted to the stream.
-		void FlushBytes () 
-		{
-			// write the encoding preamble only at the start of the stream
-			if (!preamble_done && byte_pos > 0) {
-				byte[] preamble = internalEncoding.GetPreamble ();
-				if (preamble.Length > 0)
-					internalStream.Write (preamble, 0, preamble.Length);
-				preamble_done = true;
-			}
-			internalStream.Write (byte_buf, 0, byte_pos);
-			byte_pos = 0;
-		}
-
-		void Decode () 
-		{
-			if (byte_pos > 0)
-				FlushBytes ();
-			if (decode_pos > 0) {
-				int len = internalEncoding.GetBytes (decode_buf, 0, decode_pos, byte_buf, byte_pos);
-				byte_pos += len;
-				decode_pos = 0;
-			}
-		}
-
-		void LowLevelWrite (char[] buffer, int index, int count)
-		{
-			while (count > 0) {
-				int todo = decode_buf.Length - decode_pos;
-				if (todo == 0) {
-					Decode ();
-					todo = decode_buf.Length;
-				}
-				if (todo > count)
-					todo = count;
-				Buffer.BlockCopy (buffer, index * 2, decode_buf, decode_pos * 2, todo * 2);
-				count -= todo;
-				index += todo;
-				decode_pos += todo;
-			}
-		}
-		
-		void LowLevelWrite (string s)
-		{
-			int count = s.Length;
-			int index = 0;
-			while (count > 0) {
-				int todo = decode_buf.Length - decode_pos;
-				if (todo == 0) {
-					Decode ();
-					todo = decode_buf.Length;
-				}
-				if (todo > count)
-					todo = count;
-				
-				for (int i = 0; i < todo; i ++)
-					decode_buf [i + decode_pos] = s [i + index];
-				
-				count -= todo;
-				index += todo;
-				decode_pos += todo;
-			}
-		}		
-
-		async Task FlushCoreAsync ()
-		{
-			await DecodeAsync ().ConfigureAwait (false);
-			if (byte_pos > 0) {
-				await FlushBytesAsync ().ConfigureAwait (false);
-				await internalStream.FlushAsync ().ConfigureAwait (false);
-			}
-		}
-
-		async Task FlushBytesAsync ()
-		{
-			// write the encoding preamble only at the start of the stream
-			if (!preamble_done && byte_pos > 0) {
-				byte[] preamble = internalEncoding.GetPreamble ();
-				if (preamble.Length > 0)
-					await internalStream.WriteAsync (preamble, 0, preamble.Length).ConfigureAwait (false);
-				preamble_done = true;
-			}
-
-			await internalStream.WriteAsync (byte_buf, 0, byte_pos).ConfigureAwait (false);
-			byte_pos = 0;
-		}
-
-		async Task DecodeAsync () 
-		{
-			if (byte_pos > 0)
-				await FlushBytesAsync ().ConfigureAwait (false);
-			if (decode_pos > 0) {
-				int len = internalEncoding.GetBytes (decode_buf, 0, decode_pos, byte_buf, byte_pos);
-				byte_pos += len;
-				decode_pos = 0;
-			}
-		}		
-
-		async Task LowLevelWriteAsync (char[] buffer, int index, int count)
-		{
-			while (count > 0) {
-				int todo = decode_buf.Length - decode_pos;
-				if (todo == 0) {
-					await DecodeAsync ().ConfigureAwait (false);
-					todo = decode_buf.Length;
-				}
-				if (todo > count)
-					todo = count;
-				Buffer.BlockCopy (buffer, index * 2, decode_buf, decode_pos * 2, todo * 2);
-				count -= todo;
-				index += todo;
-				decode_pos += todo;
-			}
-		}
-		
-		async Task LowLevelWriteAsync (string s)
-		{
-			int count = s.Length;
-			int index = 0;
-			while (count > 0) {
-				int todo = decode_buf.Length - decode_pos;
-				if (todo == 0) {
-					await DecodeAsync ().ConfigureAwait (false);
-					todo = decode_buf.Length;
-				}
-				if (todo > count)
-					todo = count;
-				
-				for (int i = 0; i < todo; i ++)
-					decode_buf [i + decode_pos] = s [i + index];
-				
-				count -= todo;
-				index += todo;
-				decode_pos += todo;
-			}
-		}	
-
-		public override void Write (char[] buffer, int index, int count) 
-		{
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0)
-				throw new ArgumentOutOfRangeException ("index", "< 0");
-			if (count < 0)
-				throw new ArgumentOutOfRangeException ("count", "< 0");
-			// re-ordered to avoid possible integer overflow
-			if (index > buffer.Length - count)
-				throw new ArgumentException ("index + count > buffer.Length");
-
-			CheckState ();
-
-			LowLevelWrite (buffer, index, count);
-			if (iflush)
-				FlushCore ();
-		}
-		
-		public override void Write (char value)
-		{
-			CheckState ();
-
-			// the size of decode_buf is always > 0 and
-			// we check for overflow right away
-			if (decode_pos >= decode_buf.Length)
-				Decode ();
-			decode_buf [decode_pos++] = value;
-			if (iflush)
-				FlushCore ();
-		}
-
-		public override void Write (char[] buffer)
-		{
-			CheckState ();
-
-			if (buffer != null)
-				LowLevelWrite (buffer, 0, buffer.Length);
-			if (iflush)
-				FlushCore ();
-		}
-
-		public override void Write (string value) 
-		{
-			CheckState ();
-
-			if (value == null)
-				return;
-			
-			LowLevelWrite (value);
-			
-			if (iflush)
-				FlushCore ();
-		}
-
-		public override void Close()
-		{
-			Dispose (true);
-		}
-
-		void CheckState ()
-		{
-			if (byte_buf == null)
-				throw new ObjectDisposedException ("StreamWriter");
-
-			if (async_task != null && !async_task.IsCompleted)
-				throw new InvalidOperationException ();
-		}
-
-		public override Task FlushAsync ()
-		{
-			CheckState ();
-			DecoupledTask res;
-			async_task = res = new DecoupledTask (FlushCoreAsync ());
-			return res.Task;
-		}
-
-		public override Task WriteAsync (char value)
-		{
-			CheckState ();
-
-			DecoupledTask res;
-			async_task = res = new DecoupledTask (WriteAsyncCore (value));
-			return res.Task;
-		}
-
-		async Task WriteAsyncCore (char value)
-		{
-			// the size of decode_buf is always > 0 and
-			// we check for overflow right away
-			if (decode_pos >= decode_buf.Length)
-				await DecodeAsync ().ConfigureAwait (false);
-			decode_buf [decode_pos++] = value;
-
-			if (iflush)
-				await FlushCoreAsync ().ConfigureAwait (false);
-		}
-
-		public override Task WriteAsync (char[] buffer, int index, int count)
-		{
-			CheckState ();
-			if (buffer == null)
-				return TaskConstants.Finished;
-
-			DecoupledTask res;
-			async_task = res = new DecoupledTask (WriteAsyncCore (buffer, index, count));
-			return res.Task;
-		}
-
-		async Task WriteAsyncCore (char[] buffer, int index, int count)
-		{
-			// Debug.Assert (buffer == null);
-
-			await LowLevelWriteAsync (buffer, index, count).ConfigureAwait (false);
-
-			if (iflush)
-				await FlushCoreAsync ().ConfigureAwait (false);
-		}
-
-		public override Task WriteAsync (string value)
-		{
-			CheckState ();
-
-			if (value == null)
-				return TaskConstants.Finished;
-
-			DecoupledTask res;			
-			async_task = res = new DecoupledTask (WriteAsyncCore (value, false));
-			return res.Task;
-		}
-
-		async Task WriteAsyncCore (string value, bool appendNewLine)
-		{
-			// Debug.Assert (value == null);
-
-			await LowLevelWriteAsync (value).ConfigureAwait (false);
-			if (appendNewLine)
-				await LowLevelWriteAsync (CoreNewLine, 0, CoreNewLine.Length).ConfigureAwait (false);
-			
-			if (iflush)
-				await FlushCoreAsync ().ConfigureAwait (false);
-		}		
-
-		public override Task WriteLineAsync ()
-		{
-			CheckState ();
-
-			DecoupledTask res;
-			async_task = res = new DecoupledTask (WriteAsyncCore (CoreNewLine, 0, CoreNewLine.Length));
-			return res.Task;
-		}
-
-		public override Task WriteLineAsync (char value)
-		{
-			CheckState ();
-			DecoupledTask res;
-			async_task = res = new DecoupledTask (WriteLineAsyncCore (value));
-			return res.Task;
-		}
-
-		async Task WriteLineAsyncCore (char value)
-		{
-			await WriteAsyncCore (value).ConfigureAwait (false);
-			await LowLevelWriteAsync (CoreNewLine, 0, CoreNewLine.Length).ConfigureAwait (false);
-			
-			if (iflush)
-				await FlushCoreAsync ().ConfigureAwait (false);
-		}		
-
-		public override Task WriteLineAsync (char[] buffer, int index, int count)
-		{
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0)
-				throw new ArgumentOutOfRangeException ("index", "< 0");
-			if (count < 0)
-				throw new ArgumentOutOfRangeException ("count", "< 0");
-			// re-ordered to avoid possible integer overflow
-			if (index > buffer.Length - count)
-				throw new ArgumentException ("index + count > buffer.Length");
-
-			CheckState ();
-			DecoupledTask res;
-			async_task = res = new DecoupledTask (WriteLineAsyncCore (buffer, index, count));
-			return res.Task;
-		}
-
-		async Task WriteLineAsyncCore (char[] buffer, int index, int count)
-		{
-			// Debug.Assert (buffer == null);
-
-			await LowLevelWriteAsync (buffer, index, count).ConfigureAwait (false);
-			await LowLevelWriteAsync (CoreNewLine, 0, CoreNewLine.Length).ConfigureAwait (false);
-			
-			if (iflush)
-				await FlushCoreAsync ().ConfigureAwait (false);
-		}		
-
-		public override Task WriteLineAsync (string value)
-		{
-			if (value == null)
-				return WriteLineAsync ();
-
-			CheckState ();
-			DecoupledTask res;			
-			async_task = res = new DecoupledTask (WriteAsyncCore (value, true));
-			return res.Task;
-		}
-	}
-}

+ 0 - 186
mcs/class/corlib/System.IO/StringReader.cs

@@ -1,186 +0,0 @@
-//
-// System.IO.StringReader
-//
-// Authors:
-//   Marcin Szczepanski ([email protected])
-//   Marek Safar ([email protected])
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright 2011 Xamarin Inc.
-//
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Globalization;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace System.IO {
-	[Serializable]
-	[ComVisible (true)]
-	public class StringReader : TextReader {
-
-		string source;
-		int nextChar;
-		int sourceLength;
-		static char[] cr_lf;
-
-		public StringReader (string s)
-		{
-			if (s == null) 
-				throw new ArgumentNullException ("s");
-
-			this.source = s;
-			nextChar = 0;
-			sourceLength = s.Length;
-		}
-
-		public override void Close ()
-		{
-			Dispose (true);
-		}
-
-		protected override void Dispose (bool disposing)
-		{
-			source = null;
-			base.Dispose (disposing);
-		}
-
-		public override int Peek ()
-		{
-			if (source == null)
-				ObjectDisposedException ();
-
-			if (nextChar >= sourceLength) 
-				return -1;
-			return (int)source [nextChar];
-		}
-
-		public override int Read ()
-		{
-			if (source == null)
-				ObjectDisposedException ();
-
-			if (nextChar >= sourceLength)
-				return -1;
-			return (int)source [nextChar++];
-		}
-
-		// The method will read up to count characters from the StringReader
-		// into the buffer character array starting at position index. Returns
-		// the actual number of characters read, or zero if the end of the string
-		// has been reached and no characters are read.
-
-		public override int Read ([In, Out] char[] buffer, int index, int count)
-		{
-			if (source == null)
-				ObjectDisposedException ();
-
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (buffer.Length - index < count)
-				throw new ArgumentException ();
-			if (index < 0 || count < 0)
-				throw new ArgumentOutOfRangeException ();
-
-			int charsToRead;
-
-			// reordered to avoir possible integer overflow
-			if (nextChar > sourceLength - count)
-				charsToRead = sourceLength - nextChar;
-			else
-				charsToRead = count;
-			
-			source.CopyTo (nextChar, buffer, index, charsToRead);
-
-			nextChar += charsToRead;
-
-			return charsToRead;
-		}
-
-		public override string ReadLine ()
-		{
-			// Reads until next \r or \n or \r\n, otherwise return null
-
-			if (source == null)
-				ObjectDisposedException ();
-
-			if (nextChar >= source.Length)
-				return null;
-
-			if (cr_lf == null)
-				cr_lf = new char [] { '\n', '\r' };
-			
-			int readto = source.IndexOfAny (cr_lf, nextChar);
-			
-			if (readto == -1)
-				return ReadToEnd ();
-
-			bool consecutive = source[readto] == '\r'
-				&& readto + 1 < source.Length
-				&& source[readto + 1] == '\n';
-
-			string nextLine = source.Substring (nextChar, readto - nextChar);
-			nextChar = readto + ((consecutive) ? 2 : 1);
-			return nextLine;
-		}
-
-		public override string ReadToEnd ()
-		{
-			if (source == null)
-				ObjectDisposedException ();
-			string toEnd = source.Substring (nextChar, sourceLength - nextChar);
-			nextChar = sourceLength;
-			return toEnd;
-		}
-
-		//
-		// All async methods return finished task with a result as it's faster
-		// than setting up async call
-		//
-		public override Task<int> ReadAsync (char[] buffer, int index, int count)
-		{
-			return Task.FromResult (Read (buffer, index, count));
-		}
-
-		public override Task<int> ReadBlockAsync (char[] buffer, int index, int count)
-		{
-			return Task.FromResult (ReadBlock (buffer, index, count));
-		}
-
-		public override Task<string> ReadLineAsync ()
-		{
-			return Task.FromResult (ReadLine ());
-		}
-
-		public override Task<string> ReadToEndAsync ()
-		{
-			return Task.FromResult (ReadToEnd ());
-		}
-
-		static void ObjectDisposedException ()
-		{
-			throw new ObjectDisposedException ("StringReader", 
-							   Locale.GetText ("Cannot read from a closed StringReader"));
-		}
-	}
-}

+ 0 - 187
mcs/class/corlib/System.IO/StringWriter.cs

@@ -1,187 +0,0 @@
-//
-// System.IO.StringWriter
-//
-// Authors
-//	Marcin Szczepanski ([email protected])
-//	Sebastien Pouliot  <[email protected]>
-//	Marek Safar ([email protected])
-//
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright 2011 Xamarin Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Globalization;
-using System.Text;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace System.IO
-{
-	[Serializable]
-	[ComVisible (true)]
-	[MonoLimitation ("Serialization format not compatible with .NET")]
-	public class StringWriter : TextWriter
-	{
-		private StringBuilder internalString;
-		private bool disposed;
-
-		public StringWriter ()
-			: this (new StringBuilder ())
-		{
-		}
-
-		public StringWriter (IFormatProvider formatProvider)
-			: this (new StringBuilder (), formatProvider)
-		{
-		}
-
-		public StringWriter (StringBuilder sb)
-			: this (sb, null)
-		{
-		}
-
-		public StringWriter (StringBuilder sb, IFormatProvider formatProvider)
-		{
-			if (sb == null)
-				throw new ArgumentNullException ("sb");
-
-			internalString = sb;
-			internalFormatProvider = formatProvider;
-		}
-
-		public override Encoding Encoding {
-			get {
-				return Encoding.Unicode;
-			}
-		}
-
-		public override void Close ()
-		{
-			Dispose (true);
-			disposed = true;
-		}
-
-		protected override void Dispose (bool disposing)
-		{
-			// MS.NET doesn't clear internal buffer.
-			// internalString = null;
-			base.Dispose (disposing);
-			disposed = true;
-		}
-
-		public virtual StringBuilder GetStringBuilder ()
-		{
-			return internalString;
-		}
-
-		public override string ToString ()
-		{
-			return internalString.ToString ();
-		}
-
-		public override void Write (char value)
-		{
-			if (disposed) {
-				throw new ObjectDisposedException ("StringReader",
-					Locale.GetText ("Cannot write to a closed StringWriter"));
-			}
-
-			internalString.Append (value);
-		}
-
-		public override void Write (string value)
-		{
-			if (disposed) {
-				throw new ObjectDisposedException ("StringReader",
-					Locale.GetText ("Cannot write to a closed StringWriter"));
-			}
-
-			internalString.Append (value);
-		}
-
-		public override void Write (char[] buffer, int index, int count)
-		{
-			if (disposed) {
-				throw new ObjectDisposedException ("StringReader",
-					Locale.GetText ("Cannot write to a closed StringWriter"));
-			}
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0)
-				throw new ArgumentOutOfRangeException ("index", "< 0");
-			if (count < 0)
-				throw new ArgumentOutOfRangeException ("count", "< 0");
-			// re-ordered to avoid possible integer overflow
-			if (index > buffer.Length - count)
-				throw new ArgumentException ("index + count > buffer.Length");
-
-			internalString.Append (buffer, index, count);
-		}
-
-		public override Task FlushAsync ()
-		{
-			// it appears to do nothing
-			return TaskConstants.Finished;
-		}
-
-		//
-		// All async methods return finished task with a result as it's faster
-		// than setting up async call
-		//
-		public override Task WriteAsync (char value)
-		{
-			Write (value);
-			return TaskConstants.Finished;
-		}
-
-		public override Task WriteAsync (char[] buffer, int index, int count)
-		{
-			Write (buffer, index, count);
-			return TaskConstants.Finished;
-		}
-
-		public override Task WriteAsync (string value)
-		{
-			Write (value);
-			return TaskConstants.Finished;
-		}
-
-		public override Task WriteLineAsync (char value)
-		{
-			WriteLine (value);
-			return TaskConstants.Finished;
-		}
-
-		public override Task WriteLineAsync (char[] buffer, int index, int count)
-		{
-			WriteLine (buffer, index, count);
-			return TaskConstants.Finished;
-		}
-
-		public override Task WriteLineAsync (string value)
-		{
-			WriteLine (value);
-			return TaskConstants.Finished;
-		}
-	}
-}

+ 0 - 285
mcs/class/corlib/System.IO/TextReader.cs

@@ -1,285 +0,0 @@
-//
-// System.IO.TextReader
-//
-// Authors:
-//   Marcin Szczepanski ([email protected])
-//   Miguel de Icaza ([email protected])
-//   Marek Safar ([email protected])
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright 2011 Xamarin Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace System.IO {
-
-	[Serializable]
-	[ComVisible (true)]
-#if NET_2_1
-	public abstract class TextReader : IDisposable {
-#else
-	public abstract class TextReader : MarshalByRefObject, IDisposable {
-#endif
-
-		sealed class NullTextReader : TextReader
-		{
-			public override string ReadLine ()
-			{
-				return null;
-			}
-
-			public override string ReadToEnd ()
-			{
-				return String.Empty;
-			}
-		}
-
-		public static readonly TextReader Null = new NullTextReader ();
-
-		protected TextReader()
-		{
-		}
-		
-		public virtual void Close()
-		{ 
-			Dispose(true);
-		}
-
-		public void Dispose ()
-		{
-			Dispose(true);
-		}
-
-		protected virtual void Dispose (bool disposing)
-		{
-			if (disposing){
-				// If we are explicitly disposed, we can avoid finalization.
-				GC.SuppressFinalize (this);
-			}
-			return;
-		}
-		
-		public virtual int Peek()
-		{
-			return -1;
-		}
-		
-		public virtual int Read()
-		{
-			return -1;
-		}
-		
-		public virtual int Read ([In, Out] char[] buffer, int index, int count)
-		{
-			int c, i;
-			
-			for (i = 0; i < count; i++) {
-				if ((c = Read ()) == -1)
-					return i;
-				buffer [index + i] = (char)c;
-			}
-			
-			return i;
-		}
-		
-		public virtual int ReadBlock ([In, Out] char [] buffer, int index, int count)
-		{
-			int total_read_count = 0;
-			int current_read_count;
-
-			do {
-				current_read_count = Read (buffer, index, count);
-				index += current_read_count;
-				total_read_count += current_read_count;
-				count -= current_read_count;
-			} while (current_read_count != 0 && count > 0);
-
-			return total_read_count;
-		}
-
-		public virtual string ReadLine ()
-		{ 
-			var result = new System.Text.StringBuilder ();
-			int c;
-
-			while ((c = Read ()) != -1){
-				// check simple character line ending
-				if (c == '\n')
-					break;
-				if (c == '\r') {
-					if (Peek () == '\n') 
-						Read ();
-					break;
-				}
-				result.Append ((char) c);
-			}
-			if (c == -1 && result.Length == 0)
-				return null;
-			
-			return result.ToString ();
-		}
-
-		public virtual string ReadToEnd ()
-		{ 
-			var result = new System.Text.StringBuilder ();
-			int c;
-			while ((c = Read ()) != -1)
-				result.Append ((char) c);
-			return result.ToString ();
-		}
-
-		public static TextReader Synchronized (TextReader reader)
-		{
-			if (reader == null)
-				throw new ArgumentNullException ("reader is null");
-			if (reader is SynchronizedReader)
-				return reader;
-
-			return new SynchronizedReader (reader);
-		}
-
-		//
-		// Use tuple to pack the arguments because it's faster than
-		// setting up anonymous method container with an instance delegate
-		//
-		public virtual Task<int> ReadAsync (char[] buffer, int index, int count)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextReader, char[], int, int>) l;
-				return t.Item1.Read (t.Item2, t.Item3, t.Item4);
-			}, Tuple.Create (this, buffer, index, count));
-		}
-
-		public virtual Task<int> ReadBlockAsync (char[] buffer, int index, int count)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextReader, char[], int, int>) l;
-				return t.Item1.ReadBlock (t.Item2, t.Item3, t.Item4);
-			}, Tuple.Create (this, buffer, index, count));
-		}
-
-		public virtual Task<string> ReadLineAsync ()
-		{
-			return Task.Factory.StartNew (l => ((TextReader) l).ReadLine (), this);
-		}
-
-		public virtual Task<string> ReadToEndAsync ()
-		{
-			return Task.Factory.StartNew (l => ((TextReader) l).ReadToEnd (), this);
-		}
-	}
-
-	//
-	// Synchronized Reader implementation, used internally.
-	//
-	[Serializable]
-	sealed class SynchronizedReader : TextReader
-	{
-		readonly TextReader reader;
-		
-		public SynchronizedReader (TextReader reader)
-		{
-			this.reader = reader;
-		}
-
-		public override void Close ()
-		{
-			lock (this){
-				reader.Close ();
-			}
-		}
-
-		public override int Peek ()
-		{
-			lock (this){
-				return reader.Peek ();
-			}
-		}
-
-		public override int ReadBlock (char [] buffer, int index, int count)
-		{
-			lock (this){
-				return reader.ReadBlock (buffer, index, count);
-			}
-		}
-
-		public override string ReadLine ()
-		{
-			lock (this){
-				return reader.ReadLine ();
-			}
-		}
-
-		public override string ReadToEnd ()
-		{
-			lock (this){
-				return reader.ReadToEnd ();
-			}
-		}
-
-		public override int Read ()
-		{
-			lock (this){
-				return reader.Read ();
-			}
-		}
-
-		public override int Read (char [] buffer, int index, int count)
-		{
-			lock (this){
-				return reader.Read (buffer, index, count);
-			}
-		}
-
-		public override Task<int> ReadAsync (char[] buffer, int index, int count)
-		{
-			lock (this) {
-				return reader.ReadAsync (buffer, index, count);
-			}
-		}
-
-		public override Task<int> ReadBlockAsync (char[] buffer, int index, int count)
-		{
-			lock (this) {
-				return reader.ReadBlockAsync (buffer, index, count);
-			}
-		}
-
-		public override Task<string> ReadLineAsync ()
-		{
-			lock (this) {
-				return reader.ReadLineAsync ();
-			}
-		}
-
-		public override Task<string> ReadToEndAsync ()
-		{
-			lock (this) {
-				return reader.ReadToEndAsync ();
-			}
-		}
-	}
-}

+ 0 - 803
mcs/class/corlib/System.IO/TextWriter.cs

@@ -1,803 +0,0 @@
-//
-// System.IO.TextWriter.cs
-//
-// Authors:
-//   Marcin Szczepanski ([email protected])
-//   Miguel de Icaza ([email protected])
-//   Paolo Molaro ([email protected])
-//   Marek Safar ([email protected])
-
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
-// Copyright 2011 Xamarin Inc.
-//
-// Permission is hereby granted, free of charge, to any person obtaining
-// a copy of this software and associated documentation files (the
-// "Software"), to deal in the Software without restriction, including
-// without limitation the rights to use, copy, modify, merge, publish,
-// distribute, sublicense, and/or sell copies of the Software, and to
-// permit persons to whom the Software is furnished to do so, subject to
-// the following conditions:
-// 
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-// 
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-//
-
-using System.Text;
-using System.Runtime.InteropServices;
-using System.Threading.Tasks;
-
-namespace System.IO
-{
-
-	[Serializable]
-	[ComVisible (true)]
-#if NET_2_1
-	public abstract class TextWriter : IDisposable {
-#else
-	public abstract class TextWriter : MarshalByRefObject, IDisposable
-	{
-#endif
-		//
-		// Null version of the TextWriter, for the `Null' instance variable
-		//
-		sealed class NullTextWriter : TextWriter
-		{
-			public override Encoding Encoding
-			{
-				get
-				{
-					return Encoding.Default;
-				}
-			}
-
-			public override void Write (string s)
-			{
-			}
-			public override void Write (char value)
-			{
-			}
-			public override void Write (char[] value, int index, int count)
-			{
-			}
-		}
-
-		protected TextWriter ()
-		{
-			CoreNewLine = System.Environment.NewLine.ToCharArray ();
-		}
-
-		protected TextWriter (IFormatProvider formatProvider)
-		{
-			CoreNewLine = System.Environment.NewLine.ToCharArray ();
-			internalFormatProvider = formatProvider;
-		}
-
-		protected char[] CoreNewLine;
-
-		internal IFormatProvider internalFormatProvider;
-
-		public static readonly TextWriter Null = new NullTextWriter ();
-
-		public abstract Encoding Encoding { get; }
-
-		public virtual IFormatProvider FormatProvider {
-			get {
-				return internalFormatProvider;
-			}
-		}
-
-		public virtual string NewLine {
-			get {
-				return new string (CoreNewLine);
-			}
-
-			set {
-				if (value == null)
-					value = Environment.NewLine;
-
-				CoreNewLine = value.ToCharArray ();
-			}
-		}
-
-		public virtual void Close ()
-		{
-			Dispose (true);
-		}
-
-		protected virtual void Dispose (bool disposing)
-		{
-			if (disposing) {
-				// If we are explicitly disposed, we can avoid finalization.
-				GC.SuppressFinalize (this);
-			}
-		}
-		public void Dispose ()
-		{
-			Dispose (true);
-
-			// If we are explicitly disposed, we can avoid finalization.
-			GC.SuppressFinalize (this);
-		}
-
-		public virtual void Flush ()
-		{
-			// do nothing
-		}
-
-		public static TextWriter Synchronized (TextWriter writer)
-		{
-			return Synchronized (writer, false);
-		}
-
-		internal static TextWriter Synchronized (TextWriter writer, bool neverClose)
-		{
-			if (writer == null)
-				throw new ArgumentNullException ("writer is null");
-
-			if (writer is SynchronizedWriter)
-				return writer;
-
-			return new SynchronizedWriter (writer, neverClose);
-		}
-
-		public virtual void Write (bool value)
-		{
-			Write (value.ToString ());
-		}
-
-		public virtual void Write (char value)
-		{
-			// Do nothing
-		}
-
-		public virtual void Write (char[] buffer)
-		{
-			if (buffer == null)
-				return;
-			Write (buffer, 0, buffer.Length);
-		}
-
-		public virtual void Write (decimal value)
-		{
-			Write (value.ToString (internalFormatProvider));
-		}
-
-		public virtual void Write (double value)
-		{
-			Write (value.ToString (internalFormatProvider));
-		}
-
-		public virtual void Write (int value)
-		{
-			Write (value.ToString (internalFormatProvider));
-		}
-
-		public virtual void Write (long value)
-		{
-			Write (value.ToString (internalFormatProvider));
-		}
-
-		public virtual void Write (object value)
-		{
-			if (value != null)
-				Write (value.ToString ());
-		}
-
-		public virtual void Write (float value)
-		{
-			Write (value.ToString (internalFormatProvider));
-		}
-
-		public virtual void Write (string value)
-		{
-			if (value != null)
-				Write (value.ToCharArray ());
-		}
-
-		[CLSCompliant (false)]
-		public virtual void Write (uint value)
-		{
-			Write (value.ToString (internalFormatProvider));
-		}
-
-		[CLSCompliant (false)]
-		public virtual void Write (ulong value)
-		{
-			Write (value.ToString (internalFormatProvider));
-		}
-
-		public virtual void Write (string format, object arg0)
-		{
-			Write (String.Format (format, arg0));
-		}
-
-		public virtual void Write (string format, params object[] arg)
-		{
-			Write (String.Format (format, arg));
-		}
-
-		public virtual void Write (char[] buffer, int index, int count)
-		{
-			if (buffer == null)
-				throw new ArgumentNullException ("buffer");
-			if (index < 0 || index > buffer.Length)
-				throw new ArgumentOutOfRangeException ("index");
-			// re-ordered to avoid possible integer overflow
-			if (count < 0 || (index > buffer.Length - count))
-				throw new ArgumentOutOfRangeException ("count");
-
-			for (; count > 0; --count, ++index) {
-				Write (buffer[index]);
-			}
-		}
-
-		public virtual void Write (string format, object arg0, object arg1)
-		{
-			Write (String.Format (format, arg0, arg1));
-		}
-
-		public virtual void Write (string format, object arg0, object arg1, object arg2)
-		{
-			Write (String.Format (format, arg0, arg1, arg2));
-		}
-
-		public virtual void WriteLine ()
-		{
-			Write (CoreNewLine);
-		}
-
-		public virtual void WriteLine (bool value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (char value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (char[] buffer)
-		{
-			Write (buffer);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (decimal value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (double value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (int value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (long value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (object value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (float value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (string value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		[CLSCompliant (false)]
-		public virtual void WriteLine (uint value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		[CLSCompliant (false)]
-		public virtual void WriteLine (ulong value)
-		{
-			Write (value);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (string format, object arg0)
-		{
-			Write (format, arg0);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (string format, params object[] arg)
-		{
-			Write (format, arg);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (char[] buffer, int index, int count)
-		{
-			Write (buffer, index, count);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (string format, object arg0, object arg1)
-		{
-			Write (format, arg0, arg1);
-			WriteLine ();
-		}
-
-		public virtual void WriteLine (string format, object arg0, object arg1, object arg2)
-		{
-			Write (format, arg0, arg1, arg2);
-			WriteLine ();
-		}
-
-		public virtual Task FlushAsync ()
-		{
-			return Task.Factory.StartNew (l => ((TextWriter)l).Flush (), this);
-		}
-
-		//
-		// Use tuple to pack the arguments because it's faster than
-		// setting up anonymous method container with an instance delegate
-		//
-		public virtual Task WriteAsync (char value)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextWriter, char>) l;
-				t.Item1.Write (t.Item2);
-			}, Tuple.Create (this, value));
-		}
-
-		public Task WriteAsync (char[] buffer)
-		{
-			if (buffer == null)
-				return TaskConstants.Finished;
-
-			return WriteAsync (buffer, 0, buffer.Length);
-		}
-
-		public virtual Task WriteAsync (char[] buffer, int index, int count)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextWriter, char[], int, int>) l;
-				t.Item1.Write (t.Item2, t.Item3, t.Item4);
-			}, Tuple.Create (this, buffer, index, count));
-		}
-
-		public virtual Task WriteAsync (string value)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextWriter, string>) l;
-				t.Item1.Write (t.Item2);
-			}, Tuple.Create (this, value));
-		}
-
-		public virtual Task WriteLineAsync ()
-		{
-			return WriteAsync (CoreNewLine);
-		}
-
-		public virtual Task WriteLineAsync (char value)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextWriter, char>) l;
-				t.Item1.WriteLine (t.Item2);
-			}, Tuple.Create (this, value));
-		}
-
-		public Task WriteLineAsync (char[] buffer)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextWriter, char[]>) l;
-				t.Item1.WriteLine (t.Item2);
-			}, Tuple.Create (this, buffer));
-		}
-
-		public virtual Task WriteLineAsync (char[] buffer, int index, int count)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextWriter, char[], int, int>) l;
-				t.Item1.WriteLine (t.Item2, t.Item3, t.Item4);
-			}, Tuple.Create (this, buffer, index, count));
-		}
-
-		public virtual Task WriteLineAsync (string value)
-		{
-			return Task.Factory.StartNew (l => {
-				var t = (Tuple<TextWriter, string>) l;
-				t.Item1.WriteLine (t.Item2);
-			}, Tuple.Create (this, value));
-		}
-	}
-
-	//
-	// Sychronized version of the TextWriter.
-	//
-	[Serializable]
-	sealed class SynchronizedWriter : TextWriter
-	{
-		private TextWriter writer;
-		private bool neverClose;
-
-		public SynchronizedWriter (TextWriter writer)
-			: this (writer, false)
-		{
-		}
-
-		public SynchronizedWriter (TextWriter writer, bool neverClose)
-		{
-			this.writer = writer;
-			this.neverClose = neverClose;
-		}
-
-		public override void Close ()
-		{
-			if (neverClose)
-				return;
-			lock (this) {
-				writer.Close ();
-			}
-		}
-
-		public override void Flush ()
-		{
-			lock (this) {
-				writer.Flush ();
-			}
-		}
-
-		#region Write methods
-		public override void Write (bool value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (char value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (char[] value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (Decimal value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (int value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (long value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (object value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (float value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (string value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (uint value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (ulong value)
-		{
-			lock (this) {
-				writer.Write (value);
-			}
-		}
-
-		public override void Write (string format, object value)
-		{
-			lock (this) {
-				writer.Write (format, value);
-			}
-		}
-
-		public override void Write (string format, object[] value)
-		{
-			lock (this) {
-				writer.Write (format, value);
-			}
-		}
-
-		public override void Write (char[] buffer, int index, int count)
-		{
-			lock (this) {
-				writer.Write (buffer, index, count);
-			}
-		}
-
-		public override void Write (string format, object arg0, object arg1)
-		{
-			lock (this) {
-				writer.Write (format, arg0, arg1);
-			}
-		}
-
-		public override void Write (string format, object arg0, object arg1, object arg2)
-		{
-			lock (this) {
-				writer.Write (format, arg0, arg1, arg2);
-			}
-		}
-		#endregion
-		#region WriteLine methods
-		public override void WriteLine ()
-		{
-			lock (this) {
-				writer.WriteLine ();
-			}
-		}
-
-		public override void WriteLine (bool value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (char value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (char[] value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (Decimal value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (double value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (int value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (long value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (object value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (float value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (string value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (uint value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (ulong value)
-		{
-			lock (this) {
-				writer.WriteLine (value);
-			}
-		}
-
-		public override void WriteLine (string format, object value)
-		{
-			lock (this) {
-				writer.WriteLine (format, value);
-			}
-		}
-
-		public override void WriteLine (string format, object[] value)
-		{
-			lock (this) {
-				writer.WriteLine (format, value);
-			}
-		}
-
-		public override void WriteLine (char[] buffer, int index, int count)
-		{
-			lock (this) {
-				writer.WriteLine (buffer, index, count);
-			}
-		}
-
-		public override void WriteLine (string format, object arg0, object arg1)
-		{
-			lock (this) {
-				writer.WriteLine (format, arg0, arg1);
-			}
-		}
-
-		public override void WriteLine (string format, object arg0, object arg1, object arg2)
-		{
-			lock (this) {
-				writer.WriteLine (format, arg0, arg1, arg2);
-			}
-		}
-		#endregion
-
-		public override Task FlushAsync ()
-		{
-			lock (this) {
-				return writer.FlushAsync ();
-			}
-		}
-
-		public override Task WriteAsync (char value)
-		{
-			lock (this) {
-				return writer.WriteAsync (value);
-			}
-		}
-
-		public override Task WriteAsync (char[] buffer, int index, int count)
-		{
-			lock (this) {
-				return writer.WriteAsync (buffer, index, count);
-			}
-		}
-
-		public override Task WriteAsync (string value)
-		{
-			lock (this) {
-				return writer.WriteAsync (value);
-			}
-		}
-
-		public override Task WriteLineAsync ()
-		{
-			lock (this) {
-				return writer.WriteLineAsync ();
-			}
-		}
-
-		public override Task WriteLineAsync (char value)
-		{
-			lock (this) {
-				return writer.WriteLineAsync (value);
-			}
-		}
-
-		public override Task WriteLineAsync (char[] buffer, int index, int count)
-		{
-			lock (this) {
-				return writer.WriteLineAsync (buffer, index, count);
-			}
-		}
-
-		public override Task WriteLineAsync (string value)
-		{
-			lock (this) {
-				return writer.WriteLineAsync (value);
-			}
-		}
-		public override Encoding Encoding {
-			get {
-				lock (this) {
-					return writer.Encoding;
-				}
-			}
-		}
-
-		public override IFormatProvider FormatProvider {
-			get {
-				lock (this) {
-					return writer.FormatProvider;
-				}
-			}
-		}
-
-		public override string NewLine {
-			get {
-				lock (this) {
-					return writer.NewLine;
-				}
-			}
-
-			set {
-				lock (this) {
-					writer.NewLine = value;
-				}
-			}
-		}
-	}
-}

+ 7 - 6
mcs/class/corlib/corlib.dll.sources

@@ -362,12 +362,6 @@ System.IO/PathTooLongException.cs
 System.IO/SearchOption.cs
 System.IO/SearchPattern.cs
 System.IO/SeekOrigin.cs
-System.IO/StreamReader.cs
-System.IO/StreamWriter.cs
-System.IO/StringReader.cs
-System.IO/StringWriter.cs
-System.IO/TextReader.cs
-System.IO/TextWriter.cs
 System.IO/UnexceptionalStreamReader.cs
 System.IO/UnexceptionalStreamWriter.cs
 System.IO/UnmanagedMemoryAccessor.cs
@@ -1413,6 +1407,7 @@ System.Collections.Concurrent/ConcurrentOrderedList.cs
 ../Mono.Parallel/Mono.Threading/AtomicBoolean.cs
 System.Threading/ThreadLocal.cs
 
+ReferenceSources/__ConsoleStream.cs
 ReferenceSources/Array.cs
 ReferenceSources/BCLDebug.cs
 ReferenceSources/CalendarData.cs
@@ -1569,6 +1564,12 @@ ReferenceSources/EncodingTable.cs
 ../../../external/referencesource/mscorlib/system/io/__error.cs
 ../../../external/referencesource/mscorlib/system/io/memorystream.cs
 ../../../external/referencesource/mscorlib/system/io/stream.cs
+../../../external/referencesource/mscorlib/system/io/streamreader.cs
+../../../external/referencesource/mscorlib/system/io/streamwriter.cs
+../../../external/referencesource/mscorlib/system/io/stringreader.cs
+../../../external/referencesource/mscorlib/system/io/stringwriter.cs
+../../../external/referencesource/mscorlib/system/io/textreader.cs
+../../../external/referencesource/mscorlib/system/io/textwriter.cs
 
 ../../../external/referencesource/mscorlib/system/runtime/versioning/binarycompatibility.cs
 ../../../external/referencesource/mscorlib/system/runtime/versioning/targetframeworkid.cs