I have a problem with IL2CPP enum marshalling and am trying to figure out if it is me or a bug.
If the code code has UInt32 as a parameter type:
[PreserveSig]
[return: MarshalAs(UnmanagedType.I4)]
Int32 get_Capacity(
[param: MarshalAs(UnmanagedType.U4), Out] out UInt32 value);
then IL2CPP is producing correct code:
virtual int32_t STDCALL IBuffer_get_Capacity_m1125DCD817D998EEA9C3AB757282C36DDEFF2C1A(uint32_t* ___value0) = 0;
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR int32_t IBuffer_get_Capacity_m1125DCD817D998EEA9C3AB757282C36DDEFF2C1A (RuntimeObject* __this, uint32_t* ___value0, const RuntimeMethod* method)
IBuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0* ____ibuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0 = il2cpp_codegen_com_query_interface<IBuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0>(static_cast<Il2CppComObject*>(__this));
// Native function invocation
int32_t returnValue = 0;
returnValue = ____ibuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0->IBuffer_get_Capacity_m1125DCD817D998EEA9C3AB757282C36DDEFF2C1A(___value0);
return returnValue;
But if code defines enum type with underlying type used being UInt32:
public enum TrustLevel : uint
BaseTrust,
PartialTrust = BaseTrust + 1,
FullTrust = PartialTrust + 1
[PreserveSig]
[return: MarshalAs(UnmanagedType.I4)]
Int32 GetTrustLevel(
[param: MarshalAs(UnmanagedType.U4), Out] out TrustLevel trust);
Then IL2CPP code produces broken code by generating parameter passed by value in one place and by reference in the other:
virtual int32_t STDCALL IBuffer_GetTrustLevel_mBF734F53DB93868AEA6A12C281E5CCED468E3931(uint32_t ___trust0) = 0;
IL2CPP_EXTERN_C IL2CPP_METHOD_ATTR int32_t IBuffer_GetTrustLevel_mBF734F53DB93868AEA6A12C281E5CCED468E3931 (RuntimeObject* __this, uint32_t* ___trust0, const RuntimeMethod* method)
IBuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0* ____ibuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0 = il2cpp_codegen_com_query_interface<IBuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0>(static_cast<Il2CppComObject*>(__this));
// Native function invocation
int32_t returnValue = 0;
returnValue = ____ibuffer_t4B85BAC23AA3CDCD603B4CB0E3C98BCA8A4AADA0->IBuffer_GetTrustLevel_mBF734F53DB93868AEA6A12C281E5CCED468E3931(___trust0);
return returnValue;
obviously causing a compiler error:
cannot convert argument 1 from ‘uint32_t *’ to ‘uint32_t’
So, am I doing something wrong here?
Thanks.
I am not trying to redeclare anything. This is a third party to me C# library for Bluetooth LE, where the author has added things missing from WinRT, and I assume had to implement some things as well.
Also, even though it seems bizarre that this is a C# library with managed/unmanaged interface and I am now trying to push it all back to unmanaged land, I just need an ability of our product to both function built in Mono and C++.
I would love for all of it to run in C++ and be done with Mono, but then Unity needs to implement IL2CPP support for things on Windows they currently decided not to support, like WCF.
I’m not sure whether it has any influence on QA side of things (i.e. initial verification/reproduction), but on the dev side of things we don’t really look at license type when fixing bugs or prioritizing them. That said, we take bugs like these that completely prevent you from working (due to compilation errors in this case) pretty seriously and try to address them quickly.
OK, your bug status status wonder doesn’t know me no matter how hard I try. I mean
https://unity3d.atlassian.net/
…
So, how do I know the ETA of the fix? Your issue tracker is useless, it wants me to vote for a fix. Do I need to get all my people to vote to get it fixed?
borodai:
OK, your bug status status wonder doesn’t know me no matter how hard I try. I mean
https://unity3d.atlassian.net/
…
So, how do I know the ETA of the fix? Your issue tracker is useless, it wants me to vote for a fix. Do I need to get all my people to vote to get it fixed?
Do you have a bug number I can look up?