Skip to content

Commit 4e6f295

Browse files
committed
fix: fix the bug that get P/Invoke register fail when register P/Invoke method with [<module>] and not parameter signature.
1 parent 30b377e commit 4e6f295

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/runtime/vm/pinvoke.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,18 @@ RtResult<const PInvokeRegistry*> PInvokes::get_pinvoke_by_method(const metadata:
5757
{
5858
// signature: Namespace.Class.Method
5959
sb.clear();
60+
sb.append_char('[');
61+
sb.append_cstr(method->parent->image->get_name_no_ext());
62+
sb.append_char(']');
63+
size_t length = sb.length();
6064
RET_ERR_ON_FAIL(metadata::MetadataName::append_method_full_name_without_params(sb, method));
61-
auto it = g_pinvoke_map.find(sb.as_cstr());
65+
66+
const char* signature_with_module = sb.as_cstr();
67+
auto it = g_pinvoke_map.find(signature_with_module);
68+
if (it != g_pinvoke_map.end())
69+
RET_OK(&it->second);
70+
const char* signature_without_module = sb.as_cstr() + length;
71+
it = g_pinvoke_map.find(signature_without_module);
6272
if (it != g_pinvoke_map.end())
6373
RET_OK(&it->second);
6474
}

0 commit comments

Comments
 (0)