You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I need to enumerate all implemented interfaces in a class, for example List.
Let's imagine that
ICorDebugType* ptList;
refers to the List type.
and
IMetadataImport* pMD;
points to IMetadataImport interface.
The code looks like that:
ICorDebugClass* ptListClass;
mdTypeDef metaTypeDef;
CorElementType ty;
HRESULT stat;
HCORENUM phEnum = NULL;
ULONG pcImpls;
mdInterfaceImpl rImpls[10];
stat = ptList->GetType(&ty);
if (ty == ELEMENT_TYPE_CLASS || ty == ELEMENT_TYPE_VALUETYPE)
{
stat = pType->GetClass(&ptListClass);
stat = ptListClass->GetToken(&metaTypeDef);
stat = pMD->EnumInterfaceImpls(&phEnum, metaTypeDef, rImpls, 10, &pcImpls);
}
The problem is that EnumInterfaceImpls returns S_FALSE that means it couldn't find any implemented interfaces and the counter pcImpls is 0.
In fact, class List implements several interfaces:
public partial class List : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I need to enumerate all implemented interfaces in a class, for example List.
Let's imagine that
ICorDebugType* ptList;
refers to the List type.
and
IMetadataImport* pMD;
points to IMetadataImport interface.
The code looks like that:
ICorDebugClass* ptListClass;
mdTypeDef metaTypeDef;
CorElementType ty;
HRESULT stat;
HCORENUM phEnum = NULL;
ULONG pcImpls;
mdInterfaceImpl rImpls[10];
stat = ptList->GetType(&ty);
if (ty == ELEMENT_TYPE_CLASS || ty == ELEMENT_TYPE_VALUETYPE)
{
stat = pType->GetClass(&ptListClass);
stat = ptListClass->GetToken(&metaTypeDef);
stat = pMD->EnumInterfaceImpls(&phEnum, metaTypeDef, rImpls, 10, &pcImpls);
}
The problem is that EnumInterfaceImpls returns S_FALSE that means it couldn't find any implemented interfaces and the counter pcImpls is 0.
In fact, class List implements several interfaces:
public partial class List : System.Collections.Generic.ICollection, System.Collections.Generic.IEnumerable, System.Collections.Generic.IList, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.ICollection, System.Collections.IEnumerable, System.Collections.IList
So, what am I doing wrong?
Beta Was this translation helpful? Give feedback.
All reactions