Bitbound.SystemAbstractions
1.0.7
dotnet add package Bitbound.SystemAbstractions --version 1.0.7
NuGet\Install-Package Bitbound.SystemAbstractions -Version 1.0.7
<PackageReference Include="Bitbound.SystemAbstractions" Version="1.0.7" />
<PackageVersion Include="Bitbound.SystemAbstractions" Version="1.0.7" />
<PackageReference Include="Bitbound.SystemAbstractions" />
paket add Bitbound.SystemAbstractions --version 1.0.7
#r "nuget: Bitbound.SystemAbstractions, 1.0.7"
#:package Bitbound.SystemAbstractions@1.0.7
#addin nuget:?package=Bitbound.SystemAbstractions&version=1.0.7
#tool nuget:?package=Bitbound.SystemAbstractions&version=1.0.7
Bitbound.SystemAbstractions
Operating system abstractions for .NET services: file system, processes, system environment, and the Windows registry.
Interfaces are public, implementations are internal, and everything is registered through
ServiceCollectionExtensions.
Quick Start
Install the package.
dotnet add package Bitbound.SystemAbstractions
Register the abstractions on your IServiceCollection.
using Bitbound.SystemAbstractions;
var services = new ServiceCollection();
services.AddSystemAbstractions();
Resolve and use them through the interfaces.
public class BackupService(IFileSystem fileSystem, IProcessManager processes)
{
public async Task RunAsync()
{
if (fileSystem.FileExists("/data/state.json"))
{
var result = await processes.GetProcessOutput("dotnet", "--version");
if (result.IsSuccess)
{
Console.WriteLine("dotnet version: " + result.Value);
}
}
}
}
The companion test package provides in-memory fakes and xUnit helpers.
dotnet add package Bitbound.SystemAbstractions.TestUtilities
using Bitbound.SystemAbstractions.FileSystem;
var fileSystem = new FakeFileSystem();
fileSystem.AddFile("/data/config.json", """{"port": 5000}""");
var services = new ServiceCollection();
services.AddSystemAbstractions();
services.AddSingleton<IFileSystem>(fileSystem);
// Inject into your service and assert against the fakes.
AddSystemAbstractions() registers:
| Service | Registration | Notes |
|---|---|---|
IFileSystem |
AddFileSystem() |
Files, directories, drives, streams, zip extraction, which/where.exe path resolution. |
IFileAccessPermissions |
AddFileSystem() |
Windows ACLs by WellKnownSidType, or UnixFileMode on Linux/macOS. |
IProcessManager |
AddProcesses() |
Start, inspect, and wait on processes. IProcess wraps System.Diagnostics.Process. |
ISystemEnvironment |
AddSystemEnvironment() |
Platform, RID, process id, startup paths, well-known directories. |
IRegistryManager |
AddRegistry() |
Windows only. Throws PlatformNotSupportedException elsewhere, and AddSystemAbstractions() skips it. |
The registry abstractions use their own RegistryHive, RegistryView, and RegistryValueKind enums, so the contracts
are platform-neutral and can be faked on any operating system.
Returning failures instead of throwing
IFileSystem.ResolveFilePath and IProcessManager.GetProcessOutput return Result/Result<T> from
Bitbound.SystemAbstractions.Primitives, which carry IsSuccess, Reason, and the Exception that produced the
failure.
var resolved = await fileSystem.ResolveFilePath("dotnet");
if (!resolved.IsSuccess)
{
logger.LogWarning("dotnet is not on the path: {Reason}", resolved.Reason);
}
Testing
Use the companion Bitbound.SystemAbstractions.TestUtilities
package, which provides FakeFileSystem and FakeRegistry.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.11)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.11)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Bitbound.SystemAbstractions:
| Package | Downloads |
|---|---|
|
Bitbound.SystemAbstractions.TestUtilities
In-memory fakes (file system, Windows registry), platform-specific xUnit facts/theories, and an xUnit-backed ILogger for testing services that depend on Bitbound.SystemAbstractions. |
GitHub repositories
This package is not used by any popular GitHub repositories.