TruePath.TestableIO.System.IO
0.15.1
dotnet add package TruePath.TestableIO.System.IO --version 0.15.1
NuGet\Install-Package TruePath.TestableIO.System.IO -Version 0.15.1
<PackageReference Include="TruePath.TestableIO.System.IO" Version="0.15.1" />
<PackageVersion Include="TruePath.TestableIO.System.IO" Version="0.15.1" />
<PackageReference Include="TruePath.TestableIO.System.IO" />
paket add TruePath.TestableIO.System.IO --version 0.15.1
#r "nuget: TruePath.TestableIO.System.IO, 0.15.1"
#:package TruePath.TestableIO.System.IO@0.15.1
#addin nuget:?package=TruePath.TestableIO.System.IO&version=0.15.1
#tool nuget:?package=TruePath.TestableIO.System.IO&version=0.15.1
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
Instead of using strings, you can use AbsolutePath with your IFileSystem:
For relevant interfaces of the IFileSystem abstraction it will provide extension methods and if possible also provide a convinience method directly on AbsolutePath that allows for a direct way to call it with an optional IFileSystem (if null the default IFileSystem will be used new FileSystem() ).
For instance IFile.WriteAllText will be available as FileIO.WriteAllText(...)
For these there will also be a direct method available on AbsolutePath that allows for a direct way to call it. Note that this will live in the TruePath.TestableIO.System.IO namespace and not System.IO.Abstractions
Note that in some cases. For instance the Create method that is available for both IFile and IDirectory the direct method call will be FileCreate and DirectoryCreate
Example
For instance SetLastWriteTime on IFile is available as
FileSetLastWriteTime(this AbsolutePath path, DateTime lastWriteTime, IFileSystem? fileSystem = null)
and
SetLastWriteTime(this IFile file, AbsolutePath path, DateTime lastWriteTime)
It will also be available with ad call to
FileIO.SetLastWriteTime(AbsolutePath.Create(...), .., ...)
Installation
Install the package via NuGet:
dotnet add package TruePath.TestableIO.System.IO
Usage
Basic Example
using System.IO.Abstractions;
using TruePath;
var fileSystem = new FileSystem();
var myPath = new AbsolutePath("/var/log/app.log");
fileSystem.File.WriteAllText(myPath, "Hello, world!");
myPath.WriteAllText("Hello world", fileSystem);
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, IFileSystem? fileSystem = null)
{
fileSystem ??= new FileSystem();
fileSystem.File.WriteAllText(path, contents);
}
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.12.0)
-
net8.0
- TestableIO.System.IO.Abstractions.Wrappers (>= 22.1.0)
- Testably.Abstractions.FileSystem.Interface (>= 10.0.0)
- TruePath (>= 1.12.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 | 30 | 3/15/2026 |
| 0.15.0 | 127 | 3/13/2026 |
| 0.15.0-rc-01 | 75 | 3/12/2026 |
| 0.15.0-dev-03 | 80 | 3/11/2026 |
| 0.15.0-dev-01 | 96 | 3/11/2026 |
| 0.14.0 | 101 | 3/10/2026 |
| 0.14.0-preview-02 | 89 | 3/10/2026 |
| 0.13.0 | 91 | 3/8/2026 |
| 0.12.0 | 104 | 3/7/2026 |
| 0.11.2 | 97 | 3/5/2026 |
- Updated TruePath dependency to 1.12.0
- No longer syncing versions with FileBasedApp.Toolkit