DoenaSoft.AbstractionLayer.IO
6.0.6
dotnet add package DoenaSoft.AbstractionLayer.IO --version 6.0.6
NuGet\Install-Package DoenaSoft.AbstractionLayer.IO -Version 6.0.6
<PackageReference Include="DoenaSoft.AbstractionLayer.IO" Version="6.0.6" />
<PackageVersion Include="DoenaSoft.AbstractionLayer.IO" Version="6.0.6" />
<PackageReference Include="DoenaSoft.AbstractionLayer.IO" />
paket add DoenaSoft.AbstractionLayer.IO --version 6.0.6
#r "nuget: DoenaSoft.AbstractionLayer.IO, 6.0.6"
#:package DoenaSoft.AbstractionLayer.IO@6.0.6
#addin nuget:?package=DoenaSoft.AbstractionLayer.IO&version=6.0.6
#tool nuget:?package=DoenaSoft.AbstractionLayer.IO&version=6.0.6
DoenaSoft.AbstractionLayer.IO
File I/O interface contracts to simplify unit testing of file operations. This project contains interface definitions only and targets .NET Standard 2.0, .NET Framework 4.7.2, and .NET 10 to be usable from multiple framework versions.
Package Id: DoenaSoft.AbstractionLayer.IO
Targets: netstandard2.0, net472, net10.0
Overview
This package contains only the interface contracts for file I/O abstractions. For production use, you'll also need the default implementations package: DoenaSoft.AbstractionLayer.IO.Default which contains System.IO-based implementations of these interfaces.
License: MIT
Interfaces
The project provides several interfaces that represent parts of the file system. The primary entry point is IIOServices and the contracts include:
Core Interfaces
IIOServices- The main entry point that aggregates access to all I/O services. Provides factory methods for files, folders, drives, and file system watchers.
Base Interface
IIOServiceItem- Base interface for all types that provide access to the masterIIOServicesinterface. All file system-related interfaces inherit from this.
Path and File Operations
IPath- Provides path manipulation helpers (combine, get extension, get folder name, change extension, etc.)IFile- Static file operations (exists, copy, move, delete, read all bytes/lines/text, write all bytes/lines/text, append, open streams, get/set attributes and timestamps, replace, etc.)IFileInfo- Instance-based file operations and metadata (name, extension, full name, folder, size, attributes, timestamps, exists, copy, move, delete, open streams, create text, etc.)
Folder Operations
IFolder- Static folder operations (exists, create, delete, get files/folders, move, get/set current folder, get parent, etc.)IFolderInfo- Instance-based folder operations and metadata (name, full name, parent, root, drive, attributes, timestamps, exists, create, delete, move, get files/folders, etc.)
Drive and File System Watching
IDriveInfo- Drive-specific information (name, drive type, drive format, drive letter, volume label, ready state, available free space, total free space, total size, root folder, etc.)IFileSystemWatcher- File system change notification abstraction with events for file creation, deletion, and renaming.
Supporting Interfaces
ILogger- Logging abstraction used by implementations to record I/O operations.IRenameQueue- Queue abstraction for managing mass file rename operations with automatic rollback support. Supports progress reporting and configurable rollback behavior.IRenameProgress- Progress information for rename queue operations (total, completed, current files, percent complete).IRenameResult- Result information for rename operations including successful/failed files and rollback details.IRenameResultDetail- Details of a single rename operation (source, target, error message).IShortcut- Abstraction for creating and managing file shortcuts with description, target path, and working folder.
Enumerations
RenameRollbackBehaviour- Specifies rollback behavior when rename operations fail (Automatic, Manual, None).
Usage
In Production Code
Program against these interfaces and inject implementations at runtime. For the default System.IO-based implementations, reference the DoenaSoft.AbstractionLayer.IO.Default package:
using DoenaSoft.AbstractionLayer.IOServices;
public class FileProcessor
{
private readonly IIOServices _io;
public FileProcessor(IIOServices io)
{
_io = io;
}
public string ReadFirstLine(string path)
{
var fileContent = _io.File.ReadAllText(path);
return fileContent.Split('\n')[0];
}
}
// In your application startup (using DoenaSoft.AbstractionLayer.IO.Default):
var io = new IOServices();
var processor = new FileProcessor(io);
In Unit Tests
Reference only this contracts package and provide test doubles to avoid disk I/O:
class FakeFile : IFile
{
public IIOServices IOServices { get; }
public bool Exists(string fileName) => true;
public string ReadAllText(string path) => "line 1\nline 2";
// ... implement other IFile members used by your code
}
class FakeIOServices : IIOServices
{
public IPath Path => throw new NotImplementedException();
public IFile File => new FakeFile();
public IFolder Folder => throw new NotImplementedException();
// ... implement only the members your tests need
}
// In your test
var fake = new FakeIOServices();
var processor = new FileProcessor(fake);
var firstLine = processor.ReadFirstLine("any.txt");
Assert.AreEqual("line 1", firstLine);
Testing Benefits
- Replace the real file system with an in-memory
IIOServicesfake during tests to avoid touching the disk - Set up deterministic file state for tests
- Verify that your code attempts the correct file operations
- Test error handling (file not found, access denied) without relying on platform-specific behavior
- Keep test projects lightweight by referencing only the contracts package
Package Architecture
DoenaSoft.AbstractionLayer.IO(this package) - Interface contracts onlyDoenaSoft.AbstractionLayer.IO.Default- DefaultSystem.IO-based implementations (depends on this package)
For production use, reference DoenaSoft.AbstractionLayer.IO.Default. For unit tests, reference only this contracts package.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.7.2
- No dependencies.
-
.NETStandard 2.0
- No dependencies.
-
net10.0
- No dependencies.
NuGet packages (3)
Showing the top 3 NuGet packages that depend on DoenaSoft.AbstractionLayer.IO:
| Package | Downloads |
|---|---|
|
DoenaSoft.AdaptBookFileNames
A .NET library for organizing and standardizing audiobook and e-book file names with consistent naming conventions. Supports MP3, M4A, MP4 audiobooks and EPUB, MOBI e-books with sequential numbering and chapter management. |
|
|
DoenaSoft.AbstractionLayer.IO.Default
Default System.IO-based implementations of the file I/O abstraction interfaces from DoenaSoft.AbstractionLayer.IO. Provides production-ready wrappers for File, Directory, Path, FileInfo, DirectoryInfo, DriveInfo, and FileSystemWatcher with optional logging support. |
|
|
DoenaSoft.DownloadFileRenamer
Lib for handling DownloadRenamer |
GitHub repositories
This package is not used by any popular GitHub repositories.