Skip to content

Getting Started

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

Getting Started

Running a Simulation

Create a SimWorld with a fixed ulong seed and run your async scenario inside world.Run(...):

using Faultline;

var world = new SimWorld(new SimWorldOptions
{
    Seed = 42,
    StartTime = new DateTimeOffset(2026, 1, 1, 0, 0, 0, TimeSpan.Zero),
});

world.Run(async sim =>
{
    sim.AddHost("node-a", async host =>
    {
        await host.DelayAsync(TimeSpan.FromSeconds(5));
        // host.Clock.UtcNow is 2026-01-01T00:00:05Z
    });

    await sim.DelayAsync(TimeSpan.FromSeconds(10));
});

Transparent IL Rewriting

To run unmodified production code (using DateTime.UtcNow, Task.Delay, Task.Run, Random.Shared, new Random(), Guid.NewGuid()) without referencing Faultline in your production project:

  1. Keep your production project completely free of Faultline references.
  2. In your test project, import build/Faultline.targets and list the target assemblies:
<PropertyGroup>
  <FaultlineRewriteAssemblies>MyProductionAssembly</FaultlineRewriteAssemblies>
</PropertyGroup>

<Import Project="..\..\build\Faultline.targets" />

On build, Faultline.Rewriter instruments MyProductionAssembly.dll in the test output directory. Outside a SimWorld, every rewritten call transparently passes through to the real .NET BCL.

Clone this wiki locally