From c64c6f789d9ef709f514a46140d2431b478b2112 Mon Sep 17 00:00:00 2001 From: Zoltan Varga Date: Tue, 1 Nov 2022 05:06:40 -0400 Subject: [PATCH] Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs Co-authored-by: Ankit Jain --- src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs index effa6a8550a95..74349b38166dd 100644 --- a/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs +++ b/src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs @@ -79,7 +79,7 @@ private void CollectPInvokes(List pinvokes, List callb } } - if (HasAttribute(type, new string[] {"System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute"})) + if (HasAttribute(type, "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute")) { var method = type.GetMethod("Invoke"); @@ -167,15 +167,20 @@ static bool MethodHasCallbackAttributes(MethodInfo method) } } - private static bool HasAttribute(Type type, string[] attributeNames) + private static bool HasAttribute(MemberInfo element, params string[] attributeNames) { - foreach (CustomAttributeData cattr in CustomAttributeData.GetCustomAttributes(type)) + foreach (CustomAttributeData cattr in CustomAttributeData.GetCustomAttributes(element)) { try { for (int i = 0; i < attributeNames.Length; ++i) - if (cattr.AttributeType.FullName == attributeNames [i]) + { + if (cattr.AttributeType.FullName == attributeNames [i] || + cattr.AttributeType.Name == attributeNames[i]) + { return true; + } + } } catch {