What is Beyond.NET and how does it work?
mainBeyond.NET is a toolset that enables calling .NET code from other programming languages (currently supporting C and Swift).
How it works
- Reflection & Wrapper Generation: The Beyond.NET code generator loads a compiled .NET assembly, reflects over its types, and generates wrapper functions for all public APIs. These wrappers are decorated with the
UnmanagedCallersOnlyattribute, making them callable from native code. - Binding Generation: The generator creates language-specific bindings (starting from C bindings) for the generated wrappers.
- Native Compilation: The generated C# code is compiled using .NET NativeAOT, allowing the resulting library to be consumed via the generated language bindings.
Call Tree Example (Swift):
Swift $\rightarrow$ C $\rightarrow$ .NET APIs (UnmanagedCallersOnly) $\rightarrow$ Original .NET API