From 435f5420e7df4f2ef77c9beca6bdafa5fc976d30 Mon Sep 17 00:00:00 2001 From: Viktor Hofer Date: Thu, 24 Aug 2017 18:29:57 +0200 Subject: [PATCH] IO --- src/mscorlib/src/System/IO/MemoryStream.cs | 1 - src/mscorlib/src/System/IO/Stream.cs | 2 -- src/mscorlib/src/System/IO/StreamReader.cs | 14 +++++--------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/mscorlib/src/System/IO/MemoryStream.cs b/src/mscorlib/src/System/IO/MemoryStream.cs index d97d3f4..2ac7c07 100644 --- a/src/mscorlib/src/System/IO/MemoryStream.cs +++ b/src/mscorlib/src/System/IO/MemoryStream.cs @@ -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 _lastReadTask; // The last successful task returned from ReadAsync private const int MemStreamMaxLength = Int32.MaxValue; diff --git a/src/mscorlib/src/System/IO/Stream.cs b/src/mscorlib/src/System/IO/Stream.cs index ae8ca51..82fad24 100644 --- a/src/mscorlib/src/System/IO/Stream.cs +++ b/src/mscorlib/src/System/IO/Stream.cs @@ -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() diff --git a/src/mscorlib/src/System/IO/StreamReader.cs b/src/mscorlib/src/System/IO/StreamReader.cs index 1fc72bf..9ff9187 100644 --- a/src/mscorlib/src/System/IO/StreamReader.cs +++ b/src/mscorlib/src/System/IO/StreamReader.cs @@ -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 { -- 2.7.4