Safety first! Low-level C# without the unsafe keyword
summary
Ports original Doom from C to C# while avoiding the unsafe keyword, reproducing game logic, demo playback, input and rendering and reaching about 80% feature parity with sound added later. Replaces C pointers and void* uses with delegates/lambdas for function hooks, preallocated arrays and careful sizing instead of zone alloc (original used a 6 MB zone). Benchmarks on .NET 6/7/8 with AOT show preallocated arrays ~6.7 µs and lists about ~1 µs slower; Spectre.Console, MAUI and Avalonia front ends work.
AI-written summary · about
chapters (12)
- 0:00Project introduction
- 1:49Developing the port
- 5:07Challenges of C to C#
- 5:55Understanding unsafe code
- 10:49Performance benchmarks
- 13:45Memory management
- 20:40Data structures and arrays
- 26:43Reading binary data
- 35:14Function pointers and lambdas
- 40:35Game thinkers and logic
- 46:00Console rendering
- 48:18Conclusion and Q&A








