Avoid pre-allocating custom attributes for managed types
This commit is contained in:
@@ -1365,6 +1365,18 @@ namespace FlaxEngine
|
||||
*classAttributesCount = attributeTypes.Length;
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly]
|
||||
internal static IntPtr GetCustomAttribute(IntPtr typeHandle, IntPtr attribHandle)
|
||||
{
|
||||
Type type = (Type)GCHandle.FromIntPtr(typeHandle).Target;
|
||||
Type attribType = (Type)GCHandle.FromIntPtr(attribHandle).Target;
|
||||
object attrib = type.GetCustomAttributes(false).FirstOrDefault(x => x.GetType() == attribType);
|
||||
|
||||
if (attrib != null)
|
||||
return GCHandle.ToIntPtr(GCHandle.Alloc(attrib, GCHandleType.Weak));
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
[UnmanagedCallersOnly]
|
||||
internal static void GetClassInterfaces(IntPtr typeHandle, IntPtr* classInterfaces, int* classInterfacesCount)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user