Nullean.Entities.FileSystem 0.1.0-preview.1

This is a prerelease version of Nullean.Entities.FileSystem.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Nullean.Entities.FileSystem --version 0.1.0-preview.1
                    
NuGet\Install-Package Nullean.Entities.FileSystem -Version 0.1.0-preview.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Nullean.Entities.FileSystem" Version="0.1.0-preview.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Nullean.Entities.FileSystem" Version="0.1.0-preview.1" />
                    
Directory.Packages.props
<PackageReference Include="Nullean.Entities.FileSystem" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Nullean.Entities.FileSystem --version 0.1.0-preview.1
                    
#r "nuget: Nullean.Entities.FileSystem, 0.1.0-preview.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Nullean.Entities.FileSystem@0.1.0-preview.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Nullean.Entities.FileSystem&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Nullean.Entities.FileSystem&version=0.1.0-preview.1&prerelease
                    
Install as a Cake Tool

Nullean.Entities.FileSystem

Constraint shapes for files and directories, over the System.IO.Abstractions types a domain model already holds (IFileInfo, IDirectoryInfo).

[Constraints]
public static partial class DocsetConstraints
{
    public static readonly Constraint<Docset> ImagesExist       = Files<Docset>.Exist(d => d.Images);
    public static readonly Constraint<Docset> ImagesStayInRoot  = Files<Docset>.StayInside(d => d.Root, d => d.Images);
    public static readonly Constraint<Docset> NoSymlinks        = Files<Docset>.NotSymlink(d => d.Images, d => d.Root);
    public static readonly Constraint<Docset> NoHiddenFolders   = Files<Docset>.NoHiddenSegments(d => d.Root, d => d.Images);
    public static readonly Constraint<Docset> PictureExtensions = Files<Docset>.HaveExtension(d => d.Images, [".png", ".svg"]);
}
Shape Violated when
Exist, DirectoriesExist a file or directory is missing (evidence: its full path)
StayInside(root, paths) a path, once .. is resolved, is not inside the root. A sibling that shares a prefix (/docs-other against /docs) is outside
NotSymlink(paths, root?) a path is a symbolic link, or sits below one (checked up to the root)
NoHiddenSegments(root, paths) a directory between the root and the path starts with a dot
HaveExtension(paths, extensions) the extension is not one of the list, ignoring case
NotEmpty(files), MaxSize(files, bytes) an existing file has no content, or is larger than the limit (a missing file is Exist's to report)
UniqueIgnoringCase(paths) two paths differ only in case: two files on Linux, one on macOS and Windows

Each takes message: (one text for every finding), describe: (a text per path) and at: (a SourceLocation for the item, so a finding can point at the YAML line), and reports the selected member as Violation.Member. Use .WithSeverity(Severity.Warning) for a rule that is not an error yet.

When the model's items are not files (a table-of-contents entry, a redirect target), Exist and DirectoriesExist take the items and a function that resolves each to the file it names; describe and at then speak about the item:

Files<Docset>.DirectoriesExist(
    d => d.Folders,                                   // the entries
    (d, f) => d.FileSystem.DirectoryInfo.New(Path.Join(d.Root.FullName, f.Path)),
    describe: f => $"Folder '{f.Path}' does not exist.",
    at: f => new SourceLocation(f.File, f.Line, f.Column, f.Path.Length));

FilePaths is the path arithmetic the shapes use, public for a rule that needs the answer inside a larger check: IsInside(root, path, comparison), SymlinkAt, HiddenSegment, and UnsafeToRead(path, root), the reason a path may not be read as content (a link, or a hidden directory, on the way) or null. A chain that stops at the first problem (right extension, inside the root, safe to read, exists) keeps its own wording and asks FilePaths instead of re-deriving the rules. The rules read the file system the path came from (IFileSystemInfo.FileSystem), so a test that builds the model on a MockFileSystem checks the very code that runs against the disk. A path the file system refuses is reported as a violation of that rule, not thrown.

The package is trim and AOT clean: ./build.sh aot publishes an app using these rules NativeAOT. To get counter-examples for them with no hand-written file system, see Nullean.Entities.CsCheck.FileSystem.

Product 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.  net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Nullean.Entities.FileSystem:

Package Downloads
Nullean.Entities.CsCheck.FileSystem

Generated file-system worlds for Nullean.Entities.CsCheck: AutoGen builds IFileSystem, IFileInfo and IDirectoryInfo members from one MockFileSystem per generated value, with missing, symlinked, hidden and outside-the-root files, so rules about files get counter-examples with no hand-written file system.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 55 10/20/2026
0.1.0 111 10/20/2026
0.1.0-preview.2 58 10/20/2026
0.1.0-preview.1 55 10/20/2026