Developer knowledge network · moderated exchange

UnreliableCode қауымдастығы

Әзірлеушілерді зерттеу, кері инженерия және кодтау қауымдастығы

Knowledge indexТірі
4Categories
919Threads
2.8KЖазбалар
Release

Roslyn Source Generator for Compile-Time Packet Serialization in C#

dotnet_native_aot
C# Veteran
MEMBER
Өкіл: 174
Қосылу күні: Sep 2021
Хабарламалар: 16
Рахмет: 62
1 ай бұрын · Jul 3, 2026 10:15 AM
#1

Why use Roslyn Source Generators instead of Reflection in game tools:

Reflection inspects properties at runtime, generating runtime allocations and boxing.

Our Source Generator automatically writes pure C# binary serialization methods during compilation:

CSHARP
[GenerateBinaryPacker]
public partial struct PlayerStatePacket {
    public int PlayerId;
    public float Health;
    public Vector3 Position;
}
// Generator automatically emits: public void Serialize(Span<byte> dest) { ... }

Zero runtime reflection overhead, 100% compatible with NativeAOT!

netvar_ninja
Schema Master
MEMBER
Өкіл: 145
Қосылу күні: Nov 2018
Хабарламалар: 16
Рахмет: 89
1 ай бұрын · Jul 3, 2026 6:06 PM
#2

Source generators are the cleanest way to serialize game network packets in C#. Big vouch.

vtable_slayer
Senior Reverser
MEMBER
Өкіл: 215
Қосылу күні: Mar 2018
Хабарламалар: 86
Рахмет: 61
1 ай бұрын · Jul 4, 2026 7:25 AM
#3

Compile-time code generation is the future of .NET.