Table of Contents

Interface IRootedFileSystem

Namespace
Invex.FileSystem
Assembly
Invex.FileSystem.dll

Defines a specialised file system abstraction, layering build-aware path resolution on top of the standard System.IO.Abstractions.IFileSystem abstraction.

public interface IRootedFileSystem

Remarks

Path resolution is intentionally separate from file I/O: GetPath(string) queries a prioritized chain of IPathProvider implementations and caches the result. Callers never need to hard-code paths or know which provider resolved a key.

Properties

CurrentDirectory

Gets the current working directory of the application as a RootedPath.

RootedPath CurrentDirectory { get; }

Property Value

RootedPath

Remarks

Evaluated eagerly each time the property is read — it is not cached because the working directory can change during the lifetime of the process.

FileSystem

Gets the underlying System.IO.Abstractions.IFileSystem instance used for all file I/O operations.

IFileSystem FileSystem { get; }

Property Value

IFileSystem

Remarks

All System.IO.Abstractions.IFileSystem members on this interface delegate to this property so that consumers of IRootedFileSystem work against a single, consistent abstraction regardless of which concrete file-system backend is registered.

Methods

CreateRootedPath(string)

Creates a new RootedPath bound to this file system instance from a raw string path.

RootedPath CreateRootedPath(string path)

Parameters

path string

The absolute string path.

Returns

RootedPath

A new RootedPath associated with this file system instance.

Remarks

Prefer this factory method over constructing RootedPath directly so that the resulting path is automatically bound to this IRootedFileSystem rather than to the inner FileSystem.

GetPath(string)

Resolves a well-known path by key, querying the registered IPathProvider chain and caching the result for later calls.

RootedPath GetPath(string key)

Parameters

key string

An application-defined key that identifies the path (e.g. "Root", "Artifacts"). Keys are compared by the individual providers and are conventionally defined as constants.

Returns

RootedPath

A RootedPath corresponding to the key.

Remarks

Providers are queried in order until one returns a non-null result; providers that do not recognise the key are skipped over. When two providers can both resolve the same key, the one with the higher priority wins.

Results are cached after the first successful resolution, so later calls with the same key return the same RootedPath instance without re-querying providers. Providers are queried outside the cache, so concurrent first resolutions of the same key may each call the providers; only the first result is cached and returned to every caller.

Exceptions

InvalidOperationException

Thrown when no registered provider can resolve key, or when the resolution depth exceeds the circular-dependency guard threshold.

GetPath<T>()

Resolves the path for a given IPathMarker type by invoking its static Path(IFileSystem) method directly.

RootedPath GetPath<T>() where T : IPathMarker

Returns

RootedPath

A RootedPath for the specified marker type.

Type Parameters

T

A type that implements IPathMarker.

Remarks

Unlike GetPath(string), this overload bypasses the provider chain and the cache entirely — it calls T.Path(this) on every invocation. Use it for paths that are statically determined by the marker type itself, such as source-generated project paths.