TruePath.TestableIO.System.IO
0.11.2
See the version list below for details.
dotnet add package TruePath.TestableIO.System.IO --version 0.11.2
NuGet\Install-Package TruePath.TestableIO.System.IO -Version 0.11.2
<PackageReference Include="TruePath.TestableIO.System.IO" Version="0.11.2" />
<PackageVersion Include="TruePath.TestableIO.System.IO" Version="0.11.2" />
<PackageReference Include="TruePath.TestableIO.System.IO" />
paket add TruePath.TestableIO.System.IO --version 0.11.2
#r "nuget: TruePath.TestableIO.System.IO, 0.11.2"
#:package TruePath.TestableIO.System.IO@0.11.2
#addin nuget:?package=TruePath.TestableIO.System.IO&version=0.11.2
#tool nuget:?package=TruePath.TestableIO.System.IO&version=0.11.2
TruePath.TestableIO.System.IO
Bridges TruePath and TestableIO.System.IO.Abstractions.
This library provides extension methods for TestableIO.System.IO.Abstractions interfaces (like IFile, IDirectory, etc.) that accept AbsolutePath from TruePath instead of raw strings. This combines the strongly-typed path safety of TruePath with the testability of System.IO.Abstractions.
Features
- Strongly-typed Paths: Use
AbsolutePathfor all file system operations. - Testability: Full support for
IFileSystemabstractions, allowing easy mocking in unit tests. - Comprehensive API: Covers
IFile,IDirectory,IFileInfo,IDirectoryInfo, andIDriveInfo. - Modern .NET Support: Targets
net8.0andnet10.0.
Installation
Install the package via NuGet:
dotnet add package TruePath.TestableIO.System.IO
Usage
Basic Example
Instead of using strings, you can use AbsolutePath with your IFileSystem:
using System.IO.Abstractions;
using TruePath;
IFileSystem fileSystem = new FileSystem();
var myPath = new AbsolutePath("/var/log/app.log");
// Extension method on IFile that takes AbsolutePath
fileSystem.File.WriteAllText(myPath, "Hello, TruePath!");
// Where possible there will also be direct extensions methods against an AbsolutePath
// So the above could also be achieved with:
myPath.WriteAllText("Hello");
// This method supports adding the fileSystem so this would also be possible
myPath.WriteAllText("Hello", fileSystem);
// Note that the fileSystem will default to null. In case of nulls a new instance of FileSystem will be created by the method
if (fileSystem.File.Exists(myPath))
{
var content = fileSystem.File.ReadAllText(myPath);
}
Extension example
In the example above. There will be the following extensions methods. Note that this pattern as general rule is followed by other extensions methods.
There are some variations. For instance Exists will be DirectoryExists on the extension of an AbsolutePath
public static void WriteAllText(this IFile file, AbsolutePath path, ReadOnlySpan<char> contents)
{
file.WriteAllText(path.Value, contents);
}
public static void WriteAllText(this AbsolutePath path, ReadOnlySpan<char> contents, FileSystem? fileSystem = null)
{
fileSystem ??= new FileSystem();
fileSystem.File.WriteAllText(path, contents);
}
Working with Directories
var workDir = new AbsolutePath("/tmp/my-work-dir");
fileSystem.Directory.CreateDirectory(workDir);
var files = fileSystem.Directory.GetFiles(workDir);
// Returns AbsolutePath[] instead of string[]
Bugs or things missing
Feel free to create an issue or submit a pull request.
Note on use of AI
AI has been used for generating documentation of code samples and for simple parts of the development.
However the generation of the actual extensions methods has been done by writing and actual tool to cloning https://github.com/Testably/Testably.Abstractions and analysing the code with Roslyn and generating the code. These parts have not been autogenerated by AI.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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. |
-
net10.0
- TestableIO.System.IO.Abstractions.Wrappers (>= 22.1.0)
- Testably.Abstractions.FileSystem.Interface (>= 10.0.0)
- TruePath (>= 1.11.0)
-
net8.0
- TestableIO.System.IO.Abstractions.Wrappers (>= 22.1.0)
- Testably.Abstractions.FileSystem.Interface (>= 10.0.0)
- TruePath (>= 1.11.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TruePath.TestableIO.System.IO:
| Package | Downloads |
|---|---|
|
FileBasedApp.Toolkit
Opiniated helpers for a FileBaseApp. Based on TruePath, SimpleExec and Spectre.Console.Cli |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.15.1 | 38 | 3/15/2026 |
| 0.15.0 | 144 | 3/13/2026 |
| 0.15.0-rc-01 | 80 | 3/12/2026 |
| 0.15.0-dev-03 | 88 | 3/11/2026 |
| 0.15.0-dev-01 | 105 | 3/11/2026 |
| 0.14.0 | 110 | 3/10/2026 |
| 0.14.0-preview-02 | 98 | 3/10/2026 |
| 0.13.0 | 92 | 3/8/2026 |
| 0.12.0 | 104 | 3/7/2026 |
| 0.11.2 | 97 | 3/5/2026 |
Fix summaries