Repository navigation
IL Rewriter
github-actions[bot] edited this page Dec 2, 2026
·
2 revisions
Faultline.Rewriter uses AsmResolver.DotNet to instrument compiled assemblies post-build in your test output directory.
| Original BCL API | Faultline Hook |
|---|---|
DateTime.UtcNow, DateTime.Now, DateTime.Today
|
SimTimeHooks.GetUtcNow() / GetNow() / GetToday()
|
DateTimeOffset.UtcNow, DateTimeOffset.Now
|
SimTimeHooks.GetDateTimeOffsetUtcNow() / GetDateTimeOffsetNow()
|
Stopwatch.GetTimestamp(), Environment.TickCount64, Environment.TickCount
|
SimTimeHooks.GetTimestamp() / GetTickCount64() / GetTickCount()
|
TimeProvider.System |
SimTimeHooks.GetSystemTimeProvider() |
new PeriodicTimer(TimeSpan) |
SimTimeHooks.CreatePeriodicTimer(TimeSpan) |
Task.Delay(...) (all overloads) |
SimTimeHooks.Delay(...) |
new CancellationTokenSource(TimeSpan / int), CancelAfter(...)
|
SimTimeHooks.CreateCancellationTokenSource(...) / CancelAfter(...)
|
Task.Run(...) (sync, async, generic Task.Run<T>) |
SimSchedulerHooks.Run(...) |
ThreadPool.QueueUserWorkItem(...) |
SimSchedulerHooks.QueueUserWorkItem(...) |
Random.Shared |
SimRandomHooks.GetSharedRandom() (AmbientSimRandom) |
new Random() (parameterless) |
SimRandomHooks.CreateRandom() (BoundSimRandom) |
Guid.NewGuid(), Guid.CreateVersion7(...)
|
SimRandomHooks.NewGuid() / CreateVersion7(...)
|
RandomNumberGenerator.Fill, RandomNumberGenerator.GetBytes
|
SimRandomHooks.FillCryptoBytes / GetCryptoBytes
|
new HttpClient(), new SocketsHttpHandler()
|
SimNetworkHooks.CreateHttpClient() / CreateSocketsHttpHandler()
|
- Rewritten assemblies are stamped with
[assembly: FaultlineRewrittenAttribute]. Subsequent incremental builds automatically skip already-rewritten DLLs. - Every hook checks
SimContext.IsSimulating. When running outside aSimWorld(e.g., regular unit tests in the same test assembly), calls fall through to the real BCL with a single null check.