Search Unity

il2cpp Reflection module implementation

Discussion in 'Windows' started by balazs_bencze, Nov 22, 2020.

  1. balazs_bencze

    balazs_bencze

    Joined:
    Oct 9, 2020
    Posts:
    5
    When using il2cpp backend for reflection, it is not possible to get the custom attributes of a MonoModule.
    When inspecting the code, I've found that in il2cpp::vm::Reflection::GetCustomAttrsInfo does not handle modules.
    Is there an ETA for this feature?
     
  2. balazs_bencze

    balazs_bencze

    Joined:
    Oct 9, 2020
    Posts:
    5
    I am talking about the code in the generated output for UwpBuild through IL2CPP
    The file in Il2CppOutputProject\IL2CPP\libil2cpp\vm\Reflection.cpp

    Code (CSharp):
    1.     CustomAttributesCache* Reflection::GetCustomAttrsInfo(Il2CppObject *obj)
    2.     {
    3.         if (IsMethod(obj) || IsCMethod(obj) || IsGenericMethod(obj) || IsGenericCMethod(obj))
    4.             return GetCustomAttributesCacheFor(((Il2CppReflectionMethod*)obj)->method);
    5.  
    6.         if (IsProperty(obj))
    7.             return GetCustomAttributesCacheFor(((Il2CppReflectionProperty*)obj)->property);
    8.  
    9.         if (IsField(obj))
    10.             return GetCustomAttributesCacheFor(((Il2CppReflectionField*)obj)->field);
    11.  
    12.         if (IsEvent(obj))
    13.             return GetCustomAttributesCacheFor(((Il2CppReflectionMonoEvent*)obj)->eventInfo);
    14.  
    15.         if (IsParameter(obj))
    16.             return GetCustomAttributesCacheFor(((Il2CppReflectionParameter*)obj));
    17.  
    18.         if (IsAssembly(obj))
    19.             return GetCustomAttributesCacheFor(((Il2CppReflectionAssembly*)obj)->assembly);
    20.  
    21.         Il2CppClass *klass = IsType(obj)
    22.             ? Class::FromSystemType((Il2CppReflectionType*)obj)
    23.             : obj->klass;
    24.  
    25.         return GetCustomAttributesCacheFor(klass);
    26.     }
    This does not handle Module objects. Because of this, CustomAttributes for modules cannot be loaded. Is there a workaround for this?
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Can you report a bug on this?