Repository navigation
Testing and Docs
Ferrous brings Rust's testing and documentation workflow (trybuild, cargo test --doc, cargo doc, and cargo new) to .NET.
Install in your test project:
dotnet add package Ferrous.TestingVerify that invalid usages of [Typestate], [Consuming], [BorrowMut], [NoDefault], or [Closed] fail compilation with specific FE* diagnostics:
using Ferrous.Testing;
CompileAssert.Fails("""
using Ferrous;
public static class Demo
{
public static void Take([Consuming] string s) { }
public static void Run()
{
var buf = "payload";
Take(buf);
_ = buf.Length;
}
}
""", "FE0200");Works with xUnit, NUnit, MSTest, and TUnit:
int port = ParsePort("8080").AssertOk();
string err = ParsePort("abc").AssertErr();
string name = FindUser(1).AssertSome();
FindUser(999).AssertNone();Unit-test companion to [NoAlloc]:
int sum = AllocAssert.Zero(static () => Result.Ok<int, string>(41).Map(static x => x + 1).UnwrapOr(0));Run all /// <example><code> XML doc blocks and fenced ```csharp Markdown snippets:
dotnet fe doctest ./src
dotnet fe test .Supported directives: no_run, ignore, compile_fail, and compile_fail(FE0200).
Generate a searchable static HTML API docs site with Roslyn syntax highlighting, full XML docs (exceptions, params, returns, examples), cross-page <see cref> links, <inheritdoc /> expansion, [DiscriminatedUnion] variant tables, [Newtype] wrapper cards, and embedded Mermaid [Typestate] graphs (see Typestate Protocol for a rendered diagram example):
dotnet fe doc ./src --output ./docs-site --title "My API Reference" --logo ./assets/icon.png --openFor a live site generated by dotnet fe doc, browse Ferrous's own API Reference.
# Audit lockfiles, SemVer validation, NativeAOT readiness, and NuGet CVEs
dotnet fe audit . --packages --allow-licenses MIT --lockfile --semver --aot --cve
# Scaffold a new strict Ferrous project
dotnet new install Ferrous.Templates
dotnet new ferrous -n MyAppZero-dependency, proptest-style property testing with deterministic replay seeds and automatic counterexample shrinking:
using Ferrous.Testing;
PropAssert.ForAll(
Gen.NonEmptyString(maxLength: 32),
s => !string.IsNullOrWhiteSpace(s.Value) && s.Length >= 1,
iterations: 200,
seed: 42);
PropAssert.ForAll(
Gen.Int(-1000, 1000),
Gen.Int(-1000, 1000),
(a, b) => a + b == b + a);Built-in generators include Gen.Int, Gen.Long, Gen.Bool, Gen.Double, Gen.Decimal, Gen.Guid, Gen.DateTimeOffset, Gen.String, Gen.NonEmptyString, Gen.NonZeroInt, Gen.Option, Gen.Result, Gen.OneOf, Gen.OneOfGen, Gen.Newtype, Gen.List, plus .Select(...) and .Where(...) combinators. Both sync (PropAssert.ForAll, up to 3 arguments) and async (PropAssert.ForAllAsync) properties are supported, with automatic counterexample shrinking and exact seed reporting in FerrousAssertionException.
Ferrous — Rust quality-of-life primitives, source generators, and analyzers for .NET (.NET 10 / .NET 11, NativeAOT-ready, MIT License).