diff --git a/Examples/AccessControlLists/AccessControlLists/CustomAccessControlStrategy.cs b/Examples/AccessControlLists/AccessControlLists/CustomAccessControlStrategy.cs
index 3fabec249..f942f2381 100644
--- a/Examples/AccessControlLists/AccessControlLists/CustomAccessControlStrategy.cs
+++ b/Examples/AccessControlLists/AccessControlLists/CustomAccessControlStrategy.cs
@@ -1,5 +1,5 @@
using System;
-using Testably.Abstractions.FileSystem;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.FileSystem;
namespace Testably.Abstractions.Examples.AccessControlLists;
diff --git a/Examples/Configuration/DependencyInjection.Tests/DependencyInjectionTests.cs b/Examples/Configuration/DependencyInjection.Tests/DependencyInjectionTests.cs
index 2a751ebd2..cf5d4d2d9 100644
--- a/Examples/Configuration/DependencyInjection.Tests/DependencyInjectionTests.cs
+++ b/Examples/Configuration/DependencyInjection.Tests/DependencyInjectionTests.cs
@@ -1,5 +1,6 @@
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
+using System.IO.Abstractions;
using Xunit;
namespace Testably.Abstractions.Examples.Configuration.DependencyInjection.Tests;
diff --git a/Examples/Configuration/FileSystemConfiguration.Tests/InitializationTests.cs b/Examples/Configuration/FileSystemConfiguration.Tests/InitializationTests.cs
index cf8506219..dd479a3b4 100644
--- a/Examples/Configuration/FileSystemConfiguration.Tests/InitializationTests.cs
+++ b/Examples/Configuration/FileSystemConfiguration.Tests/InitializationTests.cs
@@ -2,9 +2,9 @@
using FluentAssertions;
using System;
using System.IO;
+using System.IO.Abstractions;
using System.Linq;
using System.Runtime.InteropServices;
-using Testably.Abstractions.FileSystem;
using Testably.Abstractions.RandomSystem;
using Testably.Abstractions.Testing;
using Xunit;
@@ -103,7 +103,7 @@ public void LimitAvailableSpaceOnDrives()
fileSystem.File.WriteAllBytes("foo", firstFileContent);
mainDrive.AvailableFreeSpace.Should().Be(1);
- Exception exception = Record.Exception(() =>
+ Exception? exception = Record.Exception(() =>
{
fileSystem.File.WriteAllBytes("bar", secondFileContent);
});
diff --git a/Examples/Directory.Build.props b/Examples/Directory.Build.props
index 02adb62b5..7687ef278 100644
--- a/Examples/Directory.Build.props
+++ b/Examples/Directory.Build.props
@@ -36,6 +36,7 @@
+
diff --git a/Examples/ZipFile/ZipFile.Tests/ZipFileHelperTests.cs b/Examples/ZipFile/ZipFile.Tests/ZipFileHelperTests.cs
index 3d8a94fae..c4f81a1f7 100644
--- a/Examples/ZipFile/ZipFile.Tests/ZipFileHelperTests.cs
+++ b/Examples/ZipFile/ZipFile.Tests/ZipFileHelperTests.cs
@@ -1,8 +1,8 @@
using AutoFixture.Xunit2;
using FluentAssertions;
using System.IO;
+using System.IO.Abstractions;
using System.IO.Compression;
-using Testably.Abstractions.FileSystem;
using Testably.Abstractions.Testing;
using Testably.Abstractions.Testing.FileSystemInitializer;
using Xunit;
diff --git a/Examples/ZipFile/ZipFile/ZipFileHelper.cs b/Examples/ZipFile/ZipFile/ZipFileHelper.cs
index 6a13c4cb3..fd390ee60 100644
--- a/Examples/ZipFile/ZipFile/ZipFileHelper.cs
+++ b/Examples/ZipFile/ZipFile/ZipFileHelper.cs
@@ -1,6 +1,6 @@
using System.IO;
+using System.IO.Abstractions;
using System.IO.Compression;
-using Testably.Abstractions.FileSystem;
namespace Testably.Abstractions.Examples.ZipFile;
diff --git a/Source/Testably.Abstractions.AccessControl/AccessControlHelpers.cs b/Source/Testably.Abstractions.AccessControl/AccessControlHelpers.cs
index 30e61eb9a..1275a8f66 100644
--- a/Source/Testably.Abstractions.AccessControl/AccessControlHelpers.cs
+++ b/Source/Testably.Abstractions.AccessControl/AccessControlHelpers.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions;
@@ -48,4 +49,20 @@ public static IDirectoryInfo ThrowIfParentMissing(
return fileSystemInfo;
}
+
+ public static IFileSystemExtensibility GetExtensibilityOrThrow(
+ this IDirectoryInfo directoryInfo)
+ => directoryInfo as IFileSystemExtensibility
+ ?? throw new NotSupportedException(
+ $"{directoryInfo.GetType()} does not support IFileSystemExtensibility.");
+
+ public static IFileSystemExtensibility GetExtensibilityOrThrow(this IFileInfo fileInfo)
+ => fileInfo as IFileSystemExtensibility
+ ?? throw new NotSupportedException(
+ $"{fileInfo.GetType()} does not support IFileSystemExtensibility.");
+
+ public static IFileSystemExtensibility GetExtensibilityOrThrow(this FileSystemStream fileStream)
+ => fileStream as IFileSystemExtensibility
+ ?? throw new NotSupportedException(
+ $"{fileStream.GetType()} does not support IFileSystemExtensibility.");
}
diff --git a/Source/Testably.Abstractions.AccessControl/DirectoryAclExtensions.cs b/Source/Testably.Abstractions.AccessControl/DirectoryAclExtensions.cs
index cf5738989..ab25e2f64 100644
--- a/Source/Testably.Abstractions.AccessControl/DirectoryAclExtensions.cs
+++ b/Source/Testably.Abstractions.AccessControl/DirectoryAclExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Security.AccessControl;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions;
@@ -17,8 +18,7 @@ public static void CreateDirectory(this IDirectory directory,
{
IDirectoryInfo directoryInfo =
directory.FileSystem.DirectoryInfo.New(path);
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
if (extensibility.TryGetWrappedInstance(out DirectoryInfo? di))
{
di.Create(directorySecurity);
@@ -28,7 +28,7 @@ public static void CreateDirectory(this IDirectory directory,
_ = directorySecurity ?? throw new ArgumentNullException(nameof(directorySecurity));
directoryInfo.ThrowIfParentMissing();
directoryInfo.Create();
- directoryInfo.Extensibility.StoreMetadata(AccessControlHelpers.AccessControl,
+ extensibility.StoreMetadata(AccessControlHelpers.AccessControl,
directorySecurity);
}
}
@@ -41,8 +41,7 @@ public static DirectorySecurity GetAccessControl(
IDirectoryInfo directoryInfo =
directory.FileSystem.DirectoryInfo.New(path);
directoryInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out DirectoryInfo? di)
? di.GetAccessControl()
: extensibility.RetrieveMetadata(
@@ -59,8 +58,7 @@ public static DirectorySecurity GetAccessControl(
IDirectoryInfo directoryInfo =
directory.FileSystem.DirectoryInfo.New(path);
directoryInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out DirectoryInfo? di)
? di.GetAccessControl(includeSections)
: extensibility.RetrieveMetadata(
@@ -75,8 +73,7 @@ public static void SetAccessControl(this IDirectory directory,
{
IDirectoryInfo directoryInfo =
directory.FileSystem.DirectoryInfo.New(path);
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
if (extensibility.TryGetWrappedInstance(out DirectoryInfo? di))
{
di.SetAccessControl(directorySecurity);
diff --git a/Source/Testably.Abstractions.AccessControl/DirectoryInfoAclExtensions.cs b/Source/Testably.Abstractions.AccessControl/DirectoryInfoAclExtensions.cs
index d9edba740..094b0db71 100644
--- a/Source/Testably.Abstractions.AccessControl/DirectoryInfoAclExtensions.cs
+++ b/Source/Testably.Abstractions.AccessControl/DirectoryInfoAclExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Security.AccessControl;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions;
@@ -14,8 +15,7 @@ public static class DirectoryInfoAclExtensions
public static void Create(this IDirectoryInfo directoryInfo,
DirectorySecurity directorySecurity)
{
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
if (extensibility.TryGetWrappedInstance(out DirectoryInfo? di))
{
di.Create(directorySecurity);
@@ -25,7 +25,7 @@ public static void Create(this IDirectoryInfo directoryInfo,
_ = directorySecurity ?? throw new ArgumentNullException(nameof(directorySecurity));
directoryInfo.ThrowIfParentMissing();
directoryInfo.Create();
- directoryInfo.Extensibility.StoreMetadata(AccessControlHelpers.AccessControl,
+ extensibility.StoreMetadata(AccessControlHelpers.AccessControl,
directorySecurity);
}
}
@@ -36,8 +36,7 @@ public static DirectorySecurity GetAccessControl(
this IDirectoryInfo directoryInfo)
{
directoryInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out DirectoryInfo? di)
? di.GetAccessControl()
: extensibility.RetrieveMetadata(
@@ -51,8 +50,7 @@ public static DirectorySecurity GetAccessControl(
AccessControlSections includeSections)
{
directoryInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out DirectoryInfo? di)
? di.GetAccessControl(includeSections)
: extensibility.RetrieveMetadata(
@@ -64,8 +62,7 @@ public static DirectorySecurity GetAccessControl(
public static void SetAccessControl(this IDirectoryInfo directoryInfo,
DirectorySecurity directorySecurity)
{
- IFileSystemExtensibility extensibility =
- directoryInfo.Extensibility;
+ IFileSystemExtensibility extensibility = directoryInfo.GetExtensibilityOrThrow();
if (extensibility.TryGetWrappedInstance(out DirectoryInfo? di))
{
di.SetAccessControl(directorySecurity);
diff --git a/Source/Testably.Abstractions.AccessControl/FileAclExtensions.cs b/Source/Testably.Abstractions.AccessControl/FileAclExtensions.cs
index 5b9934ef0..aff05d205 100644
--- a/Source/Testably.Abstractions.AccessControl/FileAclExtensions.cs
+++ b/Source/Testably.Abstractions.AccessControl/FileAclExtensions.cs
@@ -1,5 +1,6 @@
using System.IO;
using System.Security.AccessControl;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions;
@@ -15,8 +16,7 @@ public static FileSecurity GetAccessControl(
{
IFileInfo fileInfo = file.FileSystem.FileInfo.New(path);
fileInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- fileInfo.Extensibility;
+ IFileSystemExtensibility extensibility = fileInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out FileInfo? fi)
? fi.GetAccessControl()
: extensibility.RetrieveMetadata(
@@ -32,8 +32,7 @@ public static FileSecurity GetAccessControl(
{
IFileInfo fileInfo = file.FileSystem.FileInfo.New(path);
fileInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- fileInfo.Extensibility;
+ IFileSystemExtensibility extensibility = fileInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out FileInfo? fi)
? fi.GetAccessControl(includeSections)
: extensibility.RetrieveMetadata(
@@ -47,8 +46,7 @@ public static void SetAccessControl(this IFile file,
FileSecurity fileSecurity)
{
IFileInfo fileInfo = file.FileSystem.FileInfo.New(path);
- IFileSystemExtensibility extensibility =
- fileInfo.Extensibility;
+ IFileSystemExtensibility extensibility = fileInfo.GetExtensibilityOrThrow();
if (extensibility.TryGetWrappedInstance(out FileInfo? fi))
{
fi.SetAccessControl(fileSecurity);
diff --git a/Source/Testably.Abstractions.AccessControl/FileInfoAclExtensions.cs b/Source/Testably.Abstractions.AccessControl/FileInfoAclExtensions.cs
index 980541213..4437bab5e 100644
--- a/Source/Testably.Abstractions.AccessControl/FileInfoAclExtensions.cs
+++ b/Source/Testably.Abstractions.AccessControl/FileInfoAclExtensions.cs
@@ -1,5 +1,6 @@
using System.IO;
using System.Security.AccessControl;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions;
@@ -14,8 +15,7 @@ public static FileSecurity GetAccessControl(
this IFileInfo fileInfo)
{
fileInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- fileInfo.Extensibility;
+ IFileSystemExtensibility extensibility = fileInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out FileInfo? fi)
? fi.GetAccessControl()
: extensibility.RetrieveMetadata(
@@ -29,8 +29,7 @@ public static FileSecurity GetAccessControl(
AccessControlSections includeSections)
{
fileInfo.ThrowIfMissing();
- IFileSystemExtensibility extensibility =
- fileInfo.Extensibility;
+ IFileSystemExtensibility extensibility = fileInfo.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out FileInfo? fi)
? fi.GetAccessControl(includeSections)
: extensibility.RetrieveMetadata(
@@ -42,8 +41,7 @@ public static FileSecurity GetAccessControl(
public static void SetAccessControl(this IFileInfo fileInfo,
FileSecurity fileSecurity)
{
- IFileSystemExtensibility extensibility =
- fileInfo.Extensibility;
+ IFileSystemExtensibility extensibility = fileInfo.GetExtensibilityOrThrow();
if (extensibility.TryGetWrappedInstance(out FileInfo? fi))
{
fi.SetAccessControl(fileSecurity);
diff --git a/Source/Testably.Abstractions.AccessControl/FileStreamAclExtensions.cs b/Source/Testably.Abstractions.AccessControl/FileStreamAclExtensions.cs
index 8e0fa3b0a..9eda677aa 100644
--- a/Source/Testably.Abstractions.AccessControl/FileStreamAclExtensions.cs
+++ b/Source/Testably.Abstractions.AccessControl/FileStreamAclExtensions.cs
@@ -1,5 +1,6 @@
using System.IO;
using System.Security.AccessControl;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions;
@@ -12,8 +13,7 @@ public static class FileStreamAclExtensions
[SupportedOSPlatform("windows")]
public static FileSecurity GetAccessControl(this FileSystemStream fileStream)
{
- IFileSystemExtensibility extensibility =
- fileStream.Extensibility;
+ IFileSystemExtensibility extensibility = fileStream.GetExtensibilityOrThrow();
return extensibility.TryGetWrappedInstance(out FileStream? fs)
? fs.GetAccessControl()
: extensibility.RetrieveMetadata(
@@ -25,8 +25,7 @@ public static FileSecurity GetAccessControl(this FileSystemStream fileStream)
public static void SetAccessControl(this FileSystemStream fileStream,
FileSecurity fileSecurity)
{
- IFileSystemExtensibility extensibility =
- fileStream.Extensibility;
+ IFileSystemExtensibility extensibility = fileStream.GetExtensibilityOrThrow();
if (extensibility.TryGetWrappedInstance(out FileStream? fs))
{
fs.SetAccessControl(fileSecurity);
diff --git a/Source/Testably.Abstractions.AccessControl/Usings.cs b/Source/Testably.Abstractions.AccessControl/Usings.cs
index f15db6c3f..13afd09ac 100644
--- a/Source/Testably.Abstractions.AccessControl/Usings.cs
+++ b/Source/Testably.Abstractions.AccessControl/Usings.cs
@@ -3,4 +3,4 @@
#else
global using System.Runtime.Versioning;
#endif
-global using Testably.Abstractions.FileSystem;
+global using System.IO.Abstractions;
diff --git a/Source/Testably.Abstractions.Compression/Usings.cs b/Source/Testably.Abstractions.Compression/Usings.cs
index 16d0ed6cd..babf543a4 100644
--- a/Source/Testably.Abstractions.Compression/Usings.cs
+++ b/Source/Testably.Abstractions.Compression/Usings.cs
@@ -1 +1 @@
-global using Testably.Abstractions.FileSystem;
+global using System.IO.Abstractions;
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/FileSystemStream.cs b/Source/Testably.Abstractions.Interface/FileSystem/FileSystemStream.cs
deleted file mode 100644
index 0e170c94b..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/FileSystemStream.cs
+++ /dev/null
@@ -1,214 +0,0 @@
-using System;
-using System.IO;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Wraps the .
-///
-public abstract class FileSystemStream : Stream
-{
- ///
- public override bool CanRead
- => _stream.CanRead;
-
- ///
- public override bool CanSeek
- => _stream.CanSeek;
-
- ///
- public override bool CanTimeout
- => _stream.CanTimeout;
-
- ///
- public override bool CanWrite
- => _stream.CanWrite;
-
- ///
- public bool IsAsync { get; }
-
- ///
- public override long Length
- => _stream.Length;
-
- ///
- public string Name { get; }
-
- ///
- public override long Position
- {
- get => _stream.Position;
- set => _stream.Position = value;
- }
-
- ///
- public override int ReadTimeout
- {
- get => _stream.ReadTimeout;
- set => _stream.ReadTimeout = value;
- }
-
- ///
- public override int WriteTimeout
- {
- get => _stream.WriteTimeout;
- set => _stream.WriteTimeout = value;
- }
-
- private readonly Stream _stream;
-
- ///
- /// Initializes a new instance of .
- ///
- /// The wrapped .
- /// The of the stream.
- ///
- /// The flag, indicating if the was
- /// opened asynchronously or synchronously.
- ///
- protected FileSystemStream(Stream stream, string? path, bool isAsync = false)
- {
- if (path is null)
- {
- throw new ArgumentNullException(nameof(path), "Path cannot be null.");
- }
-
- if (path.Length == 0)
- {
- throw new ArgumentException("Empty path name is not legal.", nameof(path));
- }
-
- _stream = stream;
- Name = path;
- IsAsync = isAsync;
- }
-
- ///
- /// A container to support extensions on .
- ///
- public abstract IFileSystemExtensibility Extensibility { get; }
-
- ///
- public override IAsyncResult BeginRead(byte[] buffer,
- int offset,
- int count,
- AsyncCallback? callback,
- object? state)
- => _stream.BeginRead(buffer, offset, count, callback, state);
-
- ///
- public override IAsyncResult BeginWrite(byte[] buffer,
- int offset,
- int count,
- AsyncCallback? callback,
- object? state)
- => _stream.BeginWrite(buffer, offset, count, callback, state);
-
- ///
-#if NETSTANDARD2_0
- public new virtual void CopyTo(Stream destination, int bufferSize)
- => _stream.CopyTo(destination, bufferSize);
-#else
- public override void CopyTo(Stream destination, int bufferSize)
- => _stream.CopyTo(destination, bufferSize);
-#endif
-
- ///
- public override Task CopyToAsync(Stream destination,
- int bufferSize,
- CancellationToken cancellationToken)
- => _stream.CopyToAsync(destination, bufferSize, cancellationToken);
-
- ///
- public override int EndRead(IAsyncResult asyncResult)
- => _stream.EndRead(asyncResult);
-
- ///
- public override void EndWrite(IAsyncResult asyncResult)
- => _stream.EndWrite(asyncResult);
-
- ///
- public override void Flush()
- => _stream.Flush();
-
- ///
- public override Task FlushAsync(CancellationToken cancellationToken)
- => _stream.FlushAsync(cancellationToken);
-
- ///
- public override int Read(byte[] buffer, int offset, int count)
- => _stream.Read(buffer, offset, count);
-
-#if FEATURE_SPAN
- ///
- public override int Read(Span buffer)
- => _stream.Read(buffer);
-#endif
-
- ///
- public override Task ReadAsync(byte[] buffer,
- int offset,
- int count,
- CancellationToken cancellationToken)
- => _stream.ReadAsync(buffer, offset, count, cancellationToken);
-
-#if FEATURE_SPAN
- ///
- public override ValueTask ReadAsync(Memory buffer,
- CancellationToken cancellationToken = new())
- => _stream.ReadAsync(buffer, cancellationToken);
-#endif
-
- ///
- public override int ReadByte()
- => _stream.ReadByte();
-
- ///
- public override long Seek(long offset, SeekOrigin origin)
- => _stream.Seek(offset, origin);
-
- ///
- public override void SetLength(long value)
- => _stream.SetLength(value);
-
- ///
- public override string? ToString()
- => _stream.ToString();
-
- ///
- public override void Write(byte[] buffer, int offset, int count)
- => _stream.Write(buffer, offset, count);
-
-#if FEATURE_SPAN
- ///
- public override void Write(ReadOnlySpan buffer)
- => _stream.Write(buffer);
-#endif
-
- ///
- public override Task WriteAsync(byte[] buffer,
- int offset,
- int count,
- CancellationToken cancellationToken)
- => _stream.WriteAsync(buffer, offset, count, cancellationToken);
-
-#if FEATURE_SPAN
- ///
- public override ValueTask WriteAsync(ReadOnlyMemory buffer,
- CancellationToken cancellationToken = new())
- => _stream.WriteAsync(buffer, cancellationToken);
-#endif
-
- ///
- public override void WriteByte(byte value)
- => _stream.WriteByte(value);
-
- ///
- protected override void Dispose(bool disposing)
- {
- _stream.Dispose();
- base.Dispose(disposing);
- }
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IDirectory.cs b/Source/Testably.Abstractions.Interface/FileSystem/IDirectory.cs
deleted file mode 100644
index 6cd897b23..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IDirectory.cs
+++ /dev/null
@@ -1,207 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IDirectory : IFileSystemEntity
-{
- ///
- IDirectoryInfo CreateDirectory(string path);
-
-#if FEATURE_FILESYSTEM_UNIXFILEMODE
- ///
- IDirectoryInfo CreateDirectory(string path, UnixFileMode unixCreateMode);
-#endif
-
-#if FEATURE_FILESYSTEM_LINK
- ///
- IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget);
-#endif
-
-#if FEATURE_FILESYSTEM_NET7
- ///
- IDirectoryInfo CreateTempSubdirectory(string? prefix = null);
-#endif
-
- ///
- void Delete(string path);
-
- ///
- void Delete(string path, bool recursive);
-
- ///
- IEnumerable EnumerateDirectories(string path);
-
- ///
- IEnumerable EnumerateDirectories(string path, string searchPattern);
-
- ///
- IEnumerable EnumerateDirectories(string path,
- string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateDirectories(string path,
- string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IEnumerable EnumerateFiles(string path);
-
- ///
- IEnumerable EnumerateFiles(string path, string searchPattern);
-
- ///
- IEnumerable EnumerateFiles(string path,
- string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFiles(string path,
- string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IEnumerable EnumerateFileSystemEntries(string path);
-
- ///
- IEnumerable EnumerateFileSystemEntries(string path, string searchPattern);
-
- ///
- IEnumerable EnumerateFileSystemEntries(string path,
- string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFileSystemEntries(string path,
- string searchPattern,
- EnumerationOptions
- enumerationOptions);
-#endif
-
- ///
- bool Exists([NotNullWhen(true)] string? path);
-
- ///
- DateTime GetCreationTime(string path);
-
- ///
- DateTime GetCreationTimeUtc(string path);
-
- ///
- string GetCurrentDirectory();
-
- ///
- string[] GetDirectories(string path);
-
- ///
- string[] GetDirectories(string path, string searchPattern);
-
- ///
- string[] GetDirectories(string path,
- string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- string[] GetDirectories(string path,
- string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- string GetDirectoryRoot(string path);
-
- ///
- string[] GetFiles(string path);
-
- ///
- string[] GetFiles(string path, string searchPattern);
-
- ///
- string[] GetFiles(string path,
- string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- string[] GetFiles(string path,
- string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- string[] GetFileSystemEntries(string path);
-
- ///
- string[] GetFileSystemEntries(string path, string searchPattern);
-
- ///
- string[] GetFileSystemEntries(string path,
- string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- string[] GetFileSystemEntries(string path,
- string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- DateTime GetLastAccessTime(string path);
-
- ///
- DateTime GetLastAccessTimeUtc(string path);
-
- ///
- DateTime GetLastWriteTime(string path);
-
- ///
- DateTime GetLastWriteTimeUtc(string path);
-
- ///
- string[] GetLogicalDrives();
-
- ///
- IDirectoryInfo? GetParent(string path);
-
- ///
- void Move(string sourceDirName, string destDirName);
-
-#if FEATURE_FILESYSTEM_LINK
- ///
- IFileSystemInfo? ResolveLinkTarget(string linkPath, bool returnFinalTarget);
-#endif
-
- ///
- void SetCreationTime(string path, DateTime creationTime);
-
- ///
- void SetCreationTimeUtc(string path, DateTime creationTimeUtc);
-
- ///
- void SetCurrentDirectory(string path);
-
- ///
- void SetLastAccessTime(string path, DateTime lastAccessTime);
-
- ///
- void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc);
-
- ///
- void SetLastWriteTime(string path, DateTime lastWriteTime);
-
- ///
- void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IDirectoryInfo.cs b/Source/Testably.Abstractions.Interface/FileSystem/IDirectoryInfo.cs
deleted file mode 100644
index c187e3896..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IDirectoryInfo.cs
+++ /dev/null
@@ -1,123 +0,0 @@
-using System.Collections.Generic;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IDirectoryInfo : IFileSystemInfo
-{
- ///
- IDirectoryInfo? Parent { get; }
-
- ///
- IDirectoryInfo Root { get; }
-
- ///
- void Create();
-
- ///
- IDirectoryInfo CreateSubdirectory(string path);
-
- ///
- void Delete(bool recursive);
-
- ///
- IEnumerable EnumerateDirectories();
-
- ///
- IEnumerable EnumerateDirectories(string searchPattern);
-
- ///
- IEnumerable EnumerateDirectories(string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateDirectories(string searchPattern,
- EnumerationOptions
- enumerationOptions);
-#endif
-
- ///
- IEnumerable EnumerateFiles();
-
- ///
- IEnumerable EnumerateFiles(string searchPattern);
-
- ///
- IEnumerable EnumerateFiles(string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFiles(string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IEnumerable EnumerateFileSystemInfos();
-
- ///
- IEnumerable EnumerateFileSystemInfos(string searchPattern);
-
- ///
- IEnumerable EnumerateFileSystemInfos(string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IEnumerable EnumerateFileSystemInfos(string searchPattern,
- EnumerationOptions
- enumerationOptions);
-#endif
-
- ///
- IDirectoryInfo[] GetDirectories();
-
- ///
- IDirectoryInfo[] GetDirectories(string searchPattern);
-
- ///
- IDirectoryInfo[] GetDirectories(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IDirectoryInfo[] GetDirectories(string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IFileInfo[] GetFiles();
-
- ///
- IFileInfo[] GetFiles(string searchPattern);
-
- ///
- IFileInfo[] GetFiles(string searchPattern, SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IFileInfo[] GetFiles(string searchPattern, EnumerationOptions enumerationOptions);
-#endif
-
- ///
- IFileSystemInfo[] GetFileSystemInfos();
-
- ///
- IFileSystemInfo[] GetFileSystemInfos(string searchPattern);
-
- ///
- IFileSystemInfo[] GetFileSystemInfos(string searchPattern,
- SearchOption searchOption);
-
-#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
- ///
- IFileSystemInfo[] GetFileSystemInfos(string searchPattern,
- EnumerationOptions enumerationOptions);
-#endif
-
- ///
- void MoveTo(string destDirName);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IDirectoryInfoFactory.cs b/Source/Testably.Abstractions.Interface/FileSystem/IDirectoryInfoFactory.cs
deleted file mode 100644
index 8c35c86cb..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IDirectoryInfoFactory.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Factory for abstracting the creation of .
-///
-public interface IDirectoryInfoFactory : IFileSystemEntity
-{
- ///
- IDirectoryInfo New(string path);
-
- ///
- /// Wraps the to the testable interface .
- ///
- [return: NotNullIfNotNull("directoryInfo")]
- IDirectoryInfo? Wrap(DirectoryInfo? directoryInfo);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IDriveInfo.cs b/Source/Testably.Abstractions.Interface/FileSystem/IDriveInfo.cs
deleted file mode 100644
index 752880723..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IDriveInfo.cs
+++ /dev/null
@@ -1,42 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IDriveInfo : IFileSystemEntity
-{
- ///
- long AvailableFreeSpace { get; }
-
- ///
- string DriveFormat { get; }
-
- ///
- DriveType DriveType { get; }
-
- ///
- bool IsReady { get; }
-
- ///
- string Name { get; }
-
- ///
- IDirectoryInfo RootDirectory { get; }
-
- ///
- long TotalFreeSpace { get; }
-
- ///
- long TotalSize { get; }
-
- ///
- [AllowNull]
- string VolumeLabel
- {
- get;
- [SupportedOSPlatform("windows")] set;
- }
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IDriveInfoFactory.cs b/Source/Testably.Abstractions.Interface/FileSystem/IDriveInfoFactory.cs
deleted file mode 100644
index 8d98c74ee..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IDriveInfoFactory.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Factory for abstracting the creation of .
-///
-public interface IDriveInfoFactory : IFileSystemEntity
-{
- ///
- IDriveInfo[] GetDrives();
-
- ///
- IDriveInfo New(string driveName);
-
- ///
- /// Wraps the to the testable interface .
- ///
- [return: NotNullIfNotNull("driveInfo")]
- IDriveInfo? Wrap(DriveInfo? driveInfo);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFile.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFile.cs
deleted file mode 100644
index 725fb7bd8..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFile.cs
+++ /dev/null
@@ -1,397 +0,0 @@
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
-using Microsoft.Win32.SafeHandles;
-#endif
-using System;
-using System.Collections.Generic;
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-using System.Text;
-#if FEATURE_FILESYSTEM_ASYNC
-using System.Threading;
-using System.Threading.Tasks;
-#endif
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IFile : IFileSystemEntity
-{
- ///
- void AppendAllLines(string path, IEnumerable contents);
-
- ///
- void AppendAllLines(string path, IEnumerable contents, Encoding encoding);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task AppendAllLinesAsync(string path,
- IEnumerable contents,
- CancellationToken cancellationToken = default);
-
- ///
- Task AppendAllLinesAsync(string path,
- IEnumerable contents,
- Encoding encoding,
- CancellationToken cancellationToken = default);
-#endif
-
- ///
- void AppendAllText(string path, string? contents);
-
- ///
- void AppendAllText(string path, string? contents, Encoding encoding);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task AppendAllTextAsync(string path,
- string? contents,
- CancellationToken cancellationToken = default);
-
- ///
- Task AppendAllTextAsync(string path,
- string? contents,
- Encoding encoding,
- CancellationToken cancellationToken = default);
-#endif
-
- ///
- StreamWriter AppendText(string path);
-
- ///
- void Copy(string sourceFileName, string destFileName);
-
- ///
- void Copy(string sourceFileName, string destFileName, bool overwrite);
-
- ///
- FileSystemStream Create(string path);
-
- ///
- FileSystemStream Create(string path, int bufferSize);
-
- ///
- FileSystemStream Create(string path, int bufferSize, FileOptions options);
-
-#if FEATURE_FILESYSTEM_LINK
- ///
- IFileSystemInfo CreateSymbolicLink(string path, string pathToTarget);
-#endif
-
- ///
- StreamWriter CreateText(string path);
-
- ///
- [SupportedOSPlatform("windows")]
- void Decrypt(string path);
-
- ///
- void Delete(string path);
-
- ///
- [SupportedOSPlatform("windows")]
- void Encrypt(string path);
-
- ///
- bool Exists([NotNullWhen(true)] string? path);
-
- ///
- FileAttributes GetAttributes(string path);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- FileAttributes GetAttributes(SafeFileHandle fileHandle);
-#endif
-
- ///
- DateTime GetCreationTime(string path);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- DateTime GetCreationTime(SafeFileHandle fileHandle);
-#endif
-
- ///
- DateTime GetCreationTimeUtc(string path);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- DateTime GetCreationTimeUtc(SafeFileHandle fileHandle);
-#endif
-
- ///
- DateTime GetLastAccessTime(string path);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- DateTime GetLastAccessTime(SafeFileHandle fileHandle);
-#endif
-
- ///
- DateTime GetLastAccessTimeUtc(string path);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- DateTime GetLastAccessTimeUtc(SafeFileHandle fileHandle);
-#endif
-
- ///
- DateTime GetLastWriteTime(string path);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- DateTime GetLastWriteTime(SafeFileHandle fileHandle);
-#endif
-
- ///
- DateTime GetLastWriteTimeUtc(string path);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- DateTime GetLastWriteTimeUtc(SafeFileHandle fileHandle);
-#endif
-
-#if FEATURE_FILESYSTEM_UNIXFILEMODE
- ///
- [UnsupportedOSPlatform("windows")]
- UnixFileMode GetUnixFileMode(string path);
-#endif
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- [UnsupportedOSPlatform("windows")]
- UnixFileMode GetUnixFileMode(SafeFileHandle fileHandle);
-#endif
-
- ///
- void Move(string sourceFileName, string destFileName);
-
-#if FEATURE_FILE_MOVETO_OVERWRITE
- ///
- void Move(string sourceFileName, string destFileName, bool overwrite);
-#endif
-
- ///
- FileSystemStream Open(string path, FileMode mode);
-
- ///
- FileSystemStream Open(string path, FileMode mode, FileAccess access);
-
- ///
- FileSystemStream Open(string path, FileMode mode, FileAccess access,
- FileShare share);
-
-#if FEATURE_FILESYSTEM_STREAM_OPTIONS
- ///
- FileSystemStream Open(string path, FileStreamOptions options);
-#endif
-
- ///
- FileSystemStream OpenRead(string path);
-
- ///
- StreamReader OpenText(string path);
-
- ///
- FileSystemStream OpenWrite(string path);
-
- ///
- byte[] ReadAllBytes(string path);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task ReadAllBytesAsync(string path,
- CancellationToken cancellationToken = default);
-#endif
-
- ///
- string[] ReadAllLines(string path);
-
- ///
- string[] ReadAllLines(string path, Encoding encoding);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task ReadAllLinesAsync(string path,
- CancellationToken cancellationToken = default);
-
- ///
- Task ReadAllLinesAsync(string path,
- Encoding encoding,
- CancellationToken cancellationToken = default);
-#endif
-
- ///
- string ReadAllText(string path);
-
- ///
- string ReadAllText(string path, Encoding encoding);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task ReadAllTextAsync(string path,
- CancellationToken cancellationToken = default);
-
- ///
- Task ReadAllTextAsync(string path,
- Encoding encoding,
- CancellationToken cancellationToken = default);
-#endif
-
- ///
- IEnumerable ReadLines(string path);
-
- ///
- IEnumerable ReadLines(string path, Encoding encoding);
-
-#if FEATURE_FILESYSTEM_NET7
- ///
- IAsyncEnumerable ReadLinesAsync(string path,
- CancellationToken cancellationToken =
- default);
-
- ///
- IAsyncEnumerable ReadLinesAsync(string path, Encoding encoding,
- CancellationToken cancellationToken =
- default);
-#endif
-
- ///
- void Replace(string sourceFileName,
- string destinationFileName,
- string? destinationBackupFileName);
-
- ///
- void Replace(string sourceFileName,
- string destinationFileName,
- string? destinationBackupFileName,
- bool ignoreMetadataErrors);
-
-#if FEATURE_FILESYSTEM_LINK
- ///
- IFileSystemInfo? ResolveLinkTarget(string linkPath, bool returnFinalTarget);
-#endif
-
- ///
- void SetAttributes(string path, FileAttributes fileAttributes);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- void SetAttributes(SafeFileHandle fileHandle, FileAttributes fileAttributes);
-#endif
-
- ///
- void SetCreationTime(string path, DateTime creationTime);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- void SetCreationTime(SafeFileHandle fileHandle, DateTime creationTime);
-#endif
-
- ///
- void SetCreationTimeUtc(string path, DateTime creationTimeUtc);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- void SetCreationTimeUtc(SafeFileHandle fileHandle, DateTime creationTimeUtc);
-#endif
-
- ///
- void SetLastAccessTime(string path, DateTime lastAccessTime);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- void SetLastAccessTime(SafeFileHandle fileHandle, DateTime lastAccessTime);
-#endif
-
- ///
- void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- void SetLastAccessTimeUtc(SafeFileHandle fileHandle, DateTime lastAccessTimeUtc);
-#endif
-
- ///
- void SetLastWriteTime(string path, DateTime lastWriteTime);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- void SetLastWriteTime(SafeFileHandle fileHandle, DateTime lastWriteTime);
-#endif
-
- ///
- void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc);
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- void SetLastWriteTimeUtc(SafeFileHandle fileHandle, DateTime lastWriteTimeUtc);
-#endif
-
-#if FEATURE_FILESYSTEM_UNIXFILEMODE
- ///
- [UnsupportedOSPlatform("windows")]
- void SetUnixFileMode(string path, UnixFileMode mode);
-#endif
-
-#if FEATURE_FILESYSTEM_SAFEFILEHANDLE
- ///
- [UnsupportedOSPlatform("windows")]
- void SetUnixFileMode(SafeFileHandle fileHandle, UnixFileMode mode);
-#endif
-
- ///
- void WriteAllBytes(string path, byte[] bytes);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task WriteAllBytesAsync(string path,
- byte[] bytes,
- CancellationToken cancellationToken = default);
-#endif
-
- ///
- void WriteAllLines(string path, string[] contents);
-
- ///
- void WriteAllLines(string path, IEnumerable contents);
-
- ///
- void WriteAllLines(string path, string[] contents, Encoding encoding);
-
- ///
- void WriteAllLines(string path, IEnumerable contents, Encoding encoding);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task WriteAllLinesAsync(string path,
- IEnumerable contents,
- CancellationToken cancellationToken = default);
-
- ///
- Task WriteAllLinesAsync(string path,
- IEnumerable contents,
- Encoding encoding,
- CancellationToken cancellationToken = default);
-#endif
-
- ///
- void WriteAllText(string path, string? contents);
-
- ///
- void WriteAllText(string path, string? contents, Encoding encoding);
-
-#if FEATURE_FILESYSTEM_ASYNC
- ///
- Task WriteAllTextAsync(string path,
- string? contents,
- CancellationToken cancellationToken = default);
-
- ///
- Task WriteAllTextAsync(string path,
- string? contents,
- Encoding encoding,
- CancellationToken cancellationToken = default);
-#endif
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileInfo.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFileInfo.cs
deleted file mode 100644
index f882ea5e7..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileInfo.cs
+++ /dev/null
@@ -1,84 +0,0 @@
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IFileInfo : IFileSystemInfo
-{
- ///
- IDirectoryInfo? Directory { get; }
-
- ///
- string? DirectoryName { get; }
-
- ///
- bool IsReadOnly { get; set; }
-
- ///
- long Length { get; }
-
- ///
- public StreamWriter AppendText();
-
- ///
- IFileInfo CopyTo(string destFileName);
-
- ///
- IFileInfo CopyTo(string destFileName, bool overwrite);
-
- ///
- FileSystemStream Create();
-
- ///
- public StreamWriter CreateText();
-
- ///
- [SupportedOSPlatform("windows")]
- void Decrypt();
-
- ///
- [SupportedOSPlatform("windows")]
- void Encrypt();
-
- ///
- void MoveTo(string destFileName);
-
-#if FEATURE_FILE_MOVETO_OVERWRITE
- ///
- void MoveTo(string destFileName, bool overwrite);
-#endif
-
- ///
- FileSystemStream Open(FileMode mode);
-
- ///
- FileSystemStream Open(FileMode mode, FileAccess access);
-
- ///
- FileSystemStream Open(FileMode mode, FileAccess access, FileShare share);
-
-#if FEATURE_FILESYSTEM_STREAM_OPTIONS
- ///
- FileSystemStream Open(FileStreamOptions options);
-#endif
-
- ///
- FileSystemStream OpenRead();
-
- ///
- public StreamReader OpenText();
-
- ///
- FileSystemStream OpenWrite();
-
- ///
- IFileInfo Replace(string destinationFileName,
- string? destinationBackupFileName);
-
- ///
- IFileInfo Replace(string destinationFileName,
- string? destinationBackupFileName,
- bool ignoreMetadataErrors);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileInfoFactory.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFileInfoFactory.cs
deleted file mode 100644
index 48a816e73..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileInfoFactory.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Factory for abstracting the creation of .
-///
-public interface IFileInfoFactory : IFileSystemEntity
-{
- ///
- IFileInfo New(string fileName);
-
- ///
- /// Wraps the to the testable interface .
- ///
- [return: NotNullIfNotNull("fileInfo")]
- IFileInfo? Wrap(FileInfo? fileInfo);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileStreamFactory.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFileStreamFactory.cs
deleted file mode 100644
index a4c2f690c..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileStreamFactory.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using Microsoft.Win32.SafeHandles;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Factory for abstracting creation of .
-///
-public interface IFileStreamFactory : IFileSystemEntity
-{
- ///
- FileSystemStream New(SafeFileHandle handle, FileAccess access);
-
- ///
- FileSystemStream New(SafeFileHandle handle, FileAccess access, int bufferSize);
-
- ///
- FileSystemStream New(SafeFileHandle handle, FileAccess access, int bufferSize,
- bool isAsync);
-
- ///
- FileSystemStream New(string path, FileMode mode);
-
- ///
- FileSystemStream New(string path, FileMode mode, FileAccess access);
-
- ///
- FileSystemStream New(string path, FileMode mode, FileAccess access,
- FileShare share);
-
- ///
- FileSystemStream New(string path, FileMode mode, FileAccess access,
- FileShare share, int bufferSize);
-
- ///
- FileSystemStream New(string path, FileMode mode, FileAccess access,
- FileShare share, int bufferSize, bool useAsync);
-
- ///
- FileSystemStream New(string path, FileMode mode, FileAccess access,
- FileShare share, int bufferSize, FileOptions options);
-
-#if FEATURE_FILESYSTEM_STREAM_OPTIONS
- ///
- FileSystemStream New(string path, FileStreamOptions options);
-#endif
-
- ///
- /// Wraps the to the testable .
- ///
- FileSystemStream Wrap(FileStream fileStream);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemEntity.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemEntity.cs
deleted file mode 100644
index d280fe53c..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemEntity.cs
+++ /dev/null
@@ -1,14 +0,0 @@
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Interface to support implementing extension methods on top of nested interfaces.
-///
-public interface IFileSystemEntity
-{
- ///
- /// Exposes the underlying file system implementation.
- ///
- /// This is useful for implementing extension methods.
- ///
- IFileSystem FileSystem { get; }
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemInfo.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemInfo.cs
deleted file mode 100644
index 71c942848..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemInfo.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IFileSystemInfo : IFileSystemEntity
-{
- ///
- FileAttributes Attributes { get; set; }
-
- ///
- DateTime CreationTime { get; set; }
-
- ///
- DateTime CreationTimeUtc { get; set; }
-
- ///
- bool Exists { get; }
-
- ///
- string Extension { get; }
-
- ///
- /// A container to support extensions on .
- ///
- IFileSystemExtensibility Extensibility { get; }
-
- ///
- string FullName { get; }
-
- ///
- DateTime LastAccessTime { get; set; }
-
- ///
- DateTime LastAccessTimeUtc { get; set; }
-
- ///
- DateTime LastWriteTime { get; set; }
-
- ///
- DateTime LastWriteTimeUtc { get; set; }
-
-#if FEATURE_FILESYSTEM_LINK
- ///
- string? LinkTarget { get; }
-#endif
-
- ///
- string Name { get; }
-
-#if FEATURE_FILESYSTEM_UNIXFILEMODE
- ///
- UnixFileMode UnixFileMode
- {
- get;
- [UnsupportedOSPlatform("windows")] set;
- }
-#endif
-
-#if FEATURE_FILESYSTEM_LINK
- ///
- void CreateAsSymbolicLink(string pathToTarget);
-#endif
-
- ///
- void Delete();
-
- ///
- void Refresh();
-
-#if FEATURE_FILESYSTEM_LINK
- ///
- IFileSystemInfo? ResolveLinkTarget(bool returnFinalTarget);
-#endif
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemWatcher.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemWatcher.cs
deleted file mode 100644
index bf26b8ae2..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemWatcher.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.IO;
-#if FEATURE_FILESYSTEMWATCHER_ADVANCED
-using System.Collections.ObjectModel;
-#endif
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IFileSystemWatcher : IFileSystemEntity, IDisposable
-{
- ///
- IContainer? Container { get; }
-
- ///
- bool EnableRaisingEvents { get; set; }
-
- ///
- string Filter { get; set; }
-
-#if FEATURE_FILESYSTEMWATCHER_ADVANCED
- ///
- Collection Filters { get; }
-#endif
-
- ///
- bool IncludeSubdirectories { get; set; }
-
- ///
- int InternalBufferSize { get; set; }
-
- ///
- NotifyFilters NotifyFilter { get; set; }
-
- ///
- string Path { get; set; }
-
- ///
- ISite? Site { get; set; }
-
- ///
- ISynchronizeInvoke? SynchronizingObject { get; set; }
-
- ///
- event FileSystemEventHandler? Changed;
-
- ///
- event FileSystemEventHandler? Created;
-
- ///
- event FileSystemEventHandler? Deleted;
-
- ///
- event ErrorEventHandler? Error;
-
- ///
- event RenamedEventHandler? Renamed;
-
- ///
- void BeginInit();
-
- ///
- void EndInit();
-
- ///
- IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType);
-
- ///
- IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, int timeout);
-
-#if FEATURE_FILESYSTEM_NET7
- ///
- IWaitForChangedResult WaitForChanged(WatcherChangeTypes changeType, TimeSpan timeout);
-#endif
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemWatcherFactory.cs b/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemWatcherFactory.cs
deleted file mode 100644
index 6c1465b21..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemWatcherFactory.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Factory for abstracting the creation of .
-///
-public interface IFileSystemWatcherFactory : IFileSystemEntity
-{
- ///
- IFileSystemWatcher New();
-
- ///
- IFileSystemWatcher New(string path);
-
- ///
- IFileSystemWatcher New(string path, string filter);
-
- ///
- /// Wraps the to the testable interface .
- ///
- [return: NotNullIfNotNull("fileSystemWatcher")]
- IFileSystemWatcher? Wrap(FileSystemWatcher? fileSystemWatcher);
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IPath.cs b/Source/Testably.Abstractions.Interface/FileSystem/IPath.cs
deleted file mode 100644
index 671908142..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IPath.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-using System.Diagnostics.CodeAnalysis;
-using System.IO;
-#if FEATURE_SPAN
-using System;
-#endif
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IPath : IFileSystemEntity
-{
- ///
- char AltDirectorySeparatorChar { get; }
-
- ///
- char DirectorySeparatorChar { get; }
-
- ///
- char PathSeparator { get; }
-
- ///
- char VolumeSeparatorChar { get; }
-
- ///
- [return: NotNullIfNotNull("path")]
- string? ChangeExtension(string? path, string? extension);
-
- ///
- string Combine(string path1, string path2);
-
- ///
- string Combine(string path1, string path2, string path3);
-
- ///
- string Combine(string path1, string path2, string path3, string path4);
-
- ///
- string Combine(params string[] paths);
-
-#if FEATURE_FILESYSTEM_NET7
- ///
- bool Exists([NotNullWhen(true)] string? path);
-#endif
-
-#if FEATURE_SPAN
- ///
- ReadOnlySpan GetDirectoryName(ReadOnlySpan path);
-#endif
-
- ///
- string? GetDirectoryName(string? path);
-
-#if FEATURE_SPAN
- ///
- ReadOnlySpan GetExtension(ReadOnlySpan path);
-#endif
-
- ///
- [return: NotNullIfNotNull("path")]
- string? GetExtension(string? path);
-
-#if FEATURE_SPAN
- ///
- ReadOnlySpan GetFileName(ReadOnlySpan path);
-#endif
-
- ///
- [return: NotNullIfNotNull("path")]
- string? GetFileName(string? path);
-
-#if FEATURE_SPAN
- ///
- ReadOnlySpan GetFileNameWithoutExtension(ReadOnlySpan path);
-#endif
-
- ///
- [return: NotNullIfNotNull("path")]
- string? GetFileNameWithoutExtension(string? path);
-
- ///
- string GetFullPath(string path);
-
-#if FEATURE_PATH_RELATIVE
- ///
- string GetFullPath(string path, string basePath);
-#endif
-
- ///
- char[] GetInvalidFileNameChars();
-
- ///
- char[] GetInvalidPathChars();
-
-#if FEATURE_SPAN
- ///
- ReadOnlySpan GetPathRoot(ReadOnlySpan path);
-#endif
-
- ///
- string? GetPathRoot(string? path);
-
- ///
- string GetRandomFileName();
-
-#if FEATURE_PATH_RELATIVE
- ///
- string GetRelativePath(string relativeTo, string path);
-#endif
-
- ///
-#if !NETSTANDARD2_0
- [Obsolete(
- "Insecure temporary file creation methods should not be used. Use `Path.Combine(Path.GetTempPath(), Path.GetRandomFileName())` instead.")]
-#endif
- // ReSharper disable once UnusedMember.Global -- marked as Obsolete
- string GetTempFileName();
-
- ///
- string GetTempPath();
-
-#if FEATURE_SPAN
- ///
- bool HasExtension(ReadOnlySpan path);
-#endif
-
- ///
- bool HasExtension([NotNullWhen(true)] string? path);
-
-#if FEATURE_SPAN
- ///
- bool IsPathFullyQualified(ReadOnlySpan path);
-#endif
-
-#if FEATURE_PATH_RELATIVE
- ///
- bool IsPathFullyQualified(string path);
-#endif
-
-#if FEATURE_SPAN
- ///
- bool IsPathRooted(ReadOnlySpan path);
-#endif
-
- ///
- bool IsPathRooted([NotNullWhen(true)] string? path);
-
-#if FEATURE_PATH_ADVANCED
- ///
- bool EndsInDirectorySeparator(ReadOnlySpan path);
-
- ///
- bool EndsInDirectorySeparator(string path);
-#endif
-
-#if FEATURE_PATH_JOIN
- ///
- string Join(ReadOnlySpan path1, ReadOnlySpan path2);
-
- ///
- string Join(ReadOnlySpan path1,
- ReadOnlySpan path2,
- ReadOnlySpan path3);
-#endif
-
-#if FEATURE_PATH_ADVANCED
- ///
- string Join(ReadOnlySpan path1,
- ReadOnlySpan path2,
- ReadOnlySpan path3,
- ReadOnlySpan path4);
-
- ///
- string Join(string? path1, string? path2);
-
- ///
- string Join(string? path1, string? path2, string? path3);
-
- ///
- string Join(string? path1, string? path2, string? path3, string? path4);
-
- ///
- string Join(params string?[] paths);
-#endif
-
-#if FEATURE_PATH_ADVANCED
- ///
- ReadOnlySpan TrimEndingDirectorySeparator(ReadOnlySpan path);
-
- ///
- string TrimEndingDirectorySeparator(string path);
-#endif
-
-#if FEATURE_PATH_JOIN
- ///
- bool TryJoin(ReadOnlySpan path1,
- ReadOnlySpan path2,
- Span destination,
- out int charsWritten);
-
- ///
- bool TryJoin(ReadOnlySpan path1,
- ReadOnlySpan path2,
- ReadOnlySpan path3,
- Span destination,
- out int charsWritten);
-#endif
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IWaitForChangedResult.cs b/Source/Testably.Abstractions.Interface/FileSystem/IWaitForChangedResult.cs
deleted file mode 100644
index d992a3d44..000000000
--- a/Source/Testably.Abstractions.Interface/FileSystem/IWaitForChangedResult.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System.IO;
-
-namespace Testably.Abstractions.FileSystem;
-
-///
-/// Abstractions for .
-///
-public interface IWaitForChangedResult
-{
- ///
- WatcherChangeTypes ChangeType { get; }
-
- ///
- string? Name { get; }
-
- ///
- string? OldName { get; }
-
- ///
- bool TimedOut { get; }
-}
diff --git a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemExtensibility.cs b/Source/Testably.Abstractions.Interface/Helpers/IFileSystemExtensibility.cs
similarity index 94%
rename from Source/Testably.Abstractions.Interface/FileSystem/IFileSystemExtensibility.cs
rename to Source/Testably.Abstractions.Interface/Helpers/IFileSystemExtensibility.cs
index fe7922b3c..ab637e741 100644
--- a/Source/Testably.Abstractions.Interface/FileSystem/IFileSystemExtensibility.cs
+++ b/Source/Testably.Abstractions.Interface/Helpers/IFileSystemExtensibility.cs
@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
+using System.IO.Abstractions;
-namespace Testably.Abstractions.FileSystem;
+namespace Testably.Abstractions.Helpers;
///
/// A container to support extensions on entities.
diff --git a/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs b/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs
index d28b6f7b1..03cb8d8f1 100644
--- a/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs
+++ b/Source/Testably.Abstractions.Interface/Helpers/PathSystemBase.cs
@@ -1,6 +1,6 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
-using Testably.Abstractions.FileSystem;
+using System.IO.Abstractions;
#if !NETSTANDARD2_0
using System;
#endif
diff --git a/Source/Testably.Abstractions.Interface/IFileSystem.cs b/Source/Testably.Abstractions.Interface/IFileSystem.cs
deleted file mode 100644
index 023fa0e4f..000000000
--- a/Source/Testably.Abstractions.Interface/IFileSystem.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Testably.Abstractions.FileSystem;
-
-namespace Testably.Abstractions;
-
-///
-/// Allows abstracting file-related system dependencies.
-///
-public interface IFileSystem
-{
- ///
- /// Abstractions for .
- ///
- IDirectory Directory { get; }
-
- ///
- /// Factory for abstracting creation of .
- ///
- IDirectoryInfoFactory DirectoryInfo { get; }
-
- ///
- /// Factory for abstracting creation of .
- ///
- IDriveInfoFactory DriveInfo { get; }
-
- ///
- /// Abstractions for .
- ///
- IFile File { get; }
-
- ///
- /// Factory for abstracting creation of .
- ///
- IFileInfoFactory FileInfo { get; }
-
- ///
- /// Factory for abstracting creation of .
- ///
- IFileStreamFactory FileStream { get; }
-
- ///
- /// Factory for abstracting creation of .
- ///
- IFileSystemWatcherFactory FileSystemWatcher { get; }
-
- ///
- /// Abstractions for .
- ///
- IPath Path { get; }
-}
diff --git a/Source/Testably.Abstractions.Interface/Testably.Abstractions.Interface.csproj b/Source/Testably.Abstractions.Interface/Testably.Abstractions.Interface.csproj
index e4306e570..fc934dfbf 100644
--- a/Source/Testably.Abstractions.Interface/Testably.Abstractions.Interface.csproj
+++ b/Source/Testably.Abstractions.Interface/Testably.Abstractions.Interface.csproj
@@ -17,4 +17,8 @@
+
+
+
+
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/DefaultAccessControlStrategy.cs b/Source/Testably.Abstractions.Testing/FileSystem/DefaultAccessControlStrategy.cs
index e1cd38d57..ba6a89141 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/DefaultAccessControlStrategy.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/DefaultAccessControlStrategy.cs
@@ -1,4 +1,5 @@
using System;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions.Testing.FileSystem;
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs
index 845256553..3286f7709 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoFactoryMock.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics.CodeAnalysis;
+using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using Testably.Abstractions.Testing.Helpers;
@@ -19,6 +20,11 @@ internal DirectoryInfoFactoryMock(MockFileSystem fileSystem)
public IFileSystem FileSystem
=> _fileSystem;
+ ///
+ [Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")]
+ public IDirectoryInfo FromDirectoryName(string directoryName)
+ => New(directoryName);
+
///
public IDirectoryInfo New(string path)
{
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoMock.cs
index b24fb5f29..d0d9cd91a 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/DirectoryInfoMock.cs
@@ -44,7 +44,7 @@ public void Create()
Container = _fileSystem.Storage.GetOrCreateContainer(Location,
InMemoryContainer.NewDirectory,
- Extensibility);
+ this);
ResetCache(!Execute.IsNetFramework);
}
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs
index b445806f6..052aef285 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/DriveInfoFactoryMock.cs
@@ -21,6 +21,11 @@ internal DriveInfoFactoryMock(MockFileSystem fileSystem)
public IFileSystem FileSystem
=> _fileSystem;
+ ///
+ [Obsolete("Use `IDriveInfoFactory.New(string)` instead")]
+ public IDriveInfo FromDriveName(string driveName)
+ => New(driveName);
+
///
public IDriveInfo[] GetDrives()
=> _fileSystem.Storage.GetDrives()
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs
index 86b35d86f..bf9eed183 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/FileInfoFactoryMock.cs
@@ -20,6 +20,11 @@ internal FileInfoFactoryMock(MockFileSystem fileSystem)
public IFileSystem FileSystem
=> _fileSystem;
+ ///
+ [Obsolete("Use `IFileInfoFactory.New(string)` instead")]
+ public IFileInfo FromFileName(string fileName)
+ => New(fileName);
+
///
public IFileInfo New(string fileName)
{
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs
index aca33ee87..79016ab2a 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/FileStreamFactoryMock.cs
@@ -1,6 +1,7 @@
using Microsoft.Win32.SafeHandles;
using System.IO;
using Testably.Abstractions.Testing.Helpers;
+using System;
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
#endif
@@ -25,6 +26,73 @@ internal FileStreamFactoryMock(MockFileSystem fileSystem)
public IFileSystem FileSystem
=> _fileSystem;
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode)` instead")]
+ public Stream Create(string path, FileMode mode)
+ => New(path, mode);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access)
+ => New(path, mode, access);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share)
+ => New(path, mode, access, share);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
+ => New(path, mode, access, share, bufferSize);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, FileOptions)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ FileOptions options)
+ => New(path, mode, access, share, bufferSize, options);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, bool)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ bool useAsync)
+ => New(path, mode, access, share, bufferSize, useAsync);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess)` instead")]
+ public Stream Create(SafeFileHandle handle, FileAccess access)
+ => New(handle, access);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int)` instead")]
+ public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize)
+ => New(handle, access, bufferSize);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int, bool)` instead")]
+ public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
+ => New(handle, access, bufferSize, isAsync);
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access)
+ => throw new NotImplementedException();
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle)
+ => throw new NotImplementedException();
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize)
+ => throw new NotImplementedException();
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int, bool) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync)
+ => throw new NotImplementedException();
+
///
public FileSystemStream New(string path, FileMode mode)
=> New(path,
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileStreamMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileStreamMock.cs
index 84bd8f724..aaadcef2a 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/FileStreamMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/FileStreamMock.cs
@@ -1,7 +1,9 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.Helpers;
using Testably.Abstractions.Testing.Storage;
@@ -10,7 +12,7 @@ namespace Testably.Abstractions.Testing.FileSystem;
///
/// A mocked file stream in the .
///
-internal sealed class FileStreamMock : FileSystemStream
+internal sealed class FileStreamMock : FileSystemStream, IFileSystemExtensibility
{
///
public override bool CanRead
@@ -20,10 +22,6 @@ public override bool CanRead
public override bool CanWrite
=> _access.HasFlag(FileAccess.Write);
- ///
- public override IFileSystemExtensibility Extensibility
- => _container.Extensibility;
-
private readonly FileAccess _access;
private readonly IDisposable _accessLock;
private readonly IStorageContainer _container;
@@ -89,7 +87,8 @@ private FileStreamMock(MemoryStream stream,
}
file = _fileSystem.Storage.GetOrCreateContainer(location,
- InMemoryContainer.NewFile);
+ InMemoryContainer.NewFile,
+ this);
}
else if (file.Type == FileSystemTypes.Directory)
{
@@ -450,4 +449,16 @@ private static void ThrowIfInvalidModeAccess(FileMode mode, FileAccess access)
throw ExceptionFactory.InvalidAccessCombination(mode, access);
}
}
+
+ ///
+ public bool TryGetWrappedInstance([NotNullWhen(true)] out T? wrappedInstance)
+ => _container.Extensibility.TryGetWrappedInstance(out wrappedInstance);
+
+ ///
+ public void StoreMetadata(string key, T? value)
+ => _container.Extensibility.StoreMetadata(key, value);
+
+ ///
+ public T? RetrieveMetadata(string key)
+ => _container.Extensibility.RetrieveMetadata(key);
}
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileSystemInfoMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileSystemInfoMock.cs
index 3d1d9d713..c0cc6bc3e 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/FileSystemInfoMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/FileSystemInfoMock.cs
@@ -1,11 +1,13 @@
using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.Helpers;
using Testably.Abstractions.Testing.Storage;
namespace Testably.Abstractions.Testing.FileSystem;
-internal class FileSystemInfoMock : IFileSystemInfo
+internal class FileSystemInfoMock : IFileSystemInfo, IFileSystemExtensibility
{
protected FileSystemTypes FileSystemType { get; }
protected IStorageLocation Location;
@@ -117,10 +119,6 @@ public string Extension
}
}
- ///
- public IFileSystemExtensibility Extensibility
- => Container.Extensibility;
-
///
public IFileSystem FileSystem
=> _fileSystem;
@@ -219,6 +217,18 @@ public void Refresh()
#endregion
+ ///
+ public bool TryGetWrappedInstance([NotNullWhen(true)] out T? wrappedInstance)
+ => Container.Extensibility.TryGetWrappedInstance(out wrappedInstance);
+
+ ///
+ public void StoreMetadata(string key, T? value)
+ => Container.Extensibility.StoreMetadata(key, value);
+
+ ///
+ public T? RetrieveMetadata(string key)
+ => Container.Extensibility.RetrieveMetadata(key);
+
#if NETSTANDARD2_0
///
#else
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs b/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs
index 88cf8bae4..48e6c3537 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/FileSystemWatcherFactoryMock.cs
@@ -1,11 +1,12 @@
-using System.Diagnostics.CodeAnalysis;
+using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using Testably.Abstractions.Testing.Helpers;
namespace Testably.Abstractions.Testing.FileSystem;
-internal sealed class
- FileSystemWatcherFactoryMock : IFileSystemWatcherFactory
+internal sealed class FileSystemWatcherFactoryMock
+ : IFileSystemWatcherFactory
{
private readonly MockFileSystem _fileSystem;
@@ -20,6 +21,21 @@ internal FileSystemWatcherFactoryMock(MockFileSystem fileSystem)
public IFileSystem FileSystem
=> _fileSystem;
+ ///
+ [Obsolete("Use `IFileSystemWatcherFactory.New()` instead")]
+ public IFileSystemWatcher CreateNew()
+ => New();
+
+ ///
+ [Obsolete("Use `IFileSystemWatcherFactory.New(string)` instead")]
+ public IFileSystemWatcher CreateNew(string path)
+ => New(path);
+
+ ///
+ [Obsolete("Use `IFileSystemWatcherFactory.New(string, string)` instead")]
+ public IFileSystemWatcher CreateNew(string path, string filter)
+ => New(path, filter);
+
///
public IFileSystemWatcher New()
=> FileSystemWatcherMock.New(_fileSystem);
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/IAccessControlStrategy.cs b/Source/Testably.Abstractions.Testing/FileSystem/IAccessControlStrategy.cs
index ad6b66ff6..2b0c3de2d 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/IAccessControlStrategy.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/IAccessControlStrategy.cs
@@ -1,4 +1,6 @@
-namespace Testably.Abstractions.Testing.FileSystem;
+using Testably.Abstractions.Helpers;
+
+namespace Testably.Abstractions.Testing.FileSystem;
///
/// The strategy to simulate access control (ACL) in the .
diff --git a/Source/Testably.Abstractions.Testing/FileSystem/NullAccessControlStrategy.cs b/Source/Testably.Abstractions.Testing/FileSystem/NullAccessControlStrategy.cs
index e21757429..7473e7ade 100644
--- a/Source/Testably.Abstractions.Testing/FileSystem/NullAccessControlStrategy.cs
+++ b/Source/Testably.Abstractions.Testing/FileSystem/NullAccessControlStrategy.cs
@@ -1,4 +1,6 @@
-namespace Testably.Abstractions.Testing.FileSystem;
+using Testably.Abstractions.Helpers;
+
+namespace Testably.Abstractions.Testing.FileSystem;
///
/// Null object of an which does not restrict access in any way.
diff --git a/Source/Testably.Abstractions.Testing/Helpers/FileSystemExtensibility.cs b/Source/Testably.Abstractions.Testing/Helpers/FileSystemExtensibility.cs
index bdfe283c3..1b86d139e 100644
--- a/Source/Testably.Abstractions.Testing/Helpers/FileSystemExtensibility.cs
+++ b/Source/Testably.Abstractions.Testing/Helpers/FileSystemExtensibility.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions.Testing.Helpers;
diff --git a/Source/Testably.Abstractions.Testing/MockFileSystem.cs b/Source/Testably.Abstractions.Testing/MockFileSystem.cs
index 998c91f66..8f02c3ba0 100644
--- a/Source/Testably.Abstractions.Testing/MockFileSystem.cs
+++ b/Source/Testably.Abstractions.Testing/MockFileSystem.cs
@@ -115,7 +115,7 @@ public IPath Path
/// The defines a method that receives two values and allows or denies access:
///
/// - The full path of the file or directory as first parameter
- /// - The as second parameter
+ /// - The as second parameter
///
public MockFileSystem WithAccessControlStrategy(IAccessControlStrategy accessControlStrategy)
{
diff --git a/Source/Testably.Abstractions.Testing/Storage/IStorage.cs b/Source/Testably.Abstractions.Testing/Storage/IStorage.cs
index 700121623..16bcf6542 100644
--- a/Source/Testably.Abstractions.Testing/Storage/IStorage.cs
+++ b/Source/Testably.Abstractions.Testing/Storage/IStorage.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.IO;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.Helpers;
namespace Testably.Abstractions.Testing.Storage;
diff --git a/Source/Testably.Abstractions.Testing/Storage/IStorageContainer.cs b/Source/Testably.Abstractions.Testing/Storage/IStorageContainer.cs
index 5838ab61e..0404baea0 100644
--- a/Source/Testably.Abstractions.Testing/Storage/IStorageContainer.cs
+++ b/Source/Testably.Abstractions.Testing/Storage/IStorageContainer.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.TimeSystem;
namespace Testably.Abstractions.Testing.Storage;
diff --git a/Source/Testably.Abstractions.Testing/Storage/InMemoryContainer.cs b/Source/Testably.Abstractions.Testing/Storage/InMemoryContainer.cs
index 392b1a88b..a031f0ffc 100644
--- a/Source/Testably.Abstractions.Testing/Storage/InMemoryContainer.cs
+++ b/Source/Testably.Abstractions.Testing/Storage/InMemoryContainer.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.FileSystem;
using Testably.Abstractions.Testing.Helpers;
using Testably.Abstractions.TimeSystem;
diff --git a/Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs b/Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs
index d75e1d7c6..557702a7b 100644
--- a/Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs
+++ b/Source/Testably.Abstractions.Testing/Storage/InMemoryStorage.cs
@@ -4,6 +4,7 @@
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.FileSystem;
using Testably.Abstractions.Testing.Helpers;
diff --git a/Source/Testably.Abstractions.Testing/Storage/NullContainer.cs b/Source/Testably.Abstractions.Testing/Storage/NullContainer.cs
index abf9ab117..ffd92bcb0 100644
--- a/Source/Testably.Abstractions.Testing/Storage/NullContainer.cs
+++ b/Source/Testably.Abstractions.Testing/Storage/NullContainer.cs
@@ -1,5 +1,6 @@
using System;
using System.IO;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.Helpers;
using Testably.Abstractions.TimeSystem;
diff --git a/Source/Testably.Abstractions.Testing/Usings.cs b/Source/Testably.Abstractions.Testing/Usings.cs
index f15db6c3f..13afd09ac 100644
--- a/Source/Testably.Abstractions.Testing/Usings.cs
+++ b/Source/Testably.Abstractions.Testing/Usings.cs
@@ -3,4 +3,4 @@
#else
global using System.Runtime.Versioning;
#endif
-global using Testably.Abstractions.FileSystem;
+global using System.IO.Abstractions;
diff --git a/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs b/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs
index f4cfc5518..76819e798 100644
--- a/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs
+++ b/Source/Testably.Abstractions/FileSystem/DirectoryInfoFactory.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics.CodeAnalysis;
+using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
namespace Testably.Abstractions.FileSystem;
@@ -15,6 +16,11 @@ internal DirectoryInfoFactory(RealFileSystem fileSystem)
///
public IFileSystem FileSystem { get; }
+ ///
+ [Obsolete("Use `IDirectoryInfoFactory.New(string)` instead")]
+ public IDirectoryInfo FromDirectoryName(string directoryName)
+ => New(directoryName);
+
///
public IDirectoryInfo New(string path)
=> DirectoryInfoWrapper.FromDirectoryInfo(
diff --git a/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs b/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs
index 83bdee3fa..ecd69ec91 100644
--- a/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs
+++ b/Source/Testably.Abstractions/FileSystem/DriveInfoFactory.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics.CodeAnalysis;
+using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
@@ -16,6 +17,11 @@ internal DriveInfoFactory(RealFileSystem fileSystem)
///
public IFileSystem FileSystem { get; }
+ ///
+ [Obsolete("Use `IDriveInfoFactory.New(string)` instead")]
+ public IDriveInfo FromDriveName(string driveName)
+ => New(driveName);
+
///
public IDriveInfo[] GetDrives()
=> DriveInfo.GetDrives()
diff --git a/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs b/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs
index 14ac45803..be1289c5b 100644
--- a/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs
+++ b/Source/Testably.Abstractions/FileSystem/FileInfoFactory.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics.CodeAnalysis;
+using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
namespace Testably.Abstractions.FileSystem;
@@ -15,6 +16,11 @@ internal FileInfoFactory(RealFileSystem fileSystem)
///
public IFileSystem FileSystem { get; }
+ ///
+ [Obsolete("Use `IFileInfoFactory.New(string)` instead")]
+ public IFileInfo FromFileName(string fileName)
+ => New(fileName);
+
///
public IFileInfo New(string fileName)
=> FileInfoWrapper.FromFileInfo(
diff --git a/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs b/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs
index 55ff1b24d..2bbceb7bb 100644
--- a/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs
+++ b/Source/Testably.Abstractions/FileSystem/FileStreamFactory.cs
@@ -1,4 +1,5 @@
using Microsoft.Win32.SafeHandles;
+using System;
using System.IO;
#if NET6_0_OR_GREATER
using System.Diagnostics.CodeAnalysis;
@@ -18,6 +19,73 @@ internal FileStreamFactory(RealFileSystem fileSystem)
///
public IFileSystem FileSystem { get; }
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode)` instead")]
+ public Stream Create(string path, FileMode mode)
+ => New(path, mode);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access)
+ => New(path, mode, access);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share)
+ => New(path, mode, access, share);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize)
+ => New(path, mode, access, share, bufferSize);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, FileOptions)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ FileOptions options)
+ => New(path, mode, access, share, bufferSize, options);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(string, FileMode, FileAccess, FileShare, int, bool)` instead")]
+ public Stream Create(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize,
+ bool useAsync)
+ => New(path, mode, access, share, bufferSize, useAsync);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess)` instead")]
+ public Stream Create(SafeFileHandle handle, FileAccess access)
+ => New(handle, access);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int)` instead")]
+ public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize)
+ => New(handle, access, bufferSize);
+
+ ///
+ [Obsolete("Use `IFileStreamFactory.New(SafeFileHandle, FileAccess, int, bool)` instead")]
+ public Stream Create(SafeFileHandle handle, FileAccess access, int bufferSize, bool isAsync)
+ => New(handle, access, bufferSize, isAsync);
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access)
+ => throw new NotImplementedException();
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle)
+ => throw new NotImplementedException();
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize)
+ => throw new NotImplementedException();
+
+ ///
+ [Obsolete("This method has been deprecated. Please use New(SafeFileHandle, FileAccess, int, bool) instead. http://go.microsoft.com/fwlink/?linkid=14202")]
+ public Stream Create(IntPtr handle, FileAccess access, bool ownsHandle, int bufferSize, bool isAsync)
+ => throw new NotImplementedException();
+
///
public FileSystemStream New(string path, FileMode mode)
=> Wrap(new FileStream(path, mode));
diff --git a/Source/Testably.Abstractions/FileSystem/FileStreamWrapper.cs b/Source/Testably.Abstractions/FileSystem/FileStreamWrapper.cs
index 2a754edfc..2aa858597 100644
--- a/Source/Testably.Abstractions/FileSystem/FileStreamWrapper.cs
+++ b/Source/Testably.Abstractions/FileSystem/FileStreamWrapper.cs
@@ -1,19 +1,29 @@
-using System.IO;
+using System.Diagnostics.CodeAnalysis;
+using System.IO;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions.FileSystem;
-internal sealed class FileStreamWrapper : FileSystemStream
+internal sealed class FileStreamWrapper : FileSystemStream, IFileSystemExtensibility
{
+ private readonly FileSystemExtensibility _extensibility;
+
public FileStreamWrapper(FileStream fileStream)
: base(fileStream, fileStream.Name, fileStream.IsAsync)
{
- Extensibility = new FileSystemExtensibility(fileStream);
+ _extensibility = new FileSystemExtensibility(fileStream);
}
- ///
- public override IFileSystemExtensibility Extensibility
- {
- get;
- }
+ ///
+ public bool TryGetWrappedInstance([NotNullWhen(true)] out T? wrappedInstance)
+ => _extensibility.TryGetWrappedInstance(out wrappedInstance);
+
+ ///
+ public void StoreMetadata(string key, T? value)
+ => _extensibility.StoreMetadata(key, value);
+
+ ///
+ public T? RetrieveMetadata(string key)
+ => _extensibility.RetrieveMetadata(key);
}
diff --git a/Source/Testably.Abstractions/FileSystem/FileSystemExtensibility.cs b/Source/Testably.Abstractions/FileSystem/FileSystemExtensibility.cs
index b6965b179..37100745c 100644
--- a/Source/Testably.Abstractions/FileSystem/FileSystemExtensibility.cs
+++ b/Source/Testably.Abstractions/FileSystem/FileSystemExtensibility.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions.FileSystem;
diff --git a/Source/Testably.Abstractions/FileSystem/FileSystemInfoWrapper.cs b/Source/Testably.Abstractions/FileSystem/FileSystemInfoWrapper.cs
index d3d40f6ff..0063f34b6 100644
--- a/Source/Testably.Abstractions/FileSystem/FileSystemInfoWrapper.cs
+++ b/Source/Testably.Abstractions/FileSystem/FileSystemInfoWrapper.cs
@@ -1,18 +1,20 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions.FileSystem;
-internal class FileSystemInfoWrapper : IFileSystemInfo
+internal class FileSystemInfoWrapper : IFileSystemInfo, IFileSystemExtensibility
{
private readonly FileSystemInfo _instance;
+ private readonly FileSystemExtensibility _extensibility;
internal FileSystemInfoWrapper(FileSystemInfo instance, IFileSystem fileSystem)
{
_instance = instance;
FileSystem = fileSystem;
- Extensibility = new FileSystemExtensibility(_instance);
+ _extensibility = new FileSystemExtensibility(_instance);
}
#region IFileSystemInfo Members
@@ -46,9 +48,6 @@ public bool Exists
public string Extension
=> _instance.Extension;
- ///
- public IFileSystemExtensibility Extensibility { get; }
-
///
public IFileSystem FileSystem { get; }
@@ -154,4 +153,16 @@ public override string ToString()
return null;
}
+
+ ///
+ public bool TryGetWrappedInstance([NotNullWhen(true)] out T? wrappedInstance)
+ => _extensibility.TryGetWrappedInstance(out wrappedInstance);
+
+ ///
+ public void StoreMetadata(string key, T? value)
+ => _extensibility.StoreMetadata(key, value);
+
+ ///
+ public T? RetrieveMetadata(string key)
+ => _extensibility.RetrieveMetadata(key);
}
diff --git a/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs b/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs
index dcbf06a2c..b171bfcd9 100644
--- a/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs
+++ b/Source/Testably.Abstractions/FileSystem/FileSystemWatcherFactory.cs
@@ -1,4 +1,5 @@
-using System.Diagnostics.CodeAnalysis;
+using System;
+using System.Diagnostics.CodeAnalysis;
using System.IO;
namespace Testably.Abstractions.FileSystem;
@@ -15,6 +16,21 @@ internal FileSystemWatcherFactory(RealFileSystem fileSystem)
///
public IFileSystem FileSystem { get; }
+ ///
+ [Obsolete("Use `IFileSystemWatcherFactory.New()` instead")]
+ public IFileSystemWatcher CreateNew()
+ => New();
+
+ ///
+ [Obsolete("Use `IFileSystemWatcherFactory.New(string)` instead")]
+ public IFileSystemWatcher CreateNew(string path)
+ => New(path);
+
+ ///
+ [Obsolete("Use `IFileSystemWatcherFactory.New(string, string)` instead")]
+ public IFileSystemWatcher CreateNew(string path, string filter)
+ => New(path, filter);
+
///
public IFileSystemWatcher New()
=> FileSystemWatcherWrapper.FromFileSystemWatcher(
diff --git a/Source/Testably.Abstractions/Usings.cs b/Source/Testably.Abstractions/Usings.cs
index acb44645c..13afd09ac 100644
--- a/Source/Testably.Abstractions/Usings.cs
+++ b/Source/Testably.Abstractions/Usings.cs
@@ -3,3 +3,4 @@
#else
global using System.Runtime.Versioning;
#endif
+global using System.IO.Abstractions;
diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestBase.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestBase.cs
index 0e502d8c3..d63b36877 100644
--- a/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestBase.cs
+++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestBase.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO.Abstractions;
namespace Testably.Abstractions.TestHelpers;
diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Test.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/Test.cs
index b7043aa1a..33cf0a2ab 100644
--- a/Tests/Helpers/Testably.Abstractions.TestHelpers/Test.cs
+++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/Test.cs
@@ -1,3 +1,4 @@
+using System.IO.Abstractions;
using System.Runtime.InteropServices;
using Xunit;
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs
index 033ccb476..fde8d98e7 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs
@@ -1,6 +1,6 @@
global using FluentAssertions;
global using System;
-global using Testably.Abstractions.FileSystem;
+global using System.IO.Abstractions;
global using Testably.Abstractions.TestHelpers;
// ReSharper disable once RedundantUsingDirective.Global
global using Testably.Abstractions.Testing;
diff --git a/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs
index 1ac664d84..a4d755796 100644
--- a/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs
+++ b/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs
@@ -1,7 +1,7 @@
global using AutoFixture.Xunit2;
global using FluentAssertions;
global using System;
-global using Testably.Abstractions.FileSystem;
+global using System.IO.Abstractions;
global using Testably.Abstractions.TestHelpers;
global using Testably.Abstractions.Testing;
global using Xunit;
diff --git a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs
index 168110d56..6008ebd08 100644
--- a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs
+++ b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs
@@ -1,4 +1,4 @@
global using FluentAssertions;
global using System;
-global using Testably.Abstractions.FileSystem;
+global using System.IO.Abstractions;
global using Xunit;
diff --git a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/LockableContainer.cs b/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/LockableContainer.cs
index 932c0d604..80480b1f2 100644
--- a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/LockableContainer.cs
+++ b/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/LockableContainer.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Linq;
using System.Security.AccessControl;
+using Testably.Abstractions.Helpers;
using Testably.Abstractions.Testing.Helpers;
using Testably.Abstractions.Testing.Storage;
using Testably.Abstractions.TimeSystem;
diff --git a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs
index 9ef088684..011d29062 100644
--- a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs
+++ b/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs
@@ -1,5 +1,5 @@
global using AutoFixture.Xunit2;
global using FluentAssertions;
global using System;
-global using Testably.Abstractions.FileSystem;
+global using System.IO.Abstractions;
global using Xunit;
diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs
index e62ccaa65..8540d54a4 100644
--- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs
+++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions.Tests.FileSystem.FileStream;
@@ -130,8 +131,10 @@ public void Extensibility_ShouldWrapFileStreamOnRealFileSystem(
{
FileSystem.File.WriteAllText(path, null);
using FileSystemStream readStream = FileSystem.File.OpenRead(path);
- bool result = readStream.Extensibility
- .TryGetWrappedInstance(out System.IO.FileStream? fileStream);
+ IFileSystemExtensibility? extensibility = readStream as IFileSystemExtensibility;
+ bool result = extensibility?.TryGetWrappedInstance(out System.IO.FileStream? fileStream)
+ ?? throw new NotSupportedException(
+ $"{readStream.GetType()} does not implement IFileSystemExtensibility");
if (FileSystem is RealFileSystem)
{
diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs
index 4d7ccff09..5a8709dcd 100644
--- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs
+++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs
@@ -1,4 +1,5 @@
using System.IO;
+using Testably.Abstractions.Helpers;
namespace Testably.Abstractions.Tests.FileSystem.FileSystemInfo;
@@ -14,7 +15,11 @@ public void Extensibility_ShouldWrapFileSystemInfoOnRealFileSystem(
{
FileSystem.File.WriteAllText(path, null);
IFileInfo fileInfo = FileSystem.FileInfo.New(path);
- bool result = fileInfo.Extensibility
+ IFileSystemExtensibility extensibility = fileInfo as IFileSystemExtensibility
+ ?? throw new NotSupportedException(
+ $"{fileInfo.GetType()} does not implement IFileSystemExtensibility");
+
+ bool result = extensibility
.TryGetWrappedInstance(out System.IO.FileSystemInfo? fileSystemInfo);
if (FileSystem is RealFileSystem)
diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs
index 5697edd81..3bc23a49c 100644
--- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs
+++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs
@@ -1,3 +1,5 @@
+using Testably.Abstractions.Helpers;
+
namespace Testably.Abstractions.Tests.FileSystem;
public abstract partial class FileSystemTests
@@ -9,8 +11,11 @@ public void
Extensibility_HasWrappedInstance_WithCorrectType_ShouldReturnTrueOnRealFileSystem(
string name)
{
- bool result = FileSystem.FileInfo.New(name).Extensibility
- .TryGetWrappedInstance(out System.IO.FileInfo? fileInfo);
+ IFileInfo entity = FileSystem.FileInfo.New(name);
+ IFileSystemExtensibility? extensibility = entity as IFileSystemExtensibility;
+ bool result = extensibility?.TryGetWrappedInstance(out System.IO.FileInfo? fileInfo)
+ ?? throw new NotSupportedException(
+ $"{entity.GetType()} does not implement IFileSystemExtensibility");
if (FileSystem is RealFileSystem)
{
@@ -29,8 +34,11 @@ public void
Extensibility_HasWrappedInstance_WithIncorrectType_ShouldReturnAlwaysFalse(
string name)
{
- bool result = FileSystem.FileInfo.New(name).Extensibility
- .TryGetWrappedInstance(out System.IO.DirectoryInfo? directoryInfo);
+ IFileInfo entity = FileSystem.FileInfo.New(name);
+ IFileSystemExtensibility? extensibility = entity as IFileSystemExtensibility;
+ bool result = extensibility?.TryGetWrappedInstance(out System.IO.DirectoryInfo? directoryInfo)
+ ?? throw new NotSupportedException(
+ $"{entity.GetType()} does not implement IFileSystemExtensibility");
result.Should().BeFalse();
directoryInfo.Should().BeNull();
@@ -42,8 +50,10 @@ public void
Extensibility_RetrieveMetadata_CorrectKeyAndType_ShouldReturnStoredValue(
string name, DateTime time)
{
- IFileSystemExtensibility sut = FileSystem.FileInfo.New(name)
- .Extensibility;
+ IFileInfo entity = FileSystem.FileInfo.New(name);
+ IFileSystemExtensibility sut = entity as IFileSystemExtensibility
+ ?? throw new NotSupportedException(
+ $"{entity.GetType()} does not implement IFileSystemExtensibility");
sut.StoreMetadata("foo", time);
DateTime? result = sut.RetrieveMetadata("foo");
@@ -56,8 +66,10 @@ public void
public void Extensibility_RetrieveMetadata_DifferentKey_ShouldReturnNull(
string name)
{
- IFileSystemExtensibility sut = FileSystem.FileInfo.New(name)
- .Extensibility;
+ IFileInfo entity = FileSystem.FileInfo.New(name);
+ IFileSystemExtensibility sut = entity as IFileSystemExtensibility
+ ?? throw new NotSupportedException(
+ $"{entity.GetType()} does not implement IFileSystemExtensibility");
sut.StoreMetadata("foo", DateTime.Now);
DateTime? result = sut.RetrieveMetadata("bar");
@@ -70,8 +82,10 @@ public void Extensibility_RetrieveMetadata_DifferentKey_ShouldReturnNull(
public void Extensibility_RetrieveMetadata_DifferentType_ShouldReturnNull(
string name)
{
- IFileSystemExtensibility sut = FileSystem.FileInfo.New(name)
- .Extensibility;
+ IFileInfo entity = FileSystem.FileInfo.New(name);
+ IFileSystemExtensibility sut = entity as IFileSystemExtensibility
+ ?? throw new NotSupportedException(
+ $"{entity.GetType()} does not implement IFileSystemExtensibility");
sut.StoreMetadata("foo", DateTime.Now);
TimeSpan? result = sut.RetrieveMetadata("foo");
@@ -84,8 +98,12 @@ public void Extensibility_RetrieveMetadata_DifferentType_ShouldReturnNull(
public void Extensibility_RetrieveMetadata_NotRegisteredKey_ShouldReturnNull(
string name)
{
- object? result = FileSystem.FileInfo.New(name).Extensibility
- .RetrieveMetadata