Last active
September 25, 2019 11:55
-
-
Save Sergio0694/cd3a342a2ce3db122c4f652f9ad93619 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static unsafe (object[] References, byte[] Bytes) GetData( | |
Delegate instance, DataLoader loader, | |
int referenceCount, int byteSize) | |
{ | |
// Reference and byte array | |
object[] refs = ArrayPool<object>.Shared.Rent(referenceCount); | |
byte[] bytes = ArrayPool<byte>.Shared.Rent(byteSize); | |
ref object r0 = ref refs.Length > 0 ? ref refs[0] : ref Unsafe.AsRef<object>(null); | |
ref byte r1 = ref bytes.Length > 0 ? ref bytes[0] : ref Unsafe.AsRef<byte>(null); | |
// Invoke the dynamic method to extract the captured data | |
loader(instance.Target, ref r0, ref r1); | |
return (refs, bytes); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment