Skip to content

ppn-systems/protogen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚡ Nalix Protogen

GitHub repository .NET 10.0 License

A high-performance, Roslyn-powered code generation utility that compiles C# packet definitions into wire-compatible C and Rust bindings. Ensures identical byte layout, alignment, and serialization order across platforms.


🗺️ Documentation Index

To keep this project maintainable as we support additional target languages, detailed specifications are split into dedicated guides:


✨ Key Features

  • Roslyn-Powered Parser: Uses MSBuildWorkspace to parse .csproj source trees or reflection to read compiled assemblies (.dll).
  • Multi-Language Bindings: Generates fully-typed native C structs (with MSVC pack pragmas) and safe Rust structs.
  • Automatic Size Verification: Builds round-trip test suites (packet_test.c and packet_tests.rs) to prove serialization/deserialization logic is identical across target languages.

🛠️ Installation

Build the self-contained compiler binary from the repository root:

dotnet publish src/Nalix.Protogen.Cli -c Release -o ./bin

The output compiles to a self-contained protogen executable in the ./bin directory.


💻 CLI Usage

# General CLI Command Syntax
protogen --project <path-to-csproj> --c-out <dir> [--rust-out <dir>] [options]
protogen --assembly <path-to-dll> --c-out <dir> [--rust-out <dir>] [options]

Options & Flags

Flag Long Flag Description
-p --project Path to the C# .csproj containing packet definitions.
-a --assembly Path to the compiled C# .dll containing packet definitions.
--c-out Output directory for C files (packets.h, packets.c, packet_test.c).
--rust-out Output directory for Rust files (packets.rs, packets_tests.rs).
-v --verbose Enable verbose logging for MSBuild warnings.

Practical Examples

# Generate C and Rust bindings from a csproj source
protogen -p ../Nalix.Codec/Nalix.Codec.csproj --c-out ./gen/c --rust-out ./gen/rs

# Generate C-only bindings from a compiled DLL assembly
protogen -a ../Nalix.Codec/bin/Release/net10.0/Nalix.Codec.dll --c-out ./gen/c

📐 Project Architecture

Nalix.Protogen.Abstractions   # Shared models, interfaces, and options contracts.
Nalix.Protogen.Roslyn         # MSBuild and Roslyn workspace packet code parser.
Nalix.Protogen.Cli            # Console Application entry point (protogen).

⚖️ License

Apache License 2.0. See LICENSE for details.

About

Roslyn-based code generator that produces wire-compatible C and Rust packet bindings from C# definitions.

Topics

Resources

Stars

Watchers

Forks

Contributors