From b8a60fe95e8154ef66f23ac5749d657568b965b5 Mon Sep 17 00:00:00 2001 From: Birnsen Date: Tue, 31 Jan 2023 16:54:30 +0100 Subject: [PATCH] Add an explicit cast operator for FileSystemStream This commit adds an explicit cast to change the fact, that the underlaying FileStream could not be accessed in any way. This has also the advantage that if the library is updated no code change is necessary if a cast was present from a stream. --- .../FileSystemStream.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/TestableIO.System.IO.Abstractions/FileSystemStream.cs b/src/TestableIO.System.IO.Abstractions/FileSystemStream.cs index 839986a75..f0a9abcc1 100644 --- a/src/TestableIO.System.IO.Abstractions/FileSystemStream.cs +++ b/src/TestableIO.System.IO.Abstractions/FileSystemStream.cs @@ -204,5 +204,15 @@ protected override void Dispose(bool disposing) _stream.Dispose(); base.Dispose(disposing); } + + /// + /// Allows to cast the internal Stream to a FileStream + /// + /// The FileSystemStream to cast + /// + public static explicit operator FileStream(FileSystemStream fsStream) + { + return (FileStream) fsStream._stream; + } } } \ No newline at end of file