From: Vibhav Pant vibhavp@gmail.com
--- dlls/rometadata/mdtables.c | 15 +++++++++++++-- dlls/rometadata/tests/rometadata.c | 28 ++++++++++++++-------------- 2 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/dlls/rometadata/mdtables.c b/dlls/rometadata/mdtables.c index 0a205f5a481..d7849e393f3 100644 --- a/dlls/rometadata/mdtables.c +++ b/dlls/rometadata/mdtables.c @@ -1062,8 +1062,19 @@ static HRESULT WINAPI import_EnumPermissionSets(IMetaDataImport *iface, HCORENUM static HRESULT WINAPI import_FindMember(IMetaDataImport *iface, mdTypeDef type_def, const WCHAR *name, const COR_SIGNATURE *sig_blob, ULONG len, mdToken *member_ref) { - FIXME("(%p, %#x, %s, %p, %lu, %p): stub!\n", iface, type_def, debugstr_w(name), sig_blob, len, member_ref); - return E_NOTIMPL; + HRESULT hr; + + TRACE("(%p, %s, %s, %p, %lu, %p)\n", iface, debugstr_mdToken(type_def), debugstr_w(name), sig_blob, len, + member_ref); + + if (!name) return E_INVALIDARG; + if (IsNilToken(type_def) || TypeFromToken(type_def) != mdtTypeDef) return S_FALSE; + + /* If a method and a field have the same name, native returns the method. */ + hr = IMetaDataImport_FindMethod(iface, type_def, name, sig_blob, len, member_ref); + if (hr == CLDB_E_RECORD_NOTFOUND) + hr = IMetaDataImport_FindField(iface, type_def, name, sig_blob, len, member_ref); + return hr; }
static HRESULT WINAPI import_FindMethod(IMetaDataImport *iface, mdTypeDef type_def, const WCHAR *name, diff --git a/dlls/rometadata/tests/rometadata.c b/dlls/rometadata/tests/rometadata.c index 7d357c7da2d..a28a2f0f113 100644 --- a/dlls/rometadata/tests/rometadata.c +++ b/dlls/rometadata/tests/rometadata.c @@ -1204,14 +1204,14 @@ static void test_IMetaDataImport(void)
token = mdTokenNil; hr = IMetaDataImport_FindMember(md_import, typedef2, name, sig_blob, sig_len, &token); - todo_wine ok(hr == S_OK, "got hr %#lx\n", hr); - todo_wine ok(token == typedef_tokens[i], "got token %s != %s\n", debugstr_mdToken(token), - debugstr_mdToken(methoddef_tokens[i])); + ok(hr == S_OK, "got hr %#lx\n", hr); + ok(token == typedef_tokens[i], "got token %s != %s\n", debugstr_mdToken(token), + debugstr_mdToken(methoddef_tokens[i])); token = mdTokenNil; hr = IMetaDataImport_FindMember(md_import, typedef2, name, NULL, 0, &token); - todo_wine ok(hr == S_OK, "got hr %#lx\n", hr); - todo_wine ok(token == typedef_tokens[i], "got token %s != %s\n", debugstr_mdToken(token), - debugstr_mdToken(methoddef_tokens[i])); + ok(hr == S_OK, "got hr %#lx\n", hr); + ok(token == typedef_tokens[i], "got token %s != %s\n", debugstr_mdToken(token), + debugstr_mdToken(methoddef_tokens[i]));
winetest_pop_context(); } @@ -1333,14 +1333,14 @@ static void test_IMetaDataImport(void)
token = mdTokenNil; hr = IMetaDataImport_FindMember(md_import, typedef2, name, sig_blob, sig_len, &token); - todo_wine ok(hr == S_OK, "got hr %#lx\n", hr); - todo_wine ok(token == fielddef_tokens[field_idx], "got token %s != %s\n", debugstr_mdToken(token), - debugstr_mdToken(fielddef_tokens[field_idx])); + ok(hr == S_OK, "got hr %#lx\n", hr); + ok(token == fielddef_tokens[field_idx], "got token %s != %s\n", debugstr_mdToken(token), + debugstr_mdToken(fielddef_tokens[field_idx])); token = mdTokenNil; hr = IMetaDataImport_FindMember(md_import, typedef2, name, NULL, 0, &token); - todo_wine ok(hr == S_OK, "got hr %#lx\n", hr); - todo_wine ok(token == fielddef_tokens[field_idx], "got token %s != %s\n", debugstr_mdToken(token), - debugstr_mdToken(fielddef_tokens[field_idx])); + ok(hr == S_OK, "got hr %#lx\n", hr); + ok(token == fielddef_tokens[field_idx], "got token %s != %s\n", debugstr_mdToken(token), + debugstr_mdToken(fielddef_tokens[field_idx]));
winetest_pop_context(); } @@ -1354,9 +1354,9 @@ static void test_IMetaDataImport(void) ok(hr == CLDB_E_RECORD_NOTFOUND, "got hr %#lx\n", hr);
hr = IMetaDataImport_FindMember(md_import, typedef1, NULL, NULL, 0, &token); - todo_wine ok(hr == E_INVALIDARG, "got hr %#lx\n", hr); + ok(hr == E_INVALIDARG, "got hr %#lx\n", hr); hr = IMetaDataImport_FindMember(md_import, typedef1, L"foo", NULL, 0, &token); - todo_wine ok(hr == CLDB_E_RECORD_NOTFOUND, "got hr %#lx\n", hr); + ok(hr == CLDB_E_RECORD_NOTFOUND, "got hr %#lx\n", hr);
typedef1 = buf_len = 0; data = NULL;