mirror of
https://github.com/focus-creative-games/hybridclr_unity.git
synced 2026-11-19 14:52:41 +08:00
[fix] fix raising NullReferenceException in generating MethodBridge for MonoPInvokeCallbackAttribute while constructor arguments is empty.
This commit is contained in:
@@ -559,6 +559,11 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
{
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
if (monoPInvokeCallbackAttr.ConstructorArguments.Count == 0)
|
||||
{
|
||||
Debug.LogError($"MonoPInvokeCallbackAttribute on method {method.FullName} has no constructor arguments. Using CallingConvention.Winapi as default.");
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
object delegateTypeSig = monoPInvokeCallbackAttr.ConstructorArguments[0].Value;
|
||||
|
||||
TypeDef delegateTypeDef;
|
||||
@@ -580,7 +585,7 @@ namespace HybridCLR.Editor.MethodBridge
|
||||
throw new NotSupportedException($"Unsupported delegate type: {delegateTypeSig}");
|
||||
}
|
||||
var attr = delegateTypeDef.CustomAttributes.FirstOrDefault(ca => ca.AttributeType.FullName == "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute");
|
||||
if (attr == null)
|
||||
if (attr == null || attr.ConstructorArguments.Count == 0)
|
||||
{
|
||||
return CallingConvention.Winapi;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user