Describe the bug
I was updating a library and moved from 17.11 to latest. This broke a section of code that was testing for the type of stream.
if(Stream is not FileStream fileStream) { throw new ..... }
This was introduced in v 18 with the changes to FileInfoBase/FileInfoWrapper to return FileStreamWrapper over the previous Stream.
v17.2.3...v18.0.1#diff-a71278a0c7619aba1cbf96a25bf62ef95a0441ff6e8c6f8a9ce28ccf7dbca603
To Reproduce
With a version at 18 or higher try the following code:
var fs = new System.IO.Abstractions.FileSystem();
var fi = fs.FileInfo.New("path to a real file");
var st = fi.Open(FileMode.Open);
if (st is not FileStream)
{
throw new Exception("stream is not filestream");
}
Observe exception is thrown.
Expected behavior
A clear and concise description of what you expected to happen.
With similar code prior to v18
var fs = new System.IO.Abstractions.FileSystem();
var fi = fs.FileInfo.FromFileName("path to a real file");
var st = fi.Open(FileMode.Open);
if (st is not FileStream)
{
throw new Exception("stream is not filestream");
}
The exception is not thrown.
Describe the bug
I was updating a library and moved from 17.11 to latest. This broke a section of code that was testing for the type of stream.
if(Stream is not FileStream fileStream) { throw new ..... }This was introduced in v 18 with the changes to FileInfoBase/FileInfoWrapper to return FileStreamWrapper over the previous Stream.
v17.2.3...v18.0.1#diff-a71278a0c7619aba1cbf96a25bf62ef95a0441ff6e8c6f8a9ce28ccf7dbca603
To Reproduce
With a version at 18 or higher try the following code:
Observe exception is thrown.
Expected behavior
A clear and concise description of what you expected to happen.
With similar code prior to v18
The exception is not thrown.