From 59d7c3024ffe14f5c3abbcaabe5669db8bcc3e60 Mon Sep 17 00:00:00 2001 From: josesimoes Date: Thu, 17 Feb 2022 02:43:18 +0000 Subject: [PATCH] Remove Stream class --- .../CoreLibrary.NoReflection.nfproj | 2 - nanoFramework.CoreLibrary/CoreLibrary.nfproj | 2 - .../System/IO/SeekOrigin.cs | 29 --- nanoFramework.CoreLibrary/System/IO/Stream.cs | 236 ------------------ 4 files changed, 269 deletions(-) delete mode 100644 nanoFramework.CoreLibrary/System/IO/SeekOrigin.cs delete mode 100644 nanoFramework.CoreLibrary/System/IO/Stream.cs diff --git a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj index bb109e04..6b7a268f 100644 --- a/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj +++ b/nanoFramework.CoreLibrary.NoReflection/CoreLibrary.NoReflection.nfproj @@ -122,8 +122,6 @@ - - diff --git a/nanoFramework.CoreLibrary/CoreLibrary.nfproj b/nanoFramework.CoreLibrary/CoreLibrary.nfproj index 524a65cc..c2cdced8 100644 --- a/nanoFramework.CoreLibrary/CoreLibrary.nfproj +++ b/nanoFramework.CoreLibrary/CoreLibrary.nfproj @@ -119,8 +119,6 @@ - - diff --git a/nanoFramework.CoreLibrary/System/IO/SeekOrigin.cs b/nanoFramework.CoreLibrary/System/IO/SeekOrigin.cs deleted file mode 100644 index 1db19209..00000000 --- a/nanoFramework.CoreLibrary/System/IO/SeekOrigin.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// Portions Copyright (c) Microsoft Corporation. All rights reserved. -// See LICENSE file in the project root for full license information. -// - -namespace System.IO -{ - /// - /// Specifies the position in a stream to use for seeking. - /// - /// These constants match Win32's FILE_BEGIN, FILE_CURRENT, and FILE_END - [Serializable] - public enum SeekOrigin - { - /// - /// Specifies the beginning of a stream. - /// - Begin = 0, - /// - /// Specifies the current position within a stream. - /// - Current = 1, - /// - /// Specifies the end of a stream. - /// - End = 2, - } -} diff --git a/nanoFramework.CoreLibrary/System/IO/Stream.cs b/nanoFramework.CoreLibrary/System/IO/Stream.cs deleted file mode 100644 index 2718d989..00000000 --- a/nanoFramework.CoreLibrary/System/IO/Stream.cs +++ /dev/null @@ -1,236 +0,0 @@ -// -// Copyright (c) .NET Foundation and Contributors -// Portions Copyright (c) Microsoft Corporation. All rights reserved. -// See LICENSE file in the project root for full license information. -// - -namespace System.IO -{ - /// - /// Provides a generic view of a sequence of bytes. This is an abstract class. - /// - [Serializable] - public abstract class Stream : MarshalByRefObject, IDisposable - { - /// - /// When overridden in a derived class, gets a value indicating whether the current stream supports reading. - /// - /// - /// true if the stream supports reading; otherwise, false. - /// - public abstract bool CanRead - { - get; - } - - /// - /// When overridden in a derived class, gets a value indicating whether the current stream supports seeking. - /// - /// - /// true if the stream supports seeking; otherwise, false. - /// - public abstract bool CanSeek - { - get; - } - - /// - /// Gets a value that determines whether the current stream can time out. - /// - /// - /// A value that determines whether the current stream can time out. - /// - public virtual bool CanTimeout - { - get - { - return false; - } - } - - /// - /// When overridden in a derived class, gets a value indicating whether the current stream supports writing. - /// - /// - /// true if the stream supports writing; otherwise, false. - /// - public abstract bool CanWrite - { - get; - } - - /// - /// When overridden in a derived class, gets the length in bytes of the stream. - /// - /// - /// A long value representing the length of the stream in bytes. - /// - public abstract long Length - { - get; - } - - /// - /// When overridden in a derived class, gets or sets the position within the current stream. - /// - /// - /// The current position within the stream. - /// - public abstract long Position - { - get; - set; - } - - /// - /// Gets or sets a value, in milliseconds, that determines how long the stream will attempt to read before timing out. - /// - /// - /// A value, in milliseconds, that determines how long the stream will attempt to read before timing out. - /// - /// - public virtual int ReadTimeout - { - get - { - throw new InvalidOperationException(); - } - - set - { - throw new InvalidOperationException(); - } - } - - /// - /// Gets or sets a value, in milliseconds, that determines how long the stream will attempt to write before timing out. - /// - /// - /// A value, in milliseconds, that determines how long the stream will attempt to write before timing out. - /// - /// - public virtual int WriteTimeout - { - get - { - throw new InvalidOperationException(); - } - - set - { - throw new InvalidOperationException(); - } - } - - /// - /// Closes the current stream and releases any resources (such as sockets and file handles) associated with the current stream. - /// Instead of calling this method, ensure that the stream is properly disposed. - /// - /// - /// Stream used to require that all cleanup logic went into Close(), - /// which was thought up before we invented IDisposable. However, we - /// need to follow the IDisposable pattern so that users can write - /// sensible subclasses without needing to inspect all their base - /// classes, and without worrying about version brittleness, from a - /// base class switching to the Dispose pattern. We're moving - /// Stream to the Dispose(bool) pattern - that's where all subclasses - /// should put their cleanup starting in V2. - /// - public virtual void Close() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// - public void Dispose() - { - try - { - Close(); - } - catch - { - } - } - - /// - /// - /// - ~Stream() - { - Dispose(false); - } - - /// - /// Releases the unmanaged resources used by the Stream and optionally releases the managed resources. - /// - /// true to release both managed and unmanaged resources; false to release only unmanaged resources. - protected virtual void Dispose(bool disposing) - { - } - - /// - /// When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device. - /// - public abstract void Flush(); - - /// - /// When overridden in a derived class, sets the position within the current stream. - /// - /// A byte offset relative to the origin parameter. - /// A value of type SeekOrigin indicating the reference point used to obtain the new position. - /// The new position within the current stream. - public abstract long Seek(long offset, SeekOrigin origin); - - /// - /// When overridden in a derived class, sets the length of the current stream. - /// - /// The desired length of the current stream in bytes. - public abstract void SetLength(long value); - - /// - /// When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. - /// - /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source. - /// The zero-based byte offset in buffer at which to begin storing the data read from the current stream. - /// The maximum number of bytes to be read from the current stream. - /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached. - public abstract int Read(byte[] buffer, int offset, int count); - - /// - /// Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream. - /// - /// The unsigned byte cast to an Int32, or -1 if at the end of the stream. - public virtual int ReadByte() - { - var oneByteArray = new byte[1]; - var r = Read(oneByteArray, 0, 1); - - if (r == 0) return -1; - - return oneByteArray[0]; - } - - /// - /// When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. - /// - /// An array of bytes. This method copies count bytes from buffer to the current stream. - /// The zero-based byte offset in buffer at which to begin copying bytes to the current stream. - /// The number of bytes to be written to the current stream. - public abstract void Write(byte[] buffer, int offset, int count); - - /// - /// Writes a byte to the current position in the stream and advances the position within the stream by one byte. - /// - /// The byte to write to the stream. - public virtual void WriteByte(byte value) - { - var oneByteArray = new byte[1]; - oneByteArray[0] = value; - Write(oneByteArray, 0, 1); - } - } -}