wrapped_mono 0.2 - run C#/F# code inside your Rust projects!

41 points FractalFir

What is wrapped_mono

wrapped\_mono is a safe lightweight wrapper around the mono library. It allows easy embedding of the mono runtime, and interop with code run inside it. This allows:

  • Using C#/F# libraries from rust code
  • Using C#/F# as scripting language inside a larger project, for example a game, or an game engine.

What is new?

  • Following suggestions the method type representing a C#/F# function has been reworked. Methods with different arguments are now represented as different types using generic arguments, and their signatures are checked, to ensure that the C#/F# function they represent matches the rust counterpart. The checks still are not perfect and can not trigger under very specific circumstances, but accidental signature mismatch is less likely.
  • Safe method invocation API - arguments are automatically converted when invoking methods.
  • Delegates are now supported - their signatures are now checked, the same way function signatures are checked.
  • InteropRecive and InteropSend traits can now be derived - allowing easy passing back and forth simple enums and struct made from types that can be passed themselves.
  • Multi-dimensional arrays are now fully supported and can be indexed into using multi-dimensional indices. Indices are checked to ensure they are within bounds.
  • Full windows support - wrapped_mono builds successfully on windows 10
  • New ReflectionType type representing System.Type
  • Changed large portion of the backed to use GCHandles(references) instead of raw pointers to prevent objects in use by Rust to be deleted by Garbage Collector. This decreased performance slightly(in very extreme circumstances(calling a function non stop) 10-30%), but prevents many bugs from occurring. This feature can be disabled, and GCHandles can be used manually, to gain even more performance at cost of safety and convince.
  • Changed large portion of the code base to use special functions to inform the garbage collector about critical operations that it should not interrupt, eliminating even more bugs.
  • crates.io release

What is WIP

Certain APIs are partially finished and can be used, but the are not tested as well as other features and are not fully completed

  • Reading assembly metadata - fully operational, but not fully safe.
  • Profiler API - works without issues but only supports some events

crates.io

github