IO
authorViktor Hofer <viktor.hofer@outlook.com>
Thu, 24 Aug 2017 16:29:57 +0000 (18:29 +0200)
committerViktor Hofer <viktor.hofer@outlook.com>
Tue, 12 Sep 2017 15:05:17 +0000 (17:05 +0200)
src/mscorlib/src/System/IO/MemoryStream.cs
src/mscorlib/src/System/IO/Stream.cs
src/mscorlib/src/System/IO/StreamReader.cs

index d97d3f4..2ac7c07 100644 (file)
@@ -49,7 +49,6 @@ namespace System.IO
         private bool _exposable;   // Whether the array can be returned to the user.
         private bool _isOpen;      // Is this stream open or closed?
 
-        [NonSerialized]
         private Task<int> _lastReadTask; // The last successful task returned from ReadAsync
 
         private const int MemStreamMaxLength = Int32.MaxValue;
index ae8ca51..82fad24 100644 (file)
@@ -41,9 +41,7 @@ namespace System.IO
 
         // To implement Async IO operations on streams that don't support async IO
 
-        [NonSerialized]
         private ReadWriteTask _activeReadWriteTask;
-        [NonSerialized]
         private SemaphoreSlim _asyncActiveSemaphore;
 
         internal SemaphoreSlim EnsureAsyncActiveSemaphoreInitialized()
index 1fc72bf..9ff9187 100644 (file)
@@ -58,7 +58,6 @@ namespace System.IO
         // This is used only for preamble detection
         private int bytePos;
 
-        [NonSerialized]
         private StringBuilder _builder;
 
         // This is the maximum number of chars we can get from one call to 
@@ -84,14 +83,12 @@ namespace System.IO
         private bool _isBlocked;
 
         // The intent of this field is to leave open the underlying stream when 
-        // disposing of this StreamReader.  A name like _leaveOpen is better, 
-        // but this type is serializable, and this field's name was _closable.
-        private bool _closable;  // Whether to close the underlying stream.
+        // disposing of this StreamReader.
+        private bool _leaveOpen;  // Whether to keep the underlying stream open.
 
         // We don't guarantee thread safety on StreamReader, but we should at 
         // least prevent users from trying to read anything while an Async
         // read from the same thread is in progress.
-        [NonSerialized]
         private volatile Task _asyncReadTask;
 
         private void CheckAsyncTaskInProgress()
@@ -216,14 +213,14 @@ namespace System.IO
 
             _checkPreamble = (_preamble.Length > 0);
             _isBlocked = false;
-            _closable = !leaveOpen;
+            _leaveOpen = leaveOpen;
         }
 
         // Init used by NullStreamReader, to delay load encoding
         internal void Init(Stream stream)
         {
             this.stream = stream;
-            _closable = true;
+            _leaveOpen = false;
         }
 
         public override void Close()
@@ -265,7 +262,7 @@ namespace System.IO
         }
 
         internal bool LeaveOpen {
-            get { return !_closable; }
+            get { return _leaveOpen; }
         }
 
         // DiscardBufferedData tells StreamReader to throw away its internal
@@ -1145,7 +1142,6 @@ namespace System.IO
         }
         #endregion
 
-        // No data, class doesn't need to be serializable.
         // Note this class is threadsafe.
         private class NullStreamReader : StreamReader
         {