public sealed class DevelopmentDirectoryAssetSource : IAssetSource, IAssetSourceChangeNotifier, IDisposable Exposes a refreshable local development directory, such as a frontend's build output. Every refresh publishes an immutable manifest, every file is served with AssetCacheMode.NoStore, and reads are verified against the manifest digest.
Remarks
No path component below the root may be a symbolic link or reparse point. On Linux and macOS the source pins the root with one no-follow directory handle and opens every file relative to it, so replacing the root or an ancestor directory cannot redirect a published source. Windows checks each component for a reparse point before it opens a file, but does not pin the root: a directory moved into the root's place is read from then on.
Call DevelopmentDirectoryAssetSource.StartWatching once to refresh after file changes, and dispose the source to stop.
Constructors
DevelopmentDirectoryAssetSource
public DevelopmentDirectoryAssetSource(string rootDirectory, string entryPointRelativePath) Scans a local development directory and creates its first manifest snapshot.
Parameters
rootDirectoryThe directory, absolute or relative to the current directory.
entryPointRelativePathThe entry document, relative to
rootDirectory, such asindex.html.
Exceptions
InvalidDataExceptionThe directory contains a symbolic link or reparse point.
ArgumentExceptionThe directory does not contain the entry point.
PlatformNotSupportedExceptionThe operating system is not Linux, Windows or macOS.
Properties
Manifest
public AssetManifest Manifest { get; } Gets the current immutable manifest with identity, digest, and cache metadata.
Documentation from IAssetSource.Manifest.
SkippedEntries
public IReadOnlyList<string> SkippedEntries { get; } Gets the directory entries the latest scan skipped because their names are not valid asset paths, such as names containing :, ?, #, a backslash, or a percent-encoded octet.
Methods
Dispose
public void Dispose() Stops the watch, future refreshes and notification admission; it is the only way to stop watching. A refresh in progress finishes first. Queued notifications are discarded and every external or repeated disposal call waits until callbacks admitted before disposal have finished. Disposal called by the active callback returns without waiting for itself; a later external disposal still waits for that callback. Subscriber exceptions are isolated and never affect a published refresh. Notifications are delivered in refresh order by one dispatcher; handlers may unsubscribe or refresh reentrantly, and changes queued by reentrancy run afterward.
OpenAsync
public ValueTask<AssetReadSnapshot> OpenAsync(string relativePath, CancellationToken cancellationToken = default) Opens one exact manifest asset with its matching immutable descriptor.
Exceptions
FileNotFoundExceptionThe manifest does not declare
relativePath.
Remarks
The caller owns the snapshot and disposes it, which disposes its content stream.
Documentation from IAssetSource.OpenAsync.
RefreshAsync
public ValueTask<AssetManifest> RefreshAsync(CancellationToken cancellationToken = default) Scans the directory again and atomically replaces the manifest when its assets changed, then raises DevelopmentDirectoryAssetSource.Changed. Refreshes run one at a time.
Returns
The current manifest: the replacement, or the previous one when nothing changed.
Exceptions
ArgumentExceptionThe directory no longer contains the entry point.
InvalidDataExceptionThe directory contains a symbolic link or reparse point.
ObjectDisposedExceptionThe source is disposed.
StartWatching
public void StartWatching(AssetWatchOptions? options = null) Starts the source's filesystem watcher. File changes are coalesced into one refresh after the configured quiet period, and each replacement manifest is published through DevelopmentDirectoryAssetSource.Changed. Subscribe before calling it. The watch runs until the source is disposed.
Parameters
optionsThe debounce and retry bounds;
nulluses the defaults.
Exceptions
InvalidOperationExceptionThe source is already watching.
ObjectDisposedExceptionThe source is disposed.
ValidateAsync
public ValueTask ValidateAsync(CancellationToken cancellationToken = default) Validates metadata and backing content.
Documentation from IAssetSource.ValidateAsync.
Events
Changed
public event EventHandler<AssetSourceChangedEventArgs>? Changed Raised after the source atomically publishes a validated replacement manifest. Publishers invoke handlers outside their refresh lock and isolate subscriber failures.
Documentation from IAssetSourceChangeNotifier.Changed.