Merge pull request #1135 from kitsilanosoftware/rpm-spec-dead-entries
[mono.git] / mcs / class / corlib / System.IO / StreamReader.cs
index c11db6ff2d68dccab2ed92bf2ee46339889af1a2..8a0a9e9bb10110da7b4903c2bed329c02679494c 100644 (file)
@@ -44,6 +44,11 @@ namespace System.IO {
        {
                sealed class NullStreamReader : StreamReader
                {
+                       internal NullStreamReader ()
+                       {
+                               base_stream = Stream.Null;
+                       }
+
                        public override int Peek ()
                        {
                                return -1;
@@ -122,7 +127,7 @@ namespace System.IO {
                bool mayBlock;
 
 #if NET_4_5
-               Task async_task;
+               IDecoupledTask async_task;
                readonly bool leave_open;
 #endif
 
@@ -131,10 +136,10 @@ namespace System.IO {
                private StreamReader() {}
 
                public StreamReader(Stream stream)
-                       : this (stream, Encoding.UTF8Unmarked, true, DefaultBufferSize) { }
+                       : this (stream, Encoding.UTF8, true, DefaultBufferSize) { }
 
                public StreamReader(Stream stream, bool detectEncodingFromByteOrderMarks)
-                       : this (stream, Encoding.UTF8Unmarked, detectEncodingFromByteOrderMarks, DefaultBufferSize) { }
+                       : this (stream, Encoding.UTF8, detectEncodingFromByteOrderMarks, DefaultBufferSize) { }
 
                public StreamReader(Stream stream, Encoding encoding)
                        : this (stream, encoding, true, DefaultBufferSize) { }
@@ -162,10 +167,10 @@ namespace System.IO {
                }
 
                public StreamReader(string path)
-                       : this (path, Encoding.UTF8Unmarked, true, DefaultFileBufferSize) { }
+                       : this (path, Encoding.UTF8, true, DefaultFileBufferSize) { }
 
                public StreamReader(string path, bool detectEncodingFromByteOrderMarks)
-                       : this (path, Encoding.UTF8Unmarked, detectEncodingFromByteOrderMarks, DefaultFileBufferSize) { }
+                       : this (path, Encoding.UTF8, detectEncodingFromByteOrderMarks, DefaultFileBufferSize) { }
 
                public StreamReader(string path, Encoding encoding)
                        : this (path, encoding, true, DefaultFileBufferSize) { }
@@ -258,8 +263,6 @@ namespace System.IO {
 
                public virtual Encoding CurrentEncoding {
                        get {
-                               if (encoding == null)
-                                       throw new Exception ();
                                return encoding;
                        }
                }
@@ -625,9 +628,9 @@ namespace System.IO {
 
                        CheckState ();
 
-                       Task<int> res;
-                       async_task = res = ReadAsyncCore (buffer, index, count);
-                       return res;
+                       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)
@@ -665,18 +668,18 @@ namespace System.IO {
 
                        CheckState ();
 
-                       Task<int> res;
-                       async_task = res = ReadAsyncCore (buffer, index, count);
-                       return res;
+                       DecoupledTask<int> res;
+                       async_task = res = new DecoupledTask<int> (ReadAsyncCore (buffer, index, count));
+                       return res.Task;
                }
 
                public override Task<string> ReadLineAsync ()
                {
                        CheckState ();
 
-                       Task<string> res;
-                       async_task = res = ReadLineAsyncCore ();
-                       return res;
+                       DecoupledTask<string> res;
+                       async_task = res = new DecoupledTask<string> (ReadLineAsyncCore ());
+                       return res.Task;
                }
 
                async Task<string> ReadLineAsyncCore ()
@@ -731,9 +734,9 @@ namespace System.IO {
                {
                        CheckState ();
 
-                       Task<string> res;
-                       async_task = res = ReadToEndAsyncCore ();
-                       return res;
+                       DecoupledTask<string> res;
+                       async_task = res = new DecoupledTask<string> (ReadToEndAsyncCore ());
+                       return res.Task;
                }
 
                async Task<string> ReadToEndAsyncCore ()