-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hello, I was wondering of an easier method to execute Rust code (unmanaged) from C# (managed). I already know of the return-string-from-managed example and was able to easily get it working, but it required a field and two methods to be created for a single unmanaged method:
// Required since only unsafe code can use function pointers.
private static unsafe void DoRustyThings() {
DoRustyThingsPtr();
}
private static unsafe delegate*<void> DoRustyThingsPtr;
[UnmanagedCallersOnly]
public static unsafe void SetDoRustyThingsPtr(delegate*<void> doRustyThingsPtr) => DoRustyThingsPtr = doRustyThingsPtr;
Mono has a really simple way to call managed code from unmanaged code by adding an attribute:
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public static void DoRustyThings();
Is there anyway that running managed code from unmanaged code could become easier and lead to less boilerplate? If its not implemented just yet, I may be able to mess around with implementing it and make a PR, or just hack something up to get it working for me. Thanks!
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request