menu_bookDocumentation

Hotloading: Live Code Reload Without Editor Restart in s&box

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

s&box hotloading recompiles and live-reloads code when you save .cs or .razor files, without restarting the editor.

How It Works

  • IL Hotload (Fast): If only method bodies changed, new instructions are patched in almost instantly without walking the heap. Enabled by default.
  • Full Hotload: If type definitions change, the heap is walked to find and upgrade instances of changed types.

Optimization Tips

Use hotload_log 2 in console for verbose timing. Seal classes to help hotload skip types automatically. Use value-type arrays/lists for fast processing.

Key Pitfalls

Default Field Values

Changing default values of fields won't take effect until editor restart (runtime values are preserved). Use => "value" (expression body) or const for immediate effect:
CSHARP
public static Example1 = "World";               // Still "Hello" after hotload ❌
public static Example3 => "World";              // "World" ✔️
public const Example4 = "World";                // "World" ✔️
[SkipHotload] public static Example5 = "World"; // "World" ✔️

Removing/Renaming Types

References to removed types become null. Components with removed types are automatically cleaned up.

Delegates/Lambdas

Lambda methods may not survive hotload if reordered. Failed delegates log warnings when invoked.

Async/Concurrency

Active worker threads must yield before hotload starts. Write async tasks that yield often.
Was this helpful?