Skip to content

Commit

Permalink
Update src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs
Browse files Browse the repository at this point in the history
Co-authored-by: Ankit Jain <radical@gmail.com>
  • Loading branch information
vargaz and radical committed Nov 1, 2022
1 parent 23b1dca commit c64c6f7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/tasks/WasmAppBuilder/PInvokeTableGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void CollectPInvokes(List<PInvoke> pinvokes, List<PInvokeCallback> callb
}
}

if (HasAttribute(type, new string[] {"System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute"}))
if (HasAttribute(type, "System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute"))
{
var method = type.GetMethod("Invoke");

Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit c64c6f7

Please sign in to comment.