![]() |
VOOZH | about |
dotnet add package TruePath.TestableIO.System.IO --version 0.16.1
NuGet\Install-Package TruePath.TestableIO.System.IO -Version 0.16.1
<PackageReference Include="TruePath.TestableIO.System.IO" Version="0.16.1" />
<PackageVersion Include="TruePath.TestableIO.System.IO" Version="0.16.1" />Directory.Packages.props
<PackageReference Include="TruePath.TestableIO.System.IO" />Project file
paket add TruePath.TestableIO.System.IO --version 0.16.1
#r "nuget: TruePath.TestableIO.System.IO, 0.16.1"
#:package TruePath.TestableIO.System.IO@0.16.1
#addin nuget:?package=TruePath.TestableIO.System.IO&version=0.16.1Install as a Cake Addin
#tool nuget:?package=TruePath.TestableIO.System.IO&version=0.16.1Install as a Cake Tool
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.
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
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(...), .., ...)
Install the package via NuGet:
dotnet add package TruePath.TestableIO.System.IO
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);
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);
}
Feel free to create an issue or submit a pull request.
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 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
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 |
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.16.1 | 120 | 4/22/2026 |
| 0.16.0 | 524 | 3/29/2026 |
| 0.15.1 | 158 | 3/15/2026 |
| 0.15.0 | 253 | 3/13/2026 |
| 0.15.0-rc-01 | 147 | 3/12/2026 |
| 0.15.0-dev-03 | 137 | 3/11/2026 |
| 0.15.0-dev-01 | 142 | 3/11/2026 |
| 0.14.0 | 143 | 3/10/2026 |
| 0.14.0-preview-02 | 121 | 3/10/2026 |
| 0.13.0 | 123 | 3/8/2026 |
| 0.12.0 | 134 | 3/7/2026 |
| 0.11.2 | 121 | 3/5/2026 |
- Added FileMove, FileCopy, and FileReplace extension methods on AbsolutePath for file operations via IFileSystem
- Added Move, Copy extension methods on IFile for AbsolutePath-based file operations
- Added DirectoryMove extension method on AbsolutePath for directory move operations via IFileSystem
- Added Move extension method on IDirectory for AbsolutePath-based directory move
- Added MoveTo extension method on IDirectoryInfo for AbsolutePath-based directory move
- Added CopyTo, MoveTo, and Replace extension methods on IFileInfo for AbsolutePath overloads