Skip to content

Ceilidh-Team/NativeTK

Repository files navigation

NativeTK

NativeTK is a toolkit for cross-platform native bindings in .NET.

To learn how to use NativeTK, check out the example binding here.

Benefits

  • Cross-platform: NativeTK can locate a native library using a variety of common naming schemes for each platform, and even bind specific versions of a library.
  • Lightweight: NativeTK generates high-performance bindings using Mono.Cecil.
    • NativeTK offers both standard PInvokeImpl-based interop (the same as generated by C# when using [DllImport]) and CallIndirect-based interop, which can be faster but lacks marshaling options.
  • Static variables: NativeTK can generate references to static variables inside libraries, which is not possible with standard P/Invoke.
  • Familiar syntax: NativeTK mimics the syntax of traditional P/Invoke-based native interop, so there's no steep learning curve.
    • Support for common attributes like [MarshalAs] and [SuppressUnmanagedCodeSecurity] enables fluid and complete control over the generated bindings.

Downsides

  • Interface performance: Because NativeTK uses interfaces for abstraction, there's a slight performance cost on each call when compared with static P/Invoke methods.
    • If performance is a major concern for you, check out the benchmarks here.