add_internal_call!() { /* proc-macro */ }
Expand description

Macro equivalent of mono_add_internal_call with automatic support for type conversion. Allows you to expose a function as an internal call

Parameters

NameTypePurpose
function_pathstring literal(“”)Path to managed function to replace with internal call. Example: “NAMESPCE.CLASS::Method”. Managed method to replace must have [MethodImpl(MehodImplOption.InternalCall)] atribute
functionrust functionRust function with invokable macro. Must match signature of managed function, otherwise undefined beahviour may occcur.

Example

CSharp

using System.CompilerServices;
namespace SomeNamespace{
    class SomeClass{
        [MethodImpl(MehodImplOption.InternalCall)]
        void DoSomething(String arg1);
    }
}

Rust

#[invokable]
fn do_something(input:String){
    println!("done something:{}",input);  
}
fn expose_do_something(){
    add_internal_call!("SomeNamespace.SomeClass::DoSomething()")   
}