This instruction is commonly emitted for using blocks/statements. It precedes a callvirt instruction and affects how the instance for that call is loaded. In Roslyn-compiled code, it is also used for static abstract/virtual, but I don't think Unity supports that.
To ensure that the instance calling the method can be modified (and not just a copy), we need to wrap the call with these two helpers:
public static object? ConstrainedStart<T>(ByReference<T> reference) where T : IIl2CppType<T>
{
var value = reference.GetValue();
return value?.Box();
}
public static void ConstrainedFinish<T>(ByReference<T> reference, object? boxedObject) where T : IIl2CppType<T>
{
var value = T.Unbox(boxedObject);
reference.SetValue(value);
}
This instruction is commonly emitted for
usingblocks/statements. It precedes acallvirtinstruction and affects how the instance for that call is loaded. In Roslyn-compiled code, it is also used for static abstract/virtual, but I don't think Unity supports that.To ensure that the instance calling the method can be modified (and not just a copy), we need to wrap the call with these two helpers: